diff options
Diffstat (limited to 'java')
| -rw-r--r-- | java/dexpreopt.go | 38 | ||||
| -rw-r--r-- | java/dexpreopt_bootjars.go | 74 | ||||
| -rw-r--r-- | java/hiddenapi.go | 13 | ||||
| -rw-r--r-- | java/hiddenapi_singleton.go | 50 | ||||
| -rw-r--r-- | java/testing.go | 4 |
5 files changed, 91 insertions, 88 deletions
diff --git a/java/dexpreopt.go b/java/dexpreopt.go index b53e9c47..0a565297 100644 --- a/java/dexpreopt.go +++ b/java/dexpreopt.go @@ -86,28 +86,18 @@ func (d *dexpreopter) dexpreoptDisabled(ctx android.ModuleContext) bool { } var dexpreoptGlobalConfigKey = android.NewOnceKey("DexpreoptGlobalConfig") -var dexpreoptTestGlobalConfigKey = android.NewOnceKey("TestDexpreoptGlobalConfig") - -func setDexpreoptGlobalConfig(config android.Config, globalConfig dexpreopt.GlobalConfig) { - config.Once(dexpreoptTestGlobalConfigKey, func() interface{} { return globalConfig }) -} func dexpreoptGlobalConfig(ctx android.PathContext) dexpreopt.GlobalConfig { return ctx.Config().Once(dexpreoptGlobalConfigKey, func() interface{} { if f := ctx.Config().DexpreoptGlobalConfig(); f != "" { ctx.AddNinjaFileDeps(f) - globalConfig, err := dexpreopt.LoadGlobalConfig(ctx, f) + globalConfig, err := dexpreopt.LoadGlobalConfig(f) if err != nil { panic(err) } return globalConfig } - - // No global config filename set, see if there is a test config set - return ctx.Config().Once(dexpreoptTestGlobalConfigKey, func() interface{} { - // Nope, return an empty config - return dexpreopt.GlobalConfig{} - }) + return dexpreopt.GlobalConfig{} }).(dexpreopt.GlobalConfig) } @@ -141,15 +131,17 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Mo archs = archs[:1] } - var images android.Paths + var images []string for _, arch := range archs { - images = append(images, info.images[arch]) + images = append(images, info.images[arch].String()) } dexLocation := android.InstallPathToOnDevicePath(ctx, d.installPath) strippedDexJarFile := android.PathForModuleOut(ctx, "dexpreopt", dexJarFile.Base()) + deps := android.Paths{dexJarFile} + var profileClassListing android.OptionalPath profileIsTextListing := false if BoolDefault(d.dexpreoptProperties.Dex_preopt.Profile_guided, true) { @@ -165,16 +157,20 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Mo } } + if profileClassListing.Valid() { + deps = append(deps, profileClassListing.Path()) + } + dexpreoptConfig := dexpreopt.ModuleConfig{ Name: ctx.ModuleName(), DexLocation: dexLocation, - BuildPath: android.PathForModuleOut(ctx, "dexpreopt", ctx.ModuleName()+".jar").OutputPath, - DexPath: dexJarFile, + BuildPath: android.PathForModuleOut(ctx, "dexpreopt", ctx.ModuleName()+".jar").String(), + DexPath: dexJarFile.String(), UncompressedDex: d.uncompressedDex, HasApkLibraries: false, PreoptFlags: nil, - ProfileClassListing: profileClassListing, + ProfileClassListing: profileClassListing.String(), ProfileIsTextListing: profileIsTextListing, EnforceUsesLibraries: false, @@ -185,7 +181,7 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Mo Archs: archs, DexPreoptImages: images, - PreoptBootClassPathDexFiles: info.preoptBootDex.Paths(), + PreoptBootClassPathDexFiles: info.preoptBootDex.Strings(), PreoptBootClassPathDexLocations: info.preoptBootLocations, PreoptExtractedApk: false, @@ -194,11 +190,11 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Mo ForceCreateAppImage: BoolDefault(d.dexpreoptProperties.Dex_preopt.App_image, false), NoStripping: Bool(d.dexpreoptProperties.Dex_preopt.No_stripping), - StripInputPath: dexJarFile, - StripOutputPath: strippedDexJarFile.OutputPath, + StripInputPath: dexJarFile.String(), + StripOutputPath: strippedDexJarFile.String(), } - dexpreoptRule, err := dexpreopt.GenerateDexpreoptRule(ctx, info.global, dexpreoptConfig) + dexpreoptRule, err := dexpreopt.GenerateDexpreoptRule(info.global, dexpreoptConfig) if err != nil { ctx.ModuleErrorf("error generating dexpreopt rule: %s", err.Error()) return dexJarFile diff --git a/java/dexpreopt_bootjars.go b/java/dexpreopt_bootjars.go index bb88d32b..88534283 100644 --- a/java/dexpreopt_bootjars.go +++ b/java/dexpreopt_bootjars.go @@ -259,7 +259,7 @@ func dexPreoptBootImageRule(ctx android.SingletonContext, info *bootJarsInfo, symbolsFile := symbolsDir.Join(ctx, "boot.oat") outputDir := info.dir.Join(ctx, "system/framework", arch.String()) outputPath := info.images[arch] - oatLocation := pathtools.ReplaceExtension(dexpreopt.PathToLocation(outputPath, arch), "oat") + oatLocation := pathtools.ReplaceExtension(dexpreopt.PathToLocation(outputPath.String(), arch), "oat") rule := android.NewRuleBuilder() rule.MissingDeps(missingDeps) @@ -289,31 +289,31 @@ func dexPreoptBootImageRule(ctx android.SingletonContext, info *bootJarsInfo, cmd.Tool(info.global.Tools.Dex2oat). Flag("--avoid-storing-invocation"). - FlagWithOutput("--write-invocation-to=", invocationPath).ImplicitOutput(invocationPath). + FlagWithOutput("--write-invocation-to=", invocationPath.String()).ImplicitOutput(invocationPath.String()). Flag("--runtime-arg").FlagWithArg("-Xms", info.global.Dex2oatImageXms). Flag("--runtime-arg").FlagWithArg("-Xmx", info.global.Dex2oatImageXmx) - if profile != nil { + if profile == nil { + cmd.FlagWithArg("--image-classes=", info.global.PreloadedClasses) + } else { cmd.FlagWithArg("--compiler-filter=", "speed-profile") - cmd.FlagWithInput("--profile-file=", profile) - } else if info.global.PreloadedClasses.Valid() { - cmd.FlagWithInput("--image-classes=", info.global.PreloadedClasses.Path()) + cmd.FlagWithInput("--profile-file=", profile.String()) } - if info.global.DirtyImageObjects.Valid() { - cmd.FlagWithInput("--dirty-image-objects=", info.global.DirtyImageObjects.Path()) + if info.global.DirtyImageObjects != "" { + cmd.FlagWithArg("--dirty-image-objects=", info.global.DirtyImageObjects) } cmd. - FlagForEachInput("--dex-file=", info.preoptBootDex.Paths()). + FlagForEachInput("--dex-file=", info.preoptBootDex.Strings()). FlagForEachArg("--dex-location=", info.preoptBootLocations). Flag("--generate-debug-info"). Flag("--generate-build-id"). - FlagWithOutput("--oat-symbols=", symbolsFile). + FlagWithArg("--oat-symbols=", symbolsFile.String()). Flag("--strip"). - FlagWithOutput("--oat-file=", outputPath.ReplaceExtension(ctx, "oat")). + FlagWithOutput("--oat-file=", outputPath.ReplaceExtension(ctx, "oat").String()). FlagWithArg("--oat-location=", oatLocation). - FlagWithOutput("--image=", outputPath). + FlagWithOutput("--image=", outputPath.String()). FlagWithArg("--base=", ctx.Config().LibartImgDeviceBaseAddress()). FlagWithArg("--instruction-set=", arch.String()). FlagWithArg("--instruction-set-variant=", info.global.CpuVariant[arch]). @@ -358,21 +358,21 @@ func dexPreoptBootImageRule(ctx android.SingletonContext, info *bootJarsInfo, extraFiles = append(extraFiles, art, oat, vdex, unstrippedOat) // Install the .oat and .art files. - rule.Install(art, filepath.Join(installDir, art.Base())) - rule.Install(oat, filepath.Join(installDir, oat.Base())) + rule.Install(art.String(), filepath.Join(installDir, art.Base())) + rule.Install(oat.String(), filepath.Join(installDir, oat.Base())) // The vdex files are identical between architectures, install them to a shared location. The Make rules will // only use the install rules for one architecture, and will create symlinks into the architecture-specific // directories. vdexInstalls = append(vdexInstalls, - android.RuleBuilderInstall{vdex, filepath.Join(vdexInstallDir, vdex.Base())}) + android.RuleBuilderInstall{vdex.String(), filepath.Join(vdexInstallDir, vdex.Base())}) // Install the unstripped oat files. The Make rules will put these in $(TARGET_OUT_UNSTRIPPED) unstrippedInstalls = append(unstrippedInstalls, - android.RuleBuilderInstall{unstrippedOat, filepath.Join(installDir, unstrippedOat.Base())}) + android.RuleBuilderInstall{unstrippedOat.String(), filepath.Join(installDir, unstrippedOat.Base())}) } - cmd.ImplicitOutputs(extraFiles) + cmd.ImplicitOutputs(extraFiles.Strings()) rule.Build(pctx, ctx, "bootJarsDexpreopt_"+arch.String(), "dexpreopt boot jars "+arch.String()) @@ -387,7 +387,7 @@ It is likely that the boot classpath is inconsistent. Rebuild with ART_BOOT_IMAGE_EXTRA_ARGS="--runtime-arg -verbose:verifier" to see verification errors.` func bootImageProfileRule(ctx android.SingletonContext, info *bootJarsInfo, missingDeps []string) android.WritablePath { - if !info.global.UseProfileForBootImage || ctx.Config().IsPdkBuild() || ctx.Config().UnbundledBuild() { + if len(info.global.BootImageProfiles) == 0 { return nil } @@ -396,25 +396,13 @@ func bootImageProfileRule(ctx android.SingletonContext, info *bootJarsInfo, miss rule := android.NewRuleBuilder() rule.MissingDeps(missingDeps) - var bootImageProfile android.Path + var bootImageProfile string if len(info.global.BootImageProfiles) > 1 { combinedBootImageProfile := info.dir.Join(ctx, "boot-image-profile.txt") - rule.Command().Text("cat").Inputs(info.global.BootImageProfiles).Text(">").Output(combinedBootImageProfile) - bootImageProfile = combinedBootImageProfile - } else if len(info.global.BootImageProfiles) == 1 { - bootImageProfile = info.global.BootImageProfiles[0] + rule.Command().Text("cat").Inputs(info.global.BootImageProfiles).Text(">").Output(combinedBootImageProfile.String()) + bootImageProfile = combinedBootImageProfile.String() } else { - // If not set, use the default. Some branches like master-art-host don't have frameworks/base, so manually - // handle the case that the default is missing. Those branches won't attempt to build the profile rule, - // and if they do they'll get a missing deps error. - defaultProfile := "frameworks/base/config/boot-image-profile.txt" - path := android.ExistentPathForSource(ctx, defaultProfile) - if path.Valid() { - bootImageProfile = path.Path() - } else { - missingDeps = append(missingDeps, defaultProfile) - bootImageProfile = android.PathForOutput(ctx, "missing") - } + bootImageProfile = info.global.BootImageProfiles[0] } profile := info.dir.Join(ctx, "boot.prof") @@ -422,12 +410,12 @@ func bootImageProfileRule(ctx android.SingletonContext, info *bootJarsInfo, miss rule.Command(). Text(`ANDROID_LOG_TAGS="*:e"`). Tool(tools.Profman). - FlagWithInput("--create-profile-from=", bootImageProfile). - FlagForEachInput("--apk=", info.preoptBootDex.Paths()). + FlagWithArg("--create-profile-from=", bootImageProfile). + FlagForEachInput("--apk=", info.preoptBootDex.Strings()). FlagForEachArg("--dex-location=", info.preoptBootLocations). - FlagWithOutput("--reference-profile-file=", profile) + FlagWithOutput("--reference-profile-file=", profile.String()) - rule.Install(profile, "/system/etc/boot-image.prof") + rule.Install(profile.String(), "/system/etc/boot-image.prof") rule.Build(pctx, ctx, "bootJarsProfile", "profile boot jars") @@ -451,6 +439,16 @@ func bootImageMakeVars(ctx android.MakeVarsContext) { for arch, _ := range info.images { ctx.Strict("DEXPREOPT_IMAGE_"+arch.String(), info.images[arch].String()) + var builtInstalled []string + for _, install := range info.installs[arch] { + builtInstalled = append(builtInstalled, install.From+":"+install.To) + } + + var unstrippedBuiltInstalled []string + for _, install := range info.unstrippedInstalls[arch] { + unstrippedBuiltInstalled = append(unstrippedBuiltInstalled, install.From+":"+install.To) + } + ctx.Strict("DEXPREOPT_IMAGE_BUILT_INSTALLED_"+arch.String(), info.installs[arch].String()) ctx.Strict("DEXPREOPT_IMAGE_UNSTRIPPED_BUILT_INSTALLED_"+arch.String(), info.unstrippedInstalls[arch].String()) ctx.Strict("DEXPREOPT_IMAGE_VDEX_BUILT_INSTALLED_"+arch.String(), info.vdexInstalls[arch].String()) diff --git a/java/hiddenapi.go b/java/hiddenapi.go index 104cd767..01e2c5ec 100644 --- a/java/hiddenapi.go +++ b/java/hiddenapi.go @@ -15,6 +15,8 @@ package java import ( + "path/filepath" + "github.com/google/blueprint" "android/soong/android" @@ -173,3 +175,14 @@ func hiddenAPIEncodeDex(ctx android.ModuleContext, output android.WritablePath, TransformZipAlign(ctx, output, tmpOutput) } } + +type hiddenAPIPath struct { + path string +} + +var _ android.Path = (*hiddenAPIPath)(nil) + +func (p *hiddenAPIPath) String() string { return p.path } +func (p *hiddenAPIPath) Ext() string { return filepath.Ext(p.path) } +func (p *hiddenAPIPath) Base() string { return filepath.Base(p.path) } +func (p *hiddenAPIPath) Rel() string { return p.path } diff --git a/java/hiddenapi_singleton.go b/java/hiddenapi_singleton.go index ba8b3e1f..adbd3567 100644 --- a/java/hiddenapi_singleton.go +++ b/java/hiddenapi_singleton.go @@ -170,14 +170,14 @@ func stubFlagsRule(ctx android.SingletonContext) { rule.MissingDeps(missingDeps) rule.Command(). - Tool(pctx.HostBinToolPath(ctx, "hiddenapi")). + Tool(pctx.HostBinToolPath(ctx, "hiddenapi").String()). Text("list"). - FlagForEachInput("--boot-dex=", bootDexJars). - FlagWithInputList("--public-stub-classpath=", publicStubPaths, ":"). - FlagWithInputList("--public-stub-classpath=", systemStubPaths, ":"). - FlagWithInputList("--public-stub-classpath=", testStubPaths, ":"). - FlagWithInputList("--core-platform-stub-classpath=", corePlatformStubPaths, ":"). - FlagWithOutput("--out-api-flags=", tempPath) + FlagForEachInput("--boot-dex=", bootDexJars.Strings()). + FlagWithInputList("--public-stub-classpath=", publicStubPaths.Strings(), ":"). + FlagWithInputList("--public-stub-classpath=", systemStubPaths.Strings(), ":"). + FlagWithInputList("--public-stub-classpath=", testStubPaths.Strings(), ":"). + FlagWithInputList("--core-platform-stub-classpath=", corePlatformStubPaths.Strings(), ":"). + FlagWithOutput("--out-api-flags=", tempPath.String()) commitChangeForRestat(rule, tempPath, outputPath) @@ -214,20 +214,20 @@ func flagsRule(ctx android.SingletonContext) android.Path { stubFlags := hiddenAPISingletonPaths(ctx).stubFlags rule.Command(). - Tool(android.PathForSource(ctx, "frameworks/base/tools/hiddenapi/generate_hiddenapi_lists.py")). - FlagWithInput("--csv ", stubFlags). - Inputs(flagsCSV). + Tool(android.PathForSource(ctx, "frameworks/base/tools/hiddenapi/generate_hiddenapi_lists.py").String()). + FlagWithInput("--csv ", stubFlags.String()). + Inputs(flagsCSV.Strings()). FlagWithInput("--greylist ", - android.PathForSource(ctx, "frameworks/base/config/hiddenapi-greylist.txt")). + android.PathForSource(ctx, "frameworks/base/config/hiddenapi-greylist.txt").String()). FlagWithInput("--greylist-ignore-conflicts ", - greylistIgnoreConflicts). + greylistIgnoreConflicts.String()). FlagWithInput("--greylist-max-p ", - android.PathForSource(ctx, "frameworks/base/config/hiddenapi-greylist-max-p.txt")). + android.PathForSource(ctx, "frameworks/base/config/hiddenapi-greylist-max-p.txt").String()). FlagWithInput("--greylist-max-o-ignore-conflicts ", - android.PathForSource(ctx, "frameworks/base/config/hiddenapi-greylist-max-o.txt")). + android.PathForSource(ctx, "frameworks/base/config/hiddenapi-greylist-max-o.txt").String()). FlagWithInput("--blacklist ", - android.PathForSource(ctx, "frameworks/base/config/hiddenapi-force-blacklist.txt")). - FlagWithOutput("--output ", tempPath) + android.PathForSource(ctx, "frameworks/base/config/hiddenapi-force-blacklist.txt").String()). + FlagWithOutput("--output ", tempPath.String()) commitChangeForRestat(rule, tempPath, outputPath) @@ -243,8 +243,8 @@ func emptyFlagsRule(ctx android.SingletonContext) android.Path { outputPath := hiddenAPISingletonPaths(ctx).flags - rule.Command().Text("rm").Flag("-f").Output(outputPath) - rule.Command().Text("touch").Output(outputPath) + rule.Command().Text("rm").Flag("-f").Output(outputPath.String()) + rule.Command().Text("touch").Output(outputPath.String()) rule.Build(pctx, ctx, "emptyHiddenAPIFlagsFile", "empty hiddenapi flags") @@ -269,10 +269,10 @@ func metadataRule(ctx android.SingletonContext) android.Path { outputPath := hiddenAPISingletonPaths(ctx).metadata rule.Command(). - Tool(android.PathForSource(ctx, "frameworks/base/tools/hiddenapi/merge_csv.py")). - Inputs(metadataCSV). + Tool(android.PathForSource(ctx, "frameworks/base/tools/hiddenapi/merge_csv.py").String()). + Inputs(metadataCSV.Strings()). Text(">"). - Output(outputPath) + Output(outputPath.String()) rule.Build(pctx, ctx, "hiddenAPIGreylistMetadataFile", "hiddenapi greylist metadata") @@ -284,15 +284,15 @@ func metadataRule(ctx android.SingletonContext) android.Path { // the rule. func commitChangeForRestat(rule *android.RuleBuilder, tempPath, outputPath android.WritablePath) { rule.Restat() - rule.Temporary(tempPath) + rule.Temporary(tempPath.String()) rule.Command(). Text("("). Text("if"). - Text("cmp -s").Input(tempPath).Output(outputPath).Text(";"). + Text("cmp -s").Input(tempPath.String()).Output(outputPath.String()).Text(";"). Text("then"). - Text("rm").Input(tempPath).Text(";"). + Text("rm").Input(tempPath.String()).Text(";"). Text("else"). - Text("mv").Input(tempPath).Output(outputPath).Text(";"). + Text("mv").Input(tempPath.String()).Output(outputPath.String()).Text(";"). Text("fi"). Text(")") } diff --git a/java/testing.go b/java/testing.go index bec3c0b2..6febfa1d 100644 --- a/java/testing.go +++ b/java/testing.go @@ -18,7 +18,6 @@ import ( "fmt" "android/soong/android" - "android/soong/dexpreopt" ) func TestConfig(buildDir string, env map[string]string) android.Config { @@ -31,9 +30,6 @@ func TestConfig(buildDir string, env map[string]string) android.Config { config := android.TestArchConfig(buildDir, env) config.TestProductVariables.DeviceSystemSdkVersions = []string{"14", "15"} - pathCtx := android.PathContextForTesting(config, nil) - setDexpreoptGlobalConfig(config, dexpreopt.GlobalConfigForTests(pathCtx)) - return config } |
