Loading apex/apex_test.go +96 −13 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ import ( "io/ioutil" "os" "path" "path/filepath" "reflect" "regexp" "sort" Loading Loading @@ -4518,14 +4519,16 @@ func TestPrebuiltExportDexImplementationJars(t *testing.T) { func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { transform := func(config *dexpreopt.GlobalConfig) { config.BootJars = android.CreateTestConfiguredJarList([]string{"myapex:libfoo"}) config.BootJars = android.CreateTestConfiguredJarList([]string{"myapex:libfoo", "myapex:libbar"}) } checkBootDexJarPath := func(t *testing.T, ctx *android.TestContext, bootDexJarPath string) { checkBootDexJarPath := func(t *testing.T, ctx *android.TestContext, stem string, bootDexJarPath string) { t.Helper() s := ctx.SingletonForTests("dex_bootjars") foundLibfooJar := false base := stem + ".jar" for _, output := range s.AllOutputs() { if strings.HasSuffix(output, "/libfoo.jar") { if filepath.Base(output) == base { foundLibfooJar = true buildRule := s.Output(output) actual := android.NormalizePathForTesting(buildRule.Input) Loading @@ -4540,6 +4543,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { } checkHiddenAPIIndexInputs := func(t *testing.T, ctx *android.TestContext, expectedInputs string) { t.Helper() hiddenAPIIndex := ctx.SingletonForTests("hiddenapi_index") indexRule := hiddenAPIIndex.Rule("singleton-merged-hiddenapi-index") java.CheckHiddenAPIRuleInputs(t, expectedInputs, indexRule) Loading @@ -4557,7 +4561,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { src: "myapex-arm.apex", }, }, exported_java_libs: ["libfoo"], exported_java_libs: ["libfoo", "libbar"], } java_import { Loading @@ -4565,13 +4569,23 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { jars: ["libfoo.jar"], apex_available: ["myapex"], } java_sdk_library_import { name: "libbar", public: { jars: ["libbar.jar"], }, apex_available: ["myapex"], } ` ctx := testDexpreoptWithApexes(t, bp, "", transform) checkBootDexJarPath(t, ctx, ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar") checkBootDexJarPath(t, ctx, "libfoo", ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar") checkBootDexJarPath(t, ctx, "libbar", ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libbar.jar") // Make sure that the dex file from the prebuilt_apex contributes to the hiddenapi index file. checkHiddenAPIIndexInputs(t, ctx, ` .intermediates/libbar/android_common_myapex/hiddenapi/index.csv .intermediates/libfoo/android_common_myapex/hiddenapi/index.csv `) }) Loading @@ -4588,7 +4602,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { src: "myapex-arm.apex", }, }, exported_java_libs: ["libfoo"], exported_java_libs: ["libfoo", "libbar"], } java_import { Loading @@ -4602,6 +4616,21 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { srcs: ["foo/bar/MyClass.java"], apex_available: ["myapex"], } java_sdk_library_import { name: "libbar", public: { jars: ["libbar.jar"], }, apex_available: ["myapex"], } java_sdk_library { name: "libbar", srcs: ["foo/bar/MyClass.java"], unsafe_ignore_missing_latest_api: true, apex_available: ["myapex"], } ` // In this test the source (java_library) libfoo is active since the Loading @@ -4624,7 +4653,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { src: "myapex-arm.apex", }, }, exported_java_libs: ["libfoo"], exported_java_libs: ["libfoo", "libbar"], } java_import { Loading @@ -4639,13 +4668,31 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { srcs: ["foo/bar/MyClass.java"], apex_available: ["myapex"], } java_sdk_library_import { name: "libbar", prefer: true, public: { jars: ["libbar.jar"], }, apex_available: ["myapex"], } java_sdk_library { name: "libbar", srcs: ["foo/bar/MyClass.java"], unsafe_ignore_missing_latest_api: true, apex_available: ["myapex"], } ` ctx := testDexpreoptWithApexes(t, bp, "", transform) checkBootDexJarPath(t, ctx, ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar") checkBootDexJarPath(t, ctx, "libfoo", ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar") checkBootDexJarPath(t, ctx, "libbar", ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libbar.jar") // Make sure that the dex file from the prebuilt_apex contributes to the hiddenapi index file. checkHiddenAPIIndexInputs(t, ctx, ` .intermediates/prebuilt_libbar/android_common_myapex/hiddenapi/index.csv .intermediates/prebuilt_libfoo/android_common_myapex/hiddenapi/index.csv `) }) Loading @@ -4655,7 +4702,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { apex { name: "myapex", key: "myapex.key", java_libs: ["libfoo"], java_libs: ["libfoo", "libbar"], } apex_key { Loading @@ -4674,7 +4721,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { src: "myapex-arm.apex", }, }, exported_java_libs: ["libfoo"], exported_java_libs: ["libfoo", "libbar"], } java_import { Loading @@ -4688,13 +4735,30 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { srcs: ["foo/bar/MyClass.java"], apex_available: ["myapex"], } java_sdk_library_import { name: "libbar", public: { jars: ["libbar.jar"], }, apex_available: ["myapex"], } java_sdk_library { name: "libbar", srcs: ["foo/bar/MyClass.java"], unsafe_ignore_missing_latest_api: true, apex_available: ["myapex"], } ` ctx := testDexpreoptWithApexes(t, bp, "", transform) checkBootDexJarPath(t, ctx, ".intermediates/libfoo/android_common_apex10000/hiddenapi/libfoo.jar") checkBootDexJarPath(t, ctx, "libfoo", ".intermediates/libfoo/android_common_apex10000/hiddenapi/libfoo.jar") checkBootDexJarPath(t, ctx, "libbar", ".intermediates/libbar/android_common_myapex/hiddenapi/libbar.jar") // Make sure that the dex file from the prebuilt_apex contributes to the hiddenapi index file. checkHiddenAPIIndexInputs(t, ctx, ` .intermediates/libbar/android_common_myapex/hiddenapi/index.csv .intermediates/libfoo/android_common_apex10000/hiddenapi/index.csv `) }) Loading Loading @@ -4724,7 +4788,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { src: "myapex-arm.apex", }, }, exported_java_libs: ["libfoo"], exported_java_libs: ["libfoo", "libbar"], } java_import { Loading @@ -4739,13 +4803,31 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { srcs: ["foo/bar/MyClass.java"], apex_available: ["myapex"], } java_sdk_library_import { name: "libbar", prefer: true, public: { jars: ["libbar.jar"], }, apex_available: ["myapex"], } java_sdk_library { name: "libbar", srcs: ["foo/bar/MyClass.java"], unsafe_ignore_missing_latest_api: true, apex_available: ["myapex"], } ` ctx := testDexpreoptWithApexes(t, bp, "", transform) checkBootDexJarPath(t, ctx, ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar") checkBootDexJarPath(t, ctx, "libfoo", ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar") checkBootDexJarPath(t, ctx, "libbar", ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libbar.jar") // Make sure that the dex file from the prebuilt_apex contributes to the hiddenapi index file. checkHiddenAPIIndexInputs(t, ctx, ` .intermediates/prebuilt_libbar/android_common_prebuilt_myapex/hiddenapi/index.csv .intermediates/prebuilt_libfoo/android_common_prebuilt_myapex/hiddenapi/index.csv `) }) Loading Loading @@ -6374,6 +6456,7 @@ func testDexpreoptWithApexes(t *testing.T, bp, errmsg string, transformDexpreopt ctx.RegisterModuleType("prebuilt_apex", PrebuiltFactory) ctx.RegisterModuleType("filegroup", android.FileGroupFactory) ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators) ctx.PreArchMutators(android.RegisterComponentsMutator) android.RegisterPrebuiltMutators(ctx) cc.RegisterRequiredBuildComponentsForTest(ctx) java.RegisterRequiredBuildComponentsForTest(ctx) Loading java/sdk_library.go +4 −0 Original line number Diff line number Diff line Loading @@ -1772,6 +1772,8 @@ type SdkLibraryImport struct { android.ApexModuleBase android.SdkBase hiddenAPI properties sdkLibraryImportProperties // Map from api scope to the scope specific property structure. Loading Loading @@ -2046,6 +2048,8 @@ func (module *SdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleCo di := ctx.OtherModuleProvider(deapexerModule, android.DeapexerProvider).(android.DeapexerInfo) if dexOutputPath := di.PrebuiltExportPath(module.BaseModuleName(), ".dexjar"); dexOutputPath != nil { module.dexJarFile = dexOutputPath module.initHiddenAPI(ctx, module.configurationName) module.hiddenAPIExtractInformation(ctx, dexOutputPath, module.findScopePaths(apiScopePublic).stubsImplPath[0]) } else { // This should never happen as a variant for a prebuilt_apex is only created if the // prebuilt_apex has been configured to export the java library dex file. Loading java/testing.go +1 −0 Original line number Diff line number Diff line Loading @@ -240,6 +240,7 @@ func CheckModuleDependencies(t *testing.T, ctx *android.TestContext, name, varia } func CheckHiddenAPIRuleInputs(t *testing.T, expected string, hiddenAPIRule android.TestingBuildParams) { t.Helper() actual := strings.TrimSpace(strings.Join(android.NormalizePathsForTesting(hiddenAPIRule.Implicits), "\n")) expected = strings.TrimSpace(expected) if actual != expected { Loading Loading
apex/apex_test.go +96 −13 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ import ( "io/ioutil" "os" "path" "path/filepath" "reflect" "regexp" "sort" Loading Loading @@ -4518,14 +4519,16 @@ func TestPrebuiltExportDexImplementationJars(t *testing.T) { func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { transform := func(config *dexpreopt.GlobalConfig) { config.BootJars = android.CreateTestConfiguredJarList([]string{"myapex:libfoo"}) config.BootJars = android.CreateTestConfiguredJarList([]string{"myapex:libfoo", "myapex:libbar"}) } checkBootDexJarPath := func(t *testing.T, ctx *android.TestContext, bootDexJarPath string) { checkBootDexJarPath := func(t *testing.T, ctx *android.TestContext, stem string, bootDexJarPath string) { t.Helper() s := ctx.SingletonForTests("dex_bootjars") foundLibfooJar := false base := stem + ".jar" for _, output := range s.AllOutputs() { if strings.HasSuffix(output, "/libfoo.jar") { if filepath.Base(output) == base { foundLibfooJar = true buildRule := s.Output(output) actual := android.NormalizePathForTesting(buildRule.Input) Loading @@ -4540,6 +4543,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { } checkHiddenAPIIndexInputs := func(t *testing.T, ctx *android.TestContext, expectedInputs string) { t.Helper() hiddenAPIIndex := ctx.SingletonForTests("hiddenapi_index") indexRule := hiddenAPIIndex.Rule("singleton-merged-hiddenapi-index") java.CheckHiddenAPIRuleInputs(t, expectedInputs, indexRule) Loading @@ -4557,7 +4561,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { src: "myapex-arm.apex", }, }, exported_java_libs: ["libfoo"], exported_java_libs: ["libfoo", "libbar"], } java_import { Loading @@ -4565,13 +4569,23 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { jars: ["libfoo.jar"], apex_available: ["myapex"], } java_sdk_library_import { name: "libbar", public: { jars: ["libbar.jar"], }, apex_available: ["myapex"], } ` ctx := testDexpreoptWithApexes(t, bp, "", transform) checkBootDexJarPath(t, ctx, ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar") checkBootDexJarPath(t, ctx, "libfoo", ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar") checkBootDexJarPath(t, ctx, "libbar", ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libbar.jar") // Make sure that the dex file from the prebuilt_apex contributes to the hiddenapi index file. checkHiddenAPIIndexInputs(t, ctx, ` .intermediates/libbar/android_common_myapex/hiddenapi/index.csv .intermediates/libfoo/android_common_myapex/hiddenapi/index.csv `) }) Loading @@ -4588,7 +4602,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { src: "myapex-arm.apex", }, }, exported_java_libs: ["libfoo"], exported_java_libs: ["libfoo", "libbar"], } java_import { Loading @@ -4602,6 +4616,21 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { srcs: ["foo/bar/MyClass.java"], apex_available: ["myapex"], } java_sdk_library_import { name: "libbar", public: { jars: ["libbar.jar"], }, apex_available: ["myapex"], } java_sdk_library { name: "libbar", srcs: ["foo/bar/MyClass.java"], unsafe_ignore_missing_latest_api: true, apex_available: ["myapex"], } ` // In this test the source (java_library) libfoo is active since the Loading @@ -4624,7 +4653,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { src: "myapex-arm.apex", }, }, exported_java_libs: ["libfoo"], exported_java_libs: ["libfoo", "libbar"], } java_import { Loading @@ -4639,13 +4668,31 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { srcs: ["foo/bar/MyClass.java"], apex_available: ["myapex"], } java_sdk_library_import { name: "libbar", prefer: true, public: { jars: ["libbar.jar"], }, apex_available: ["myapex"], } java_sdk_library { name: "libbar", srcs: ["foo/bar/MyClass.java"], unsafe_ignore_missing_latest_api: true, apex_available: ["myapex"], } ` ctx := testDexpreoptWithApexes(t, bp, "", transform) checkBootDexJarPath(t, ctx, ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar") checkBootDexJarPath(t, ctx, "libfoo", ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar") checkBootDexJarPath(t, ctx, "libbar", ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libbar.jar") // Make sure that the dex file from the prebuilt_apex contributes to the hiddenapi index file. checkHiddenAPIIndexInputs(t, ctx, ` .intermediates/prebuilt_libbar/android_common_myapex/hiddenapi/index.csv .intermediates/prebuilt_libfoo/android_common_myapex/hiddenapi/index.csv `) }) Loading @@ -4655,7 +4702,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { apex { name: "myapex", key: "myapex.key", java_libs: ["libfoo"], java_libs: ["libfoo", "libbar"], } apex_key { Loading @@ -4674,7 +4721,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { src: "myapex-arm.apex", }, }, exported_java_libs: ["libfoo"], exported_java_libs: ["libfoo", "libbar"], } java_import { Loading @@ -4688,13 +4735,30 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { srcs: ["foo/bar/MyClass.java"], apex_available: ["myapex"], } java_sdk_library_import { name: "libbar", public: { jars: ["libbar.jar"], }, apex_available: ["myapex"], } java_sdk_library { name: "libbar", srcs: ["foo/bar/MyClass.java"], unsafe_ignore_missing_latest_api: true, apex_available: ["myapex"], } ` ctx := testDexpreoptWithApexes(t, bp, "", transform) checkBootDexJarPath(t, ctx, ".intermediates/libfoo/android_common_apex10000/hiddenapi/libfoo.jar") checkBootDexJarPath(t, ctx, "libfoo", ".intermediates/libfoo/android_common_apex10000/hiddenapi/libfoo.jar") checkBootDexJarPath(t, ctx, "libbar", ".intermediates/libbar/android_common_myapex/hiddenapi/libbar.jar") // Make sure that the dex file from the prebuilt_apex contributes to the hiddenapi index file. checkHiddenAPIIndexInputs(t, ctx, ` .intermediates/libbar/android_common_myapex/hiddenapi/index.csv .intermediates/libfoo/android_common_apex10000/hiddenapi/index.csv `) }) Loading Loading @@ -4724,7 +4788,7 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { src: "myapex-arm.apex", }, }, exported_java_libs: ["libfoo"], exported_java_libs: ["libfoo", "libbar"], } java_import { Loading @@ -4739,13 +4803,31 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { srcs: ["foo/bar/MyClass.java"], apex_available: ["myapex"], } java_sdk_library_import { name: "libbar", prefer: true, public: { jars: ["libbar.jar"], }, apex_available: ["myapex"], } java_sdk_library { name: "libbar", srcs: ["foo/bar/MyClass.java"], unsafe_ignore_missing_latest_api: true, apex_available: ["myapex"], } ` ctx := testDexpreoptWithApexes(t, bp, "", transform) checkBootDexJarPath(t, ctx, ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar") checkBootDexJarPath(t, ctx, "libfoo", ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libfoo.jar") checkBootDexJarPath(t, ctx, "libbar", ".intermediates/myapex.deapexer/android_common/deapexer/javalib/libbar.jar") // Make sure that the dex file from the prebuilt_apex contributes to the hiddenapi index file. checkHiddenAPIIndexInputs(t, ctx, ` .intermediates/prebuilt_libbar/android_common_prebuilt_myapex/hiddenapi/index.csv .intermediates/prebuilt_libfoo/android_common_prebuilt_myapex/hiddenapi/index.csv `) }) Loading Loading @@ -6374,6 +6456,7 @@ func testDexpreoptWithApexes(t *testing.T, bp, errmsg string, transformDexpreopt ctx.RegisterModuleType("prebuilt_apex", PrebuiltFactory) ctx.RegisterModuleType("filegroup", android.FileGroupFactory) ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators) ctx.PreArchMutators(android.RegisterComponentsMutator) android.RegisterPrebuiltMutators(ctx) cc.RegisterRequiredBuildComponentsForTest(ctx) java.RegisterRequiredBuildComponentsForTest(ctx) Loading
java/sdk_library.go +4 −0 Original line number Diff line number Diff line Loading @@ -1772,6 +1772,8 @@ type SdkLibraryImport struct { android.ApexModuleBase android.SdkBase hiddenAPI properties sdkLibraryImportProperties // Map from api scope to the scope specific property structure. Loading Loading @@ -2046,6 +2048,8 @@ func (module *SdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleCo di := ctx.OtherModuleProvider(deapexerModule, android.DeapexerProvider).(android.DeapexerInfo) if dexOutputPath := di.PrebuiltExportPath(module.BaseModuleName(), ".dexjar"); dexOutputPath != nil { module.dexJarFile = dexOutputPath module.initHiddenAPI(ctx, module.configurationName) module.hiddenAPIExtractInformation(ctx, dexOutputPath, module.findScopePaths(apiScopePublic).stubsImplPath[0]) } else { // This should never happen as a variant for a prebuilt_apex is only created if the // prebuilt_apex has been configured to export the java library dex file. Loading
java/testing.go +1 −0 Original line number Diff line number Diff line Loading @@ -240,6 +240,7 @@ func CheckModuleDependencies(t *testing.T, ctx *android.TestContext, name, varia } func CheckHiddenAPIRuleInputs(t *testing.T, expected string, hiddenAPIRule android.TestingBuildParams) { t.Helper() actual := strings.TrimSpace(strings.Join(android.NormalizePathsForTesting(hiddenAPIRule.Implicits), "\n")) expected = strings.TrimSpace(expected) if actual != expected { Loading