Merge "Disable monolithic hiddenapi flags generation for non java devices." into main am: d700486907

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

Change-Id: I0ddba09be3cef955d66d7788d80d94dc242e46b0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Spandan Das
2024-05-17 21:38:27 +00:00
committed by Automerger Merge Worker
4 changed files with 61 additions and 6 deletions

View File

@@ -5049,6 +5049,20 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
// Make sure that the frameworks/base/Android.bp file exists as otherwise hidden API encoding // Make sure that the frameworks/base/Android.bp file exists as otherwise hidden API encoding
// is disabled. // is disabled.
android.FixtureAddTextFile("frameworks/base/Android.bp", ""), android.FixtureAddTextFile("frameworks/base/Android.bp", ""),
// Make sure that we have atleast one platform library so that we can check the monolithic hiddenapi
// file creation.
java.FixtureConfigureBootJars("platform:foo"),
android.FixtureModifyMockFS(func(fs android.MockFS) {
fs["platform/Android.bp"] = []byte(`
java_library {
name: "foo",
srcs: ["Test.java"],
compile_dex: true,
}
`)
fs["platform/Test.java"] = nil
}),
) )
checkBootDexJarPath := func(t *testing.T, ctx *android.TestContext, stem string, bootDexJarPath string) { checkBootDexJarPath := func(t *testing.T, ctx *android.TestContext, stem string, bootDexJarPath string) {
@@ -5143,7 +5157,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libbar.jar") checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libbar.jar")
// Verify the correct module jars contribute to the hiddenapi index file. // Verify the correct module jars contribute to the hiddenapi index file.
checkHiddenAPIIndexFromClassesInputs(t, ctx, ``) checkHiddenAPIIndexFromClassesInputs(t, ctx, `out/soong/.intermediates/platform/foo/android_common/javac/foo.jar`)
checkHiddenAPIIndexFromFlagsInputs(t, ctx, ` checkHiddenAPIIndexFromFlagsInputs(t, ctx, `
my-bootclasspath-fragment/index.csv my-bootclasspath-fragment/index.csv
out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv
@@ -5221,7 +5235,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libbar.jar") checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libbar.jar")
// Verify the correct module jars contribute to the hiddenapi index file. // Verify the correct module jars contribute to the hiddenapi index file.
checkHiddenAPIIndexFromClassesInputs(t, ctx, ``) checkHiddenAPIIndexFromClassesInputs(t, ctx, `out/soong/.intermediates/platform/foo/android_common/javac/foo.jar`)
checkHiddenAPIIndexFromFlagsInputs(t, ctx, ` checkHiddenAPIIndexFromFlagsInputs(t, ctx, `
my-bootclasspath-fragment/index.csv my-bootclasspath-fragment/index.csv
out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv
@@ -5410,7 +5424,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libbar.jar") checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libbar.jar")
// Verify the correct module jars contribute to the hiddenapi index file. // Verify the correct module jars contribute to the hiddenapi index file.
checkHiddenAPIIndexFromClassesInputs(t, ctx, ``) checkHiddenAPIIndexFromClassesInputs(t, ctx, `out/soong/.intermediates/platform/foo/android_common/javac/foo.jar`)
checkHiddenAPIIndexFromFlagsInputs(t, ctx, ` checkHiddenAPIIndexFromFlagsInputs(t, ctx, `
my-bootclasspath-fragment/index.csv my-bootclasspath-fragment/index.csv
out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv
@@ -5507,7 +5521,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/my-bootclasspath-fragment/android_common_myapex/hiddenapi-modular/encoded/libbar.jar") checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/my-bootclasspath-fragment/android_common_myapex/hiddenapi-modular/encoded/libbar.jar")
// Verify the correct module jars contribute to the hiddenapi index file. // Verify the correct module jars contribute to the hiddenapi index file.
checkHiddenAPIIndexFromClassesInputs(t, ctx, ``) checkHiddenAPIIndexFromClassesInputs(t, ctx, `out/soong/.intermediates/platform/foo/android_common/javac/foo.jar`)
checkHiddenAPIIndexFromFlagsInputs(t, ctx, ` checkHiddenAPIIndexFromFlagsInputs(t, ctx, `
out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv
out/soong/.intermediates/my-bootclasspath-fragment/android_common_myapex/modular-hiddenapi/index.csv out/soong/.intermediates/my-bootclasspath-fragment/android_common_myapex/modular-hiddenapi/index.csv
@@ -5620,7 +5634,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) {
checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libbar.jar") checkBootDexJarPath(t, ctx, "libbar", "out/soong/.intermediates/prebuilt_myapex.deapexer/android_common/deapexer/javalib/libbar.jar")
// Verify the correct module jars contribute to the hiddenapi index file. // Verify the correct module jars contribute to the hiddenapi index file.
checkHiddenAPIIndexFromClassesInputs(t, ctx, ``) checkHiddenAPIIndexFromClassesInputs(t, ctx, `out/soong/.intermediates/platform/foo/android_common/javac/foo.jar`)
checkHiddenAPIIndexFromFlagsInputs(t, ctx, ` checkHiddenAPIIndexFromFlagsInputs(t, ctx, `
my-bootclasspath-fragment/index.csv my-bootclasspath-fragment/index.csv
out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv
@@ -11239,6 +11253,20 @@ func TestBootDexJarsMultipleApexPrebuilts(t *testing.T) {
android.FixtureMergeMockFs(map[string][]byte{ android.FixtureMergeMockFs(map[string][]byte{
"system/sepolicy/apex/com.android.foo-file_contexts": nil, "system/sepolicy/apex/com.android.foo-file_contexts": nil,
}), }),
// Make sure that we have atleast one platform library so that we can check the monolithic hiddenapi
// file creation.
java.FixtureConfigureBootJars("platform:foo"),
android.FixtureModifyMockFS(func(fs android.MockFS) {
fs["platform/Android.bp"] = []byte(`
java_library {
name: "foo",
srcs: ["Test.java"],
compile_dex: true,
}
`)
fs["platform/Test.java"] = nil
}),
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.BuildFlags = map[string]string{ variables.BuildFlags = map[string]string{
"RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": tc.selectedApexContributions, "RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": tc.selectedApexContributions,

View File

@@ -198,13 +198,22 @@ func TestHiddenAPISingletonSdks(t *testing.T) {
hiddenApiFixtureFactory, hiddenApiFixtureFactory,
tc.preparer, tc.preparer,
prepareForTestWithDefaultPlatformBootclasspath, prepareForTestWithDefaultPlatformBootclasspath,
// Make sure that we have atleast one platform library so that we can check the monolithic hiddenapi
// file creation.
FixtureConfigureBootJars("platform:foo"),
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
variables.Always_use_prebuilt_sdks = proptools.BoolPtr(tc.unbundledBuild) variables.Always_use_prebuilt_sdks = proptools.BoolPtr(tc.unbundledBuild)
variables.BuildFlags = map[string]string{ variables.BuildFlags = map[string]string{
"RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true", "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
} }
}), }),
).RunTest(t) ).RunTestWithBp(t, `
java_library {
name: "foo",
srcs: ["a.java"],
compile_dex: true,
}
`)
hiddenAPI := result.ModuleForTests("platform-bootclasspath", "android_common") hiddenAPI := result.ModuleForTests("platform-bootclasspath", "android_common")
hiddenapiRule := hiddenAPI.Rule("platform-bootclasspath-monolithic-hiddenapi-stub-flags") hiddenapiRule := hiddenAPI.Rule("platform-bootclasspath-monolithic-hiddenapi-stub-flags")

View File

@@ -325,6 +325,11 @@ func (b *platformBootclasspathModule) generateHiddenAPIBuildActions(ctx android.
// the fragments will have already provided the flags that are needed. // the fragments will have already provided the flags that are needed.
classesJars := monolithicInfo.ClassesJars classesJars := monolithicInfo.ClassesJars
if len(classesJars) == 0 {
// This product does not include any monolithic jars. Monolithic hiddenapi flag generation is not required.
return bootDexJarByModule
}
// Create the input to pass to buildRuleToGenerateHiddenAPIStubFlagsFile // Create the input to pass to buildRuleToGenerateHiddenAPIStubFlagsFile
input := newHiddenAPIFlagInput() input := newHiddenAPIFlagInput()

View File

@@ -281,6 +281,19 @@ func testSnapshotWithBootClasspathFragment_Contents(t *testing.T, sdk string, co
"RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true", "RELEASE_HIDDEN_API_EXPORTABLE_STUBS": "true",
} }
}), }),
// Make sure that we have atleast one platform library so that we can check the monolithic hiddenapi
// file creation.
java.FixtureConfigureBootJars("platform:foo"),
android.FixtureModifyMockFS(func(fs android.MockFS) {
fs["platform/Android.bp"] = []byte(`
java_library {
name: "foo",
srcs: ["Test.java"],
compile_dex: true,
}
`)
fs["platform/Test.java"] = nil
}),
android.FixtureWithRootAndroidBp(sdk+` android.FixtureWithRootAndroidBp(sdk+`
apex { apex {