Loading dexpreopt/dexpreopt.go +4 −4 Original line number Diff line number Diff line Loading @@ -52,7 +52,7 @@ var DexpreoptRunningInSoong = false // GenerateDexpreoptRule generates a set of commands that will preopt a module based on a GlobalConfig and a // ModuleConfig. The produced files and their install locations will be available through rule.Installs(). func GenerateDexpreoptRule(ctx android.BuilderContext, globalSoong *GlobalSoongConfig, global *GlobalConfig, module *ModuleConfig, productPackages android.Path) ( global *GlobalConfig, module *ModuleConfig, productPackages android.Path, copyApexSystemServerJarDex bool) ( rule *android.RuleBuilder, err error) { defer func() { Loading Loading @@ -94,7 +94,7 @@ func GenerateDexpreoptRule(ctx android.BuilderContext, globalSoong *GlobalSoongC for archIdx, _ := range module.Archs { dexpreoptCommand(ctx, globalSoong, global, module, rule, archIdx, profile, appImage, generateDM, productPackages) generateDM, productPackages, copyApexSystemServerJarDex) } } } Loading Loading @@ -231,7 +231,7 @@ func ToOdexPath(path string, arch android.ArchType) string { func dexpreoptCommand(ctx android.BuilderContext, globalSoong *GlobalSoongConfig, global *GlobalConfig, module *ModuleConfig, rule *android.RuleBuilder, archIdx int, profile android.WritablePath, appImage bool, generateDM bool, productPackages android.Path) { profile android.WritablePath, appImage bool, generateDM bool, productPackages android.Path, copyApexSystemServerJarDex bool) { arch := module.Archs[archIdx] Loading Loading @@ -277,7 +277,7 @@ func dexpreoptCommand(ctx android.BuilderContext, globalSoong *GlobalSoongConfig clcTarget = append(clcTarget, GetSystemServerDexLocation(ctx, global, lib)) } if DexpreoptRunningInSoong { if DexpreoptRunningInSoong && copyApexSystemServerJarDex { // Copy the system server jar to a predefined location where dex2oat will find it. dexPathHost := SystemServerDexJarHostPath(ctx, module.Name) rule.Command().Text("mkdir -p").Flag(filepath.Dir(dexPathHost.String())) Loading dexpreopt/dexpreopt_gen/dexpreopt_gen.go +2 −1 Original line number Diff line number Diff line Loading @@ -205,8 +205,9 @@ func writeScripts(ctx android.BuilderContext, globalSoong *dexpreopt.GlobalSoong panic(err) } } cpApexSscpServerJar := false // dexpreopt_gen operates on make modules, and since sscp libraries are in soong, this should be a noop dexpreoptRule, err := dexpreopt.GenerateDexpreoptRule( ctx, globalSoong, global, module, android.PathForTesting(productPackagesPath)) ctx, globalSoong, global, module, android.PathForTesting(productPackagesPath), cpApexSscpServerJar) if err != nil { panic(err) } Loading dexpreopt/dexpreopt_test.go +24 −7 Original line number Diff line number Diff line Loading @@ -101,7 +101,7 @@ func TestDexPreopt(t *testing.T) { module := testSystemModuleConfig(ctx, "test") productPackages := android.PathForTesting("product_packages.txt") rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages) rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages, true) if err != nil { t.Fatal(err) } Loading Loading @@ -161,7 +161,7 @@ func TestDexPreoptSystemOther(t *testing.T) { for _, test := range tests { global.PatternsOnSystemOther = test.patterns for _, mt := range test.moduleTests { rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, mt.module, productPackages) rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, mt.module, productPackages, true) if err != nil { t.Fatal(err) } Loading @@ -181,6 +181,11 @@ func TestDexPreoptSystemOther(t *testing.T) { } func TestDexPreoptApexSystemServerJars(t *testing.T) { // modify the global variable for test var oldDexpreoptRunningInSoong = DexpreoptRunningInSoong DexpreoptRunningInSoong = true // test begin config := android.TestConfig("out", nil, "", nil) ctx := android.BuilderContextForTesting(config) globalSoong := globalSoongConfigForTests(ctx) Loading @@ -191,7 +196,7 @@ func TestDexPreoptApexSystemServerJars(t *testing.T) { global.ApexSystemServerJars = android.CreateTestConfiguredJarList( []string{"com.android.apex1:service-A"}) rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages) rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages, true) if err != nil { t.Fatal(err) } Loading @@ -202,6 +207,18 @@ func TestDexPreoptApexSystemServerJars(t *testing.T) { } android.AssertStringEquals(t, "installs", wantInstalls.String(), rule.Installs().String()) android.AssertStringListContains(t, "apex sscp jar copy", rule.Outputs().Strings(), "out/soong/system_server_dexjars/service-A.jar") // rule with apex sscp cp as false rule, err = GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages, false) if err != nil { t.Fatal(err) } android.AssertStringListDoesNotContain(t, "apex sscp jar copy", rule.Outputs().Strings(), "out/soong/system_server_dexjars/service-A.jar") // cleanup the global variable for test DexpreoptRunningInSoong = oldDexpreoptRunningInSoong } func TestDexPreoptStandaloneSystemServerJars(t *testing.T) { Loading @@ -215,7 +232,7 @@ func TestDexPreoptStandaloneSystemServerJars(t *testing.T) { global.StandaloneSystemServerJars = android.CreateTestConfiguredJarList( []string{"platform:service-A"}) rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages) rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages, true) if err != nil { t.Fatal(err) } Loading @@ -239,7 +256,7 @@ func TestDexPreoptSystemExtSystemServerJars(t *testing.T) { global.StandaloneSystemServerJars = android.CreateTestConfiguredJarList( []string{"system_ext:service-A"}) rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages) rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages, true) if err != nil { t.Fatal(err) } Loading @@ -263,7 +280,7 @@ func TestDexPreoptApexStandaloneSystemServerJars(t *testing.T) { global.ApexStandaloneSystemServerJars = android.CreateTestConfiguredJarList( []string{"com.android.apex1:service-A"}) rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages) rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages, true) if err != nil { t.Fatal(err) } Loading @@ -286,7 +303,7 @@ func TestDexPreoptProfile(t *testing.T) { module.ProfileClassListing = android.OptionalPathForPath(android.PathForTesting("profile")) rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages) rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages, true) if err != nil { t.Fatal(err) } Loading java/dexpreopt.go +5 −5 Original line number Diff line number Diff line Loading @@ -243,10 +243,6 @@ func (d *dexpreopter) dexpreoptDisabled(ctx android.BaseModuleContext, libName s return true } if disableSourceApexVariant(ctx) { return true } if _, isApex := android.ModuleProvider(ctx, android.ApexBundleInfoProvider); isApex { // dexpreopt rules for system server jars can be generated in the ModuleCtx of prebuilt apexes return false Loading Loading @@ -501,8 +497,12 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, libName string, dexJa Output(appProductPackages) productPackagesRule.Restat().Build("product_packages."+dexJarStem, "dexpreopt product_packages") // Prebuilts are active, do not copy the dexpreopt'd source javalib to out/soong/system_server_dexjars // The javalib from the deapexed prebuilt will be copied to this location. // TODO (b/331665856): Implement a principled solution for this. copyApexSystemServerJarDex := !disableSourceApexVariant(ctx) dexpreoptRule, err := dexpreopt.GenerateDexpreoptRule( ctx, globalSoong, global, dexpreoptConfig, appProductPackages) ctx, globalSoong, global, dexpreoptConfig, appProductPackages, copyApexSystemServerJarDex) if err != nil { ctx.ModuleErrorf("error generating dexpreopt rule: %s", err.Error()) return Loading java/java.go +6 −0 Original line number Diff line number Diff line Loading @@ -886,6 +886,12 @@ func init() { } func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) { if disableSourceApexVariant(ctx) { // Prebuilts are active, do not create the installation rules for the source javalib. // Even though the source javalib is not used, we need to hide it to prevent duplicate installation rules. // TODO (b/331665856): Implement a principled solution for this. j.HideFromMake() } j.provideHiddenAPIPropertyInfo(ctx) j.sdkVersion = j.SdkVersion(ctx) Loading Loading
dexpreopt/dexpreopt.go +4 −4 Original line number Diff line number Diff line Loading @@ -52,7 +52,7 @@ var DexpreoptRunningInSoong = false // GenerateDexpreoptRule generates a set of commands that will preopt a module based on a GlobalConfig and a // ModuleConfig. The produced files and their install locations will be available through rule.Installs(). func GenerateDexpreoptRule(ctx android.BuilderContext, globalSoong *GlobalSoongConfig, global *GlobalConfig, module *ModuleConfig, productPackages android.Path) ( global *GlobalConfig, module *ModuleConfig, productPackages android.Path, copyApexSystemServerJarDex bool) ( rule *android.RuleBuilder, err error) { defer func() { Loading Loading @@ -94,7 +94,7 @@ func GenerateDexpreoptRule(ctx android.BuilderContext, globalSoong *GlobalSoongC for archIdx, _ := range module.Archs { dexpreoptCommand(ctx, globalSoong, global, module, rule, archIdx, profile, appImage, generateDM, productPackages) generateDM, productPackages, copyApexSystemServerJarDex) } } } Loading Loading @@ -231,7 +231,7 @@ func ToOdexPath(path string, arch android.ArchType) string { func dexpreoptCommand(ctx android.BuilderContext, globalSoong *GlobalSoongConfig, global *GlobalConfig, module *ModuleConfig, rule *android.RuleBuilder, archIdx int, profile android.WritablePath, appImage bool, generateDM bool, productPackages android.Path) { profile android.WritablePath, appImage bool, generateDM bool, productPackages android.Path, copyApexSystemServerJarDex bool) { arch := module.Archs[archIdx] Loading Loading @@ -277,7 +277,7 @@ func dexpreoptCommand(ctx android.BuilderContext, globalSoong *GlobalSoongConfig clcTarget = append(clcTarget, GetSystemServerDexLocation(ctx, global, lib)) } if DexpreoptRunningInSoong { if DexpreoptRunningInSoong && copyApexSystemServerJarDex { // Copy the system server jar to a predefined location where dex2oat will find it. dexPathHost := SystemServerDexJarHostPath(ctx, module.Name) rule.Command().Text("mkdir -p").Flag(filepath.Dir(dexPathHost.String())) Loading
dexpreopt/dexpreopt_gen/dexpreopt_gen.go +2 −1 Original line number Diff line number Diff line Loading @@ -205,8 +205,9 @@ func writeScripts(ctx android.BuilderContext, globalSoong *dexpreopt.GlobalSoong panic(err) } } cpApexSscpServerJar := false // dexpreopt_gen operates on make modules, and since sscp libraries are in soong, this should be a noop dexpreoptRule, err := dexpreopt.GenerateDexpreoptRule( ctx, globalSoong, global, module, android.PathForTesting(productPackagesPath)) ctx, globalSoong, global, module, android.PathForTesting(productPackagesPath), cpApexSscpServerJar) if err != nil { panic(err) } Loading
dexpreopt/dexpreopt_test.go +24 −7 Original line number Diff line number Diff line Loading @@ -101,7 +101,7 @@ func TestDexPreopt(t *testing.T) { module := testSystemModuleConfig(ctx, "test") productPackages := android.PathForTesting("product_packages.txt") rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages) rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages, true) if err != nil { t.Fatal(err) } Loading Loading @@ -161,7 +161,7 @@ func TestDexPreoptSystemOther(t *testing.T) { for _, test := range tests { global.PatternsOnSystemOther = test.patterns for _, mt := range test.moduleTests { rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, mt.module, productPackages) rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, mt.module, productPackages, true) if err != nil { t.Fatal(err) } Loading @@ -181,6 +181,11 @@ func TestDexPreoptSystemOther(t *testing.T) { } func TestDexPreoptApexSystemServerJars(t *testing.T) { // modify the global variable for test var oldDexpreoptRunningInSoong = DexpreoptRunningInSoong DexpreoptRunningInSoong = true // test begin config := android.TestConfig("out", nil, "", nil) ctx := android.BuilderContextForTesting(config) globalSoong := globalSoongConfigForTests(ctx) Loading @@ -191,7 +196,7 @@ func TestDexPreoptApexSystemServerJars(t *testing.T) { global.ApexSystemServerJars = android.CreateTestConfiguredJarList( []string{"com.android.apex1:service-A"}) rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages) rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages, true) if err != nil { t.Fatal(err) } Loading @@ -202,6 +207,18 @@ func TestDexPreoptApexSystemServerJars(t *testing.T) { } android.AssertStringEquals(t, "installs", wantInstalls.String(), rule.Installs().String()) android.AssertStringListContains(t, "apex sscp jar copy", rule.Outputs().Strings(), "out/soong/system_server_dexjars/service-A.jar") // rule with apex sscp cp as false rule, err = GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages, false) if err != nil { t.Fatal(err) } android.AssertStringListDoesNotContain(t, "apex sscp jar copy", rule.Outputs().Strings(), "out/soong/system_server_dexjars/service-A.jar") // cleanup the global variable for test DexpreoptRunningInSoong = oldDexpreoptRunningInSoong } func TestDexPreoptStandaloneSystemServerJars(t *testing.T) { Loading @@ -215,7 +232,7 @@ func TestDexPreoptStandaloneSystemServerJars(t *testing.T) { global.StandaloneSystemServerJars = android.CreateTestConfiguredJarList( []string{"platform:service-A"}) rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages) rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages, true) if err != nil { t.Fatal(err) } Loading @@ -239,7 +256,7 @@ func TestDexPreoptSystemExtSystemServerJars(t *testing.T) { global.StandaloneSystemServerJars = android.CreateTestConfiguredJarList( []string{"system_ext:service-A"}) rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages) rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages, true) if err != nil { t.Fatal(err) } Loading @@ -263,7 +280,7 @@ func TestDexPreoptApexStandaloneSystemServerJars(t *testing.T) { global.ApexStandaloneSystemServerJars = android.CreateTestConfiguredJarList( []string{"com.android.apex1:service-A"}) rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages) rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages, true) if err != nil { t.Fatal(err) } Loading @@ -286,7 +303,7 @@ func TestDexPreoptProfile(t *testing.T) { module.ProfileClassListing = android.OptionalPathForPath(android.PathForTesting("profile")) rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages) rule, err := GenerateDexpreoptRule(ctx, globalSoong, global, module, productPackages, true) if err != nil { t.Fatal(err) } Loading
java/dexpreopt.go +5 −5 Original line number Diff line number Diff line Loading @@ -243,10 +243,6 @@ func (d *dexpreopter) dexpreoptDisabled(ctx android.BaseModuleContext, libName s return true } if disableSourceApexVariant(ctx) { return true } if _, isApex := android.ModuleProvider(ctx, android.ApexBundleInfoProvider); isApex { // dexpreopt rules for system server jars can be generated in the ModuleCtx of prebuilt apexes return false Loading Loading @@ -501,8 +497,12 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, libName string, dexJa Output(appProductPackages) productPackagesRule.Restat().Build("product_packages."+dexJarStem, "dexpreopt product_packages") // Prebuilts are active, do not copy the dexpreopt'd source javalib to out/soong/system_server_dexjars // The javalib from the deapexed prebuilt will be copied to this location. // TODO (b/331665856): Implement a principled solution for this. copyApexSystemServerJarDex := !disableSourceApexVariant(ctx) dexpreoptRule, err := dexpreopt.GenerateDexpreoptRule( ctx, globalSoong, global, dexpreoptConfig, appProductPackages) ctx, globalSoong, global, dexpreoptConfig, appProductPackages, copyApexSystemServerJarDex) if err != nil { ctx.ModuleErrorf("error generating dexpreopt rule: %s", err.Error()) return Loading
java/java.go +6 −0 Original line number Diff line number Diff line Loading @@ -886,6 +886,12 @@ func init() { } func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) { if disableSourceApexVariant(ctx) { // Prebuilts are active, do not create the installation rules for the source javalib. // Even though the source javalib is not used, we need to hide it to prevent duplicate installation rules. // TODO (b/331665856): Implement a principled solution for this. j.HideFromMake() } j.provideHiddenAPIPropertyInfo(ctx) j.sdkVersion = j.SdkVersion(ctx) Loading