Loading apex/apex.go +15 −0 Original line number Diff line number Diff line Loading @@ -1771,6 +1771,18 @@ func apexFileForJavaModuleWithFile(ctx android.BaseModuleContext, module javaMod return af } func apexFileForJavaModuleProfile(ctx android.BaseModuleContext, module javaModule) *apexFile { if dexpreopter, ok := module.(java.DexpreopterInterface); ok { if profilePathOnHost := dexpreopter.ProfilePathOnHost(); profilePathOnHost != nil { dirInApex := "javalib" af := newApexFile(ctx, profilePathOnHost, module.BaseModuleName()+"-profile", dirInApex, etc, nil) af.customStem = module.Stem() + ".jar.prof" return &af } } return nil } // androidApp is an interface to handle all app modules (android_app, android_app_import, etc.) in // the same way. type androidApp interface { Loading Loading @@ -2465,6 +2477,9 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, case *java.Library, *java.SdkLibrary: af := apexFileForJavaModule(ctx, child.(javaModule)) vctx.filesInfo = append(vctx.filesInfo, af) if profileAf := apexFileForJavaModuleProfile(ctx, child.(javaModule)); profileAf != nil { vctx.filesInfo = append(vctx.filesInfo, *profileAf) } return true // track transitive dependencies default: ctx.PropertyErrorf("systemserverclasspath_fragments", Loading apex/systemserver_classpath_fragment_test.go +32 −2 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ func TestSystemserverclasspathFragmentContents(t *testing.T) { result := android.GroupFixturePreparers( prepareForTestWithSystemserverclasspathFragment, prepareForTestWithMyapex, dexpreopt.FixtureSetApexSystemServerJars("myapex:foo"), dexpreopt.FixtureSetApexSystemServerJars("myapex:foo", "myapex:bar"), ).RunTestWithBp(t, ` apex { name: "myapex", Loading @@ -57,10 +57,23 @@ func TestSystemserverclasspathFragmentContents(t *testing.T) { ], } java_library { name: "bar", srcs: ["c.java"], installable: true, dex_preopt: { profile: "bar-art-profile", }, apex_available: [ "myapex", ], } systemserverclasspath_fragment { name: "mysystemserverclasspathfragment", contents: [ "foo", "bar", ], apex_available: [ "myapex", Loading @@ -71,6 +84,8 @@ func TestSystemserverclasspathFragmentContents(t *testing.T) { ensureExactContents(t, result.TestContext, "myapex", "android_common_myapex_image", []string{ "etc/classpaths/systemserverclasspath.pb", "javalib/foo.jar", "javalib/bar.jar", "javalib/bar.jar.prof", }) java.CheckModuleDependencies(t, result.TestContext, "myapex", "android_common_myapex_image", []string{ Loading Loading @@ -236,7 +251,7 @@ func TestSystemserverclasspathFragmentStandaloneContents(t *testing.T) { result := android.GroupFixturePreparers( prepareForTestWithSystemserverclasspathFragment, prepareForTestWithMyapex, dexpreopt.FixtureSetApexStandaloneSystemServerJars("myapex:foo"), dexpreopt.FixtureSetApexStandaloneSystemServerJars("myapex:foo", "myapex:bar"), ).RunTestWithBp(t, ` apex { name: "myapex", Loading @@ -262,10 +277,23 @@ func TestSystemserverclasspathFragmentStandaloneContents(t *testing.T) { ], } java_library { name: "bar", srcs: ["c.java"], dex_preopt: { profile: "bar-art-profile", }, installable: true, apex_available: [ "myapex", ], } systemserverclasspath_fragment { name: "mysystemserverclasspathfragment", standalone_contents: [ "foo", "bar", ], apex_available: [ "myapex", Loading @@ -276,6 +304,8 @@ func TestSystemserverclasspathFragmentStandaloneContents(t *testing.T) { ensureExactContents(t, result.TestContext, "myapex", "android_common_myapex_image", []string{ "etc/classpaths/systemserverclasspath.pb", "javalib/foo.jar", "javalib/bar.jar", "javalib/bar.jar.prof", }) } Loading dexpreopt/dexpreopt.go +4 −0 Original line number Diff line number Diff line Loading @@ -101,6 +101,10 @@ func GenerateDexpreoptRule(ctx android.BuilderContext, globalSoong *GlobalSoongC } func dexpreoptDisabled(ctx android.PathContext, global *GlobalConfig, module *ModuleConfig) bool { if ctx.Config().UnbundledBuild() { return true } if contains(global.DisablePreoptModules, module.Name) { return true } Loading java/dexpreopt.go +31 −16 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ type DexpreopterInterface interface { dexpreoptDisabled(ctx android.BaseModuleContext) bool DexpreoptBuiltInstalledForApex() []dexpreopterInstall AndroidMkEntriesForApex() []android.AndroidMkEntries ProfilePathOnHost() android.Path } type dexpreopterInstall struct { Loading Loading @@ -103,6 +104,9 @@ type dexpreopter struct { // - Dexpreopt post-processing (using dexpreopt artifacts from a prebuilt system image to incrementally // dexpreopt another partition). configPath android.WritablePath // The path to the profile on host. profilePathOnHost android.Path } type DexpreoptProperties struct { Loading Loading @@ -180,9 +184,8 @@ func (d *dexpreopter) dexpreoptDisabled(ctx android.BaseModuleContext) bool { isApexSystemServerJar := global.AllApexSystemServerJars(ctx).ContainsJar(moduleName(ctx)) if isApexVariant(ctx) { // Don't preopt APEX variant module unless the module is an APEX system server jar and we are // building the entire system image. if !isApexSystemServerJar || ctx.Config().UnbundledBuild() { // Don't preopt APEX variant module unless the module is an APEX system server jar. if !isApexSystemServerJar { return true } } else { Loading Loading @@ -368,8 +371,15 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Wr installBase := filepath.Base(install.To) arch := filepath.Base(installDir) installPath := android.PathForModuleInPartitionInstall(ctx, "", installDir) isProfile := strings.HasSuffix(installBase, ".prof") if isProfile { d.profilePathOnHost = install.From } if isApexSystemServerJar { // Profiles are handled separately because they are installed into the APEX. if !isProfile { // APEX variants of java libraries are hidden from Make, so their dexpreopt // outputs need special handling. Currently, for APEX variants of java // libraries, only those in the system server classpath are handled here. Loading @@ -383,6 +393,7 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Wr installDirOnDevice: installPath, installFileOnDevice: installBase, }) } } else if !d.preventInstall { ctx.InstallFile(installPath, installBase, install.From) } Loading @@ -404,3 +415,7 @@ func (d *dexpreopter) AndroidMkEntriesForApex() []android.AndroidMkEntries { } return entries } func (d *dexpreopter) ProfilePathOnHost() android.Path { return d.profilePathOnHost } Loading
apex/apex.go +15 −0 Original line number Diff line number Diff line Loading @@ -1771,6 +1771,18 @@ func apexFileForJavaModuleWithFile(ctx android.BaseModuleContext, module javaMod return af } func apexFileForJavaModuleProfile(ctx android.BaseModuleContext, module javaModule) *apexFile { if dexpreopter, ok := module.(java.DexpreopterInterface); ok { if profilePathOnHost := dexpreopter.ProfilePathOnHost(); profilePathOnHost != nil { dirInApex := "javalib" af := newApexFile(ctx, profilePathOnHost, module.BaseModuleName()+"-profile", dirInApex, etc, nil) af.customStem = module.Stem() + ".jar.prof" return &af } } return nil } // androidApp is an interface to handle all app modules (android_app, android_app_import, etc.) in // the same way. type androidApp interface { Loading Loading @@ -2465,6 +2477,9 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, case *java.Library, *java.SdkLibrary: af := apexFileForJavaModule(ctx, child.(javaModule)) vctx.filesInfo = append(vctx.filesInfo, af) if profileAf := apexFileForJavaModuleProfile(ctx, child.(javaModule)); profileAf != nil { vctx.filesInfo = append(vctx.filesInfo, *profileAf) } return true // track transitive dependencies default: ctx.PropertyErrorf("systemserverclasspath_fragments", Loading
apex/systemserver_classpath_fragment_test.go +32 −2 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ func TestSystemserverclasspathFragmentContents(t *testing.T) { result := android.GroupFixturePreparers( prepareForTestWithSystemserverclasspathFragment, prepareForTestWithMyapex, dexpreopt.FixtureSetApexSystemServerJars("myapex:foo"), dexpreopt.FixtureSetApexSystemServerJars("myapex:foo", "myapex:bar"), ).RunTestWithBp(t, ` apex { name: "myapex", Loading @@ -57,10 +57,23 @@ func TestSystemserverclasspathFragmentContents(t *testing.T) { ], } java_library { name: "bar", srcs: ["c.java"], installable: true, dex_preopt: { profile: "bar-art-profile", }, apex_available: [ "myapex", ], } systemserverclasspath_fragment { name: "mysystemserverclasspathfragment", contents: [ "foo", "bar", ], apex_available: [ "myapex", Loading @@ -71,6 +84,8 @@ func TestSystemserverclasspathFragmentContents(t *testing.T) { ensureExactContents(t, result.TestContext, "myapex", "android_common_myapex_image", []string{ "etc/classpaths/systemserverclasspath.pb", "javalib/foo.jar", "javalib/bar.jar", "javalib/bar.jar.prof", }) java.CheckModuleDependencies(t, result.TestContext, "myapex", "android_common_myapex_image", []string{ Loading Loading @@ -236,7 +251,7 @@ func TestSystemserverclasspathFragmentStandaloneContents(t *testing.T) { result := android.GroupFixturePreparers( prepareForTestWithSystemserverclasspathFragment, prepareForTestWithMyapex, dexpreopt.FixtureSetApexStandaloneSystemServerJars("myapex:foo"), dexpreopt.FixtureSetApexStandaloneSystemServerJars("myapex:foo", "myapex:bar"), ).RunTestWithBp(t, ` apex { name: "myapex", Loading @@ -262,10 +277,23 @@ func TestSystemserverclasspathFragmentStandaloneContents(t *testing.T) { ], } java_library { name: "bar", srcs: ["c.java"], dex_preopt: { profile: "bar-art-profile", }, installable: true, apex_available: [ "myapex", ], } systemserverclasspath_fragment { name: "mysystemserverclasspathfragment", standalone_contents: [ "foo", "bar", ], apex_available: [ "myapex", Loading @@ -276,6 +304,8 @@ func TestSystemserverclasspathFragmentStandaloneContents(t *testing.T) { ensureExactContents(t, result.TestContext, "myapex", "android_common_myapex_image", []string{ "etc/classpaths/systemserverclasspath.pb", "javalib/foo.jar", "javalib/bar.jar", "javalib/bar.jar.prof", }) } Loading
dexpreopt/dexpreopt.go +4 −0 Original line number Diff line number Diff line Loading @@ -101,6 +101,10 @@ func GenerateDexpreoptRule(ctx android.BuilderContext, globalSoong *GlobalSoongC } func dexpreoptDisabled(ctx android.PathContext, global *GlobalConfig, module *ModuleConfig) bool { if ctx.Config().UnbundledBuild() { return true } if contains(global.DisablePreoptModules, module.Name) { return true } Loading
java/dexpreopt.go +31 −16 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ type DexpreopterInterface interface { dexpreoptDisabled(ctx android.BaseModuleContext) bool DexpreoptBuiltInstalledForApex() []dexpreopterInstall AndroidMkEntriesForApex() []android.AndroidMkEntries ProfilePathOnHost() android.Path } type dexpreopterInstall struct { Loading Loading @@ -103,6 +104,9 @@ type dexpreopter struct { // - Dexpreopt post-processing (using dexpreopt artifacts from a prebuilt system image to incrementally // dexpreopt another partition). configPath android.WritablePath // The path to the profile on host. profilePathOnHost android.Path } type DexpreoptProperties struct { Loading Loading @@ -180,9 +184,8 @@ func (d *dexpreopter) dexpreoptDisabled(ctx android.BaseModuleContext) bool { isApexSystemServerJar := global.AllApexSystemServerJars(ctx).ContainsJar(moduleName(ctx)) if isApexVariant(ctx) { // Don't preopt APEX variant module unless the module is an APEX system server jar and we are // building the entire system image. if !isApexSystemServerJar || ctx.Config().UnbundledBuild() { // Don't preopt APEX variant module unless the module is an APEX system server jar. if !isApexSystemServerJar { return true } } else { Loading Loading @@ -368,8 +371,15 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Wr installBase := filepath.Base(install.To) arch := filepath.Base(installDir) installPath := android.PathForModuleInPartitionInstall(ctx, "", installDir) isProfile := strings.HasSuffix(installBase, ".prof") if isProfile { d.profilePathOnHost = install.From } if isApexSystemServerJar { // Profiles are handled separately because they are installed into the APEX. if !isProfile { // APEX variants of java libraries are hidden from Make, so their dexpreopt // outputs need special handling. Currently, for APEX variants of java // libraries, only those in the system server classpath are handled here. Loading @@ -383,6 +393,7 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Wr installDirOnDevice: installPath, installFileOnDevice: installBase, }) } } else if !d.preventInstall { ctx.InstallFile(installPath, installBase, install.From) } Loading @@ -404,3 +415,7 @@ func (d *dexpreopter) AndroidMkEntriesForApex() []android.AndroidMkEntries { } return entries } func (d *dexpreopter) ProfilePathOnHost() android.Path { return d.profilePathOnHost }