Merge "bootclasspath_fragment: Require at least one hidden_api package property" am: 4a737a2d8b

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2062450

Change-Id: Iba3a72d689afcd626f5794da150d54c670792031
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot 2022-06-06 18:15:56 +00:00 committed by Automerger Merge Worker
commit 811d444ce1
8 changed files with 120 additions and 3 deletions

View file

@ -6227,6 +6227,9 @@ func TestOverrideApex(t *testing.T) {
name: "mybootclasspath_fragment", name: "mybootclasspath_fragment",
contents: ["bcplib"], contents: ["bcplib"],
apex_available: ["myapex"], apex_available: ["myapex"],
hidden_api: {
split_packages: ["*"],
},
} }
java_library { java_library {
@ -6241,6 +6244,9 @@ func TestOverrideApex(t *testing.T) {
name: "override_bootclasspath_fragment", name: "override_bootclasspath_fragment",
contents: ["override_bcplib"], contents: ["override_bcplib"],
apex_available: ["myapex"], apex_available: ["myapex"],
hidden_api: {
split_packages: ["*"],
},
} }
java_library { java_library {
@ -7294,6 +7300,9 @@ func testNoUpdatableJarsInBootImage(t *testing.T, errmsg string, preparer androi
apex_available: [ apex_available: [
"some-non-updatable-apex", "some-non-updatable-apex",
], ],
hidden_api: {
split_packages: ["*"],
},
} }
java_library { java_library {
@ -7352,6 +7361,9 @@ func testNoUpdatableJarsInBootImage(t *testing.T, errmsg string, preparer androi
apex_available: [ apex_available: [
"com.android.art.debug", "com.android.art.debug",
], ],
hidden_api: {
split_packages: ["*"],
},
} }
apex_key { apex_key {
@ -8695,6 +8707,9 @@ func TestApexJavaCoverage(t *testing.T) {
name: "mybootclasspathfragment", name: "mybootclasspathfragment",
contents: ["mybootclasspathlib"], contents: ["mybootclasspathlib"],
apex_available: ["myapex"], apex_available: ["myapex"],
hidden_api: {
split_packages: ["*"],
},
} }
java_library { java_library {
@ -9015,6 +9030,9 @@ func TestSdkLibraryCanHaveHigherMinSdkVersion(t *testing.T) {
name: "mybootclasspathfragment", name: "mybootclasspathfragment",
contents: ["mybootclasspathlib"], contents: ["mybootclasspathlib"],
apex_available: ["myapex"], apex_available: ["myapex"],
hidden_api: {
split_packages: ["*"],
},
} }
java_sdk_library { java_sdk_library {
@ -9115,6 +9133,9 @@ func TestSdkLibraryCanHaveHigherMinSdkVersion(t *testing.T) {
name: "mybootclasspathfragment", name: "mybootclasspathfragment",
contents: ["mybootclasspathlib"], contents: ["mybootclasspathlib"],
apex_available: ["myapex"], apex_available: ["myapex"],
hidden_api: {
split_packages: ["*"],
},
} }
java_sdk_library { java_sdk_library {
@ -9334,6 +9355,9 @@ func TestApexStrictUpdtabilityLintBcpFragmentDeps(t *testing.T) {
name: "mybootclasspathfragment", name: "mybootclasspathfragment",
contents: ["myjavalib"], contents: ["myjavalib"],
apex_available: ["myapex"], apex_available: ["myapex"],
hidden_api: {
split_packages: ["*"],
},
} }
java_library { java_library {
name: "myjavalib", name: "myjavalib",

View file

@ -110,6 +110,9 @@ func TestBootclasspathFragments(t *testing.T) {
apex_available: [ apex_available: [
"com.android.art", "com.android.art",
], ],
hidden_api: {
split_packages: ["*"],
},
} }
`, `,
) )
@ -209,6 +212,9 @@ func TestBootclasspathFragments_FragmentDependency(t *testing.T) {
apex_available: [ apex_available: [
"com.android.art", "com.android.art",
], ],
hidden_api: {
split_packages: ["*"],
},
} }
bootclasspath_fragment { bootclasspath_fragment {
@ -220,6 +226,9 @@ func TestBootclasspathFragments_FragmentDependency(t *testing.T) {
module: "art-bootclasspath-fragment", module: "art-bootclasspath-fragment",
}, },
], ],
hidden_api: {
split_packages: ["*"],
},
} }
`, `,
) )
@ -361,6 +370,9 @@ func TestBootclasspathFragmentInArtApex(t *testing.T) {
apex_available: [ apex_available: [
"com.android.art", "com.android.art",
], ],
hidden_api: {
split_packages: ["*"],
},
} }
`, contentsInsert(contents)) `, contentsInsert(contents))
@ -853,6 +865,9 @@ func TestBootclasspathFragmentContentsNoName(t *testing.T) {
apex_available: [ apex_available: [
"myapex", "myapex",
], ],
hidden_api: {
split_packages: ["*"],
},
} }
`) `)
@ -959,6 +974,9 @@ func TestBootclasspathFragment_HiddenAPIList(t *testing.T) {
apex_available: [ apex_available: [
"com.android.art", "com.android.art",
], ],
hidden_api: {
split_packages: ["*"],
},
} }
apex { apex {
@ -1010,6 +1028,9 @@ func TestBootclasspathFragment_HiddenAPIList(t *testing.T) {
module: "art-bootclasspath-fragment", module: "art-bootclasspath-fragment",
}, },
], ],
hidden_api: {
split_packages: ["*"],
},
} }
`) `)
@ -1123,6 +1144,9 @@ func TestBootclasspathFragment_AndroidNonUpdatable(t *testing.T) {
apex_available: [ apex_available: [
"com.android.art", "com.android.art",
], ],
hidden_api: {
split_packages: ["*"],
},
} }
apex { apex {
@ -1175,6 +1199,9 @@ func TestBootclasspathFragment_AndroidNonUpdatable(t *testing.T) {
module: "art-bootclasspath-fragment", module: "art-bootclasspath-fragment",
}, },
], ],
hidden_api: {
split_packages: ["*"],
},
} }
`) `)
@ -1282,6 +1309,9 @@ func TestBootclasspathFragment_AndroidNonUpdatable_AlwaysUsePrebuiltSdks(t *test
apex_available: [ apex_available: [
"com.android.art", "com.android.art",
], ],
hidden_api: {
split_packages: ["*"],
},
} }
apex { apex {
@ -1334,6 +1364,9 @@ func TestBootclasspathFragment_AndroidNonUpdatable_AlwaysUsePrebuiltSdks(t *test
module: "art-bootclasspath-fragment", module: "art-bootclasspath-fragment",
}, },
], ],
hidden_api: {
split_packages: ["*"],
},
} }
`) `)

View file

@ -88,6 +88,9 @@ func TestCreateClasspathElements(t *testing.T) {
"baz", "baz",
"quuz", "quuz",
], ],
hidden_api: {
split_packages: ["*"],
},
} }
java_library { java_library {
@ -134,6 +137,9 @@ func TestCreateClasspathElements(t *testing.T) {
contents: [ contents: [
"bar", "bar",
], ],
hidden_api: {
split_packages: ["*"],
},
} }
java_library { java_library {

View file

@ -125,6 +125,7 @@ func TestPlatformBootclasspath_Fragments(t *testing.T) {
unsupported_packages: [ unsupported_packages: [
"bar-unsupported-packages.txt", "bar-unsupported-packages.txt",
], ],
split_packages: ["*"],
}, },
} }
@ -274,6 +275,9 @@ func TestPlatformBootclasspathDependencies(t *testing.T) {
"baz", "baz",
"quuz", "quuz",
], ],
hidden_api: {
split_packages: ["*"],
},
} }
java_library { java_library {
@ -317,6 +321,9 @@ func TestPlatformBootclasspathDependencies(t *testing.T) {
name: "my-bootclasspath-fragment", name: "my-bootclasspath-fragment",
contents: ["bar"], contents: ["bar"],
apex_available: ["myapex"], apex_available: ["myapex"],
hidden_api: {
split_packages: ["*"],
},
} }
apex_key { apex_key {
@ -482,6 +489,9 @@ func TestPlatformBootclasspath_AlwaysUsePrebuiltSdks(t *testing.T) {
contents: [ contents: [
"foo", "bar", "foo", "bar",
], ],
hidden_api: {
split_packages: ["*"],
},
} }
prebuilt_bootclasspath_fragment { prebuilt_bootclasspath_fragment {
@ -599,6 +609,9 @@ func TestPlatformBootclasspath_IncludesRemainingApexJars(t *testing.T) {
generate_classpaths_proto: false, generate_classpaths_proto: false,
contents: ["foo"], contents: ["foo"],
apex_available: ["myapex"], apex_available: ["myapex"],
hidden_api: {
split_packages: ["*"],
},
} }
java_library { java_library {
@ -656,6 +669,9 @@ func TestBootJarNotInApex(t *testing.T) {
contents: [ contents: [
"foo", "foo",
], ],
hidden_api: {
split_packages: ["*"],
},
} }
platform_bootclasspath { platform_bootclasspath {
@ -696,6 +712,9 @@ func TestBootFragmentNotInApex(t *testing.T) {
bootclasspath_fragment { bootclasspath_fragment {
name: "not-in-apex-fragment", name: "not-in-apex-fragment",
contents: ["foo"], contents: ["foo"],
hidden_api: {
split_packages: ["*"],
},
} }
platform_bootclasspath { platform_bootclasspath {
@ -746,6 +765,9 @@ func TestNonBootJarInFragment(t *testing.T) {
name: "apex-fragment", name: "apex-fragment",
contents: ["foo", "bar"], contents: ["foo", "bar"],
apex_available:[ "myapex" ], apex_available:[ "myapex" ],
hidden_api: {
split_packages: ["*"],
},
} }
platform_bootclasspath { platform_bootclasspath {

View file

@ -858,11 +858,18 @@ func (b *BootclasspathFragmentModule) produceHiddenAPIOutput(ctx android.ModuleC
packagePrefixes := b.sourceOnlyProperties.Hidden_api.Package_prefixes packagePrefixes := b.sourceOnlyProperties.Hidden_api.Package_prefixes
singlePackages := b.sourceOnlyProperties.Hidden_api.Single_packages singlePackages := b.sourceOnlyProperties.Hidden_api.Single_packages
if splitPackages != nil || packagePrefixes != nil || singlePackages != nil { if splitPackages != nil || packagePrefixes != nil || singlePackages != nil {
if splitPackages == nil {
splitPackages = []string{"*"}
}
output.SignaturePatternsPath = buildRuleSignaturePatternsFile( output.SignaturePatternsPath = buildRuleSignaturePatternsFile(
ctx, output.AllFlagsPath, splitPackages, packagePrefixes, singlePackages) ctx, output.AllFlagsPath, splitPackages, packagePrefixes, singlePackages)
} else if !b.isTestFragment() {
ctx.ModuleErrorf(`Must specify at least one of the split_packages, package_prefixes and single_packages properties
If this is a new bootclasspath_fragment or you are unsure what to do add the
the following to the bootclasspath_fragment:
hidden_api: {split_packages: ["*"]},
and then run the following:
m analyze_bcpf && analyze_bcpf --bcpf %q
it will analyze the bootclasspath_fragment and provide hints as to what you
should specify here. If you are happy with its suggestions then you can add
the --fix option and it will fix them for you.`, b.BaseModuleName())
} }
return output return output

View file

@ -121,6 +121,9 @@ func TestBootclasspathFragment_Coverage(t *testing.T) {
], ],
}, },
}, },
hidden_api: {
split_packages: ["*"],
},
} }
java_library { java_library {
@ -201,6 +204,9 @@ func TestBootclasspathFragment_StubLibs(t *testing.T) {
core_platform_api: { core_platform_api: {
stub_libs: ["mycoreplatform.stubs"], stub_libs: ["mycoreplatform.stubs"],
}, },
hidden_api: {
split_packages: ["*"],
},
} }
java_library { java_library {

View file

@ -101,6 +101,9 @@ func TestSnapshotWithBootclasspathFragment_ImageName(t *testing.T) {
image_name: "art", image_name: "art",
contents: ["mybootlib"], contents: ["mybootlib"],
apex_available: ["com.android.art"], apex_available: ["com.android.art"],
hidden_api: {
split_packages: ["*"],
},
} }
apex_key { apex_key {
@ -235,6 +238,9 @@ func TestSnapshotWithBootClasspathFragment_Contents(t *testing.T) {
// This should be automatically added to the sdk_snapshot as a java_sdk_libs module. // This should be automatically added to the sdk_snapshot as a java_sdk_libs module.
stub_libs: ["mycoreplatform"], stub_libs: ["mycoreplatform"],
}, },
hidden_api: {
split_packages: ["*"],
},
} }
java_library { java_library {
@ -453,6 +459,9 @@ func TestSnapshotWithBootClasspathFragment_Fragments(t *testing.T) {
contents: [ contents: [
"myotherlib", "myotherlib",
], ],
hidden_api: {
split_packages: ["*"],
},
} }
java_library { java_library {
@ -482,6 +491,9 @@ func TestSnapshotWithBootClasspathFragment_Fragments(t *testing.T) {
module: "myotherbootclasspathfragment" module: "myotherbootclasspathfragment"
}, },
], ],
hidden_api: {
split_packages: ["*"],
},
} }
java_sdk_library { java_sdk_library {
@ -561,6 +573,9 @@ func TestBasicSdkWithBootclasspathFragment(t *testing.T) {
image_name: "art", image_name: "art",
contents: ["mybootlib"], contents: ["mybootlib"],
apex_available: ["myapex"], apex_available: ["myapex"],
hidden_api: {
split_packages: ["*"],
},
} }
java_library { java_library {
@ -668,6 +683,7 @@ func TestSnapshotWithBootclasspathFragment_HiddenAPI(t *testing.T) {
unsupported_packages: [ unsupported_packages: [
"my-unsupported-packages.txt", "my-unsupported-packages.txt",
], ],
split_packages: ["*"],
}, },
} }

View file

@ -473,6 +473,9 @@ java_import {
name: "mybootclasspathfragment", name: "mybootclasspathfragment",
apex_available: ["myapex"], apex_available: ["myapex"],
contents: ["mysdklibrary"], contents: ["mysdklibrary"],
hidden_api: {
split_packages: ["*"],
},
} }
java_sdk_library { java_sdk_library {