Loading apex/apex_test.go +43 −0 Original line number Diff line number Diff line Loading @@ -5281,7 +5281,16 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { apex_set { name: "myapex", set: "myapex.apks", exported_java_libs: ["myjavalib"], exported_bootclasspath_fragments: ["my-bootclasspath-fragment"], exported_systemserverclasspath_fragments: ["my-systemserverclasspath-fragment"], } java_import { name: "myjavalib", jars: ["myjavalib.jar"], apex_available: ["myapex"], permitted_packages: ["javalib"], } prebuilt_bootclasspath_fragment { Loading @@ -5298,6 +5307,12 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { }, } prebuilt_systemserverclasspath_fragment { name: "my-systemserverclasspath-fragment", contents: ["libbaz"], apex_available: ["myapex"], } java_import { name: "libfoo", jars: ["libfoo.jar"], Loading @@ -5314,6 +5329,16 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { shared_library: false, permitted_packages: ["bar"], } java_sdk_library_import { name: "libbaz", public: { jars: ["libbaz.jar"], }, apex_available: ["myapex"], shared_library: false, permitted_packages: ["baz"], } ` ctx := testDexpreoptWithApexes(t, bp, "", preparer, fragment) Loading @@ -5326,6 +5351,24 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { my-bootclasspath-fragment/index.csv out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv `) myApex := ctx.ModuleForTests("myapex", "android_common_myapex").Module() overrideNames := []string{ "", "myjavalib.myapex", "libfoo.myapex", "libbar.myapex", "libbaz.myapex", } mkEntries := android.AndroidMkEntriesForTest(t, ctx, myApex) for i, e := range mkEntries { g := e.OverrideName if w := overrideNames[i]; w != g { t.Errorf("Expected override name %q, got %q", w, g) } } }) t.Run("prebuilt with source library preferred", func(t *testing.T) { Loading apex/prebuilt.go +15 −17 Original line number Diff line number Diff line Loading @@ -316,31 +316,29 @@ func prebuiltApexModuleCreatorMutator(ctx android.TopDownMutatorContext) { } } func (p *prebuiltCommon) getExportedDependencies() map[string]exportedDependencyTag { dependencies := make(map[string]exportedDependencyTag) func (p *prebuiltCommon) hasExportedDeps() bool { return len(p.prebuiltCommonProperties.Exported_java_libs) > 0 || len(p.prebuiltCommonProperties.Exported_bootclasspath_fragments) > 0 || len(p.prebuiltCommonProperties.Exported_systemserverclasspath_fragments) > 0 } // prebuiltApexContentsDeps adds dependencies onto the prebuilt apex module's contents. func (p *prebuiltCommon) prebuiltApexContentsDeps(ctx android.BottomUpMutatorContext) { module := ctx.Module() for _, dep := range p.prebuiltCommonProperties.Exported_java_libs { dependencies[dep] = exportedJavaLibTag prebuiltDep := android.PrebuiltNameFromSource(dep) ctx.AddDependency(module, exportedJavaLibTag, prebuiltDep) } for _, dep := range p.prebuiltCommonProperties.Exported_bootclasspath_fragments { dependencies[dep] = exportedBootclasspathFragmentTag prebuiltDep := android.PrebuiltNameFromSource(dep) ctx.AddDependency(module, exportedBootclasspathFragmentTag, prebuiltDep) } for _, dep := range p.prebuiltCommonProperties.Exported_systemserverclasspath_fragments { dependencies[dep] = exportedSystemserverclasspathFragmentTag } return dependencies } // prebuiltApexContentsDeps adds dependencies onto the prebuilt apex module's contents. func (p *prebuiltCommon) prebuiltApexContentsDeps(ctx android.BottomUpMutatorContext) { module := ctx.Module() for dep, tag := range p.getExportedDependencies() { prebuiltDep := android.PrebuiltNameFromSource(dep) ctx.AddDependency(module, tag, prebuiltDep) ctx.AddDependency(module, exportedSystemserverclasspathFragmentTag, prebuiltDep) } } Loading Loading @@ -608,7 +606,7 @@ func createApexSelectorModule(ctx android.TopDownMutatorContext, name string, ap // the listed modules need access to files from within the prebuilt .apex file. func (p *prebuiltCommon) createDeapexerModuleIfNeeded(ctx android.TopDownMutatorContext, deapexerName string, apexFileSource string) { // Only create the deapexer module if it is needed. if len(p.getExportedDependencies()) == 0 { if !p.hasExportedDeps() { return } Loading Loading
apex/apex_test.go +43 −0 Original line number Diff line number Diff line Loading @@ -5281,7 +5281,16 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { apex_set { name: "myapex", set: "myapex.apks", exported_java_libs: ["myjavalib"], exported_bootclasspath_fragments: ["my-bootclasspath-fragment"], exported_systemserverclasspath_fragments: ["my-systemserverclasspath-fragment"], } java_import { name: "myjavalib", jars: ["myjavalib.jar"], apex_available: ["myapex"], permitted_packages: ["javalib"], } prebuilt_bootclasspath_fragment { Loading @@ -5298,6 +5307,12 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { }, } prebuilt_systemserverclasspath_fragment { name: "my-systemserverclasspath-fragment", contents: ["libbaz"], apex_available: ["myapex"], } java_import { name: "libfoo", jars: ["libfoo.jar"], Loading @@ -5314,6 +5329,16 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { shared_library: false, permitted_packages: ["bar"], } java_sdk_library_import { name: "libbaz", public: { jars: ["libbaz.jar"], }, apex_available: ["myapex"], shared_library: false, permitted_packages: ["baz"], } ` ctx := testDexpreoptWithApexes(t, bp, "", preparer, fragment) Loading @@ -5326,6 +5351,24 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { my-bootclasspath-fragment/index.csv out/soong/.intermediates/frameworks/base/boot/platform-bootclasspath/android_common/hiddenapi-monolithic/index-from-classes.csv `) myApex := ctx.ModuleForTests("myapex", "android_common_myapex").Module() overrideNames := []string{ "", "myjavalib.myapex", "libfoo.myapex", "libbar.myapex", "libbaz.myapex", } mkEntries := android.AndroidMkEntriesForTest(t, ctx, myApex) for i, e := range mkEntries { g := e.OverrideName if w := overrideNames[i]; w != g { t.Errorf("Expected override name %q, got %q", w, g) } } }) t.Run("prebuilt with source library preferred", func(t *testing.T) { Loading
apex/prebuilt.go +15 −17 Original line number Diff line number Diff line Loading @@ -316,31 +316,29 @@ func prebuiltApexModuleCreatorMutator(ctx android.TopDownMutatorContext) { } } func (p *prebuiltCommon) getExportedDependencies() map[string]exportedDependencyTag { dependencies := make(map[string]exportedDependencyTag) func (p *prebuiltCommon) hasExportedDeps() bool { return len(p.prebuiltCommonProperties.Exported_java_libs) > 0 || len(p.prebuiltCommonProperties.Exported_bootclasspath_fragments) > 0 || len(p.prebuiltCommonProperties.Exported_systemserverclasspath_fragments) > 0 } // prebuiltApexContentsDeps adds dependencies onto the prebuilt apex module's contents. func (p *prebuiltCommon) prebuiltApexContentsDeps(ctx android.BottomUpMutatorContext) { module := ctx.Module() for _, dep := range p.prebuiltCommonProperties.Exported_java_libs { dependencies[dep] = exportedJavaLibTag prebuiltDep := android.PrebuiltNameFromSource(dep) ctx.AddDependency(module, exportedJavaLibTag, prebuiltDep) } for _, dep := range p.prebuiltCommonProperties.Exported_bootclasspath_fragments { dependencies[dep] = exportedBootclasspathFragmentTag prebuiltDep := android.PrebuiltNameFromSource(dep) ctx.AddDependency(module, exportedBootclasspathFragmentTag, prebuiltDep) } for _, dep := range p.prebuiltCommonProperties.Exported_systemserverclasspath_fragments { dependencies[dep] = exportedSystemserverclasspathFragmentTag } return dependencies } // prebuiltApexContentsDeps adds dependencies onto the prebuilt apex module's contents. func (p *prebuiltCommon) prebuiltApexContentsDeps(ctx android.BottomUpMutatorContext) { module := ctx.Module() for dep, tag := range p.getExportedDependencies() { prebuiltDep := android.PrebuiltNameFromSource(dep) ctx.AddDependency(module, tag, prebuiltDep) ctx.AddDependency(module, exportedSystemserverclasspathFragmentTag, prebuiltDep) } } Loading Loading @@ -608,7 +606,7 @@ func createApexSelectorModule(ctx android.TopDownMutatorContext, name string, ap // the listed modules need access to files from within the prebuilt .apex file. func (p *prebuiltCommon) createDeapexerModuleIfNeeded(ctx android.TopDownMutatorContext, deapexerName string, apexFileSource string) { // Only create the deapexer module if it is needed. if len(p.getExportedDependencies()) == 0 { if !p.hasExportedDeps() { return } Loading