Make RuleBuilder methods take Paths
There are no more Make paths being used in Soong now that
dexpreopting and hiddenapi are in Soong. Use the Path types
in the inputs to RuleBuilder, and fix all users of RuleBuilder.
This reapplies I886f803d9a3419a43b2cae412537645f94c5dfbf with
fixes to disable preopt for Soong-only builds when the global
dexpreopt.config doesn't exist.
Test: all soong tests
Test: m checkbuild
Change-Id: I4dae9ecd5de22f062f9478ec8f0747f099cf8190
diff --git a/java/dexpreopt.go b/java/dexpreopt.go
index 0a56529..ceed9cb 100644
--- a/java/dexpreopt.go
+++ b/java/dexpreopt.go
@@ -56,11 +56,13 @@
}
func (d *dexpreopter) dexpreoptDisabled(ctx android.ModuleContext) bool {
- if ctx.Config().DisableDexPreopt() {
+ global := dexpreoptGlobalConfig(ctx)
+
+ if global.DisablePreopt {
return true
}
- if ctx.Config().DisableDexPreoptForModule(ctx.ModuleName()) {
+ if inList(ctx.ModuleName(), global.DisablePreoptModules) {
return true
}
@@ -86,18 +88,30 @@
}
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(f)
+ globalConfig, err := dexpreopt.LoadGlobalConfig(ctx, f)
if err != nil {
panic(err)
}
return globalConfig
}
- return dexpreopt.GlobalConfig{}
+
+ // No global config filename set, see if there is a test config set
+ return ctx.Config().Once(dexpreoptTestGlobalConfigKey, func() interface{} {
+ // Nope, return a config with preopting disabled
+ return dexpreopt.GlobalConfig{
+ DisablePreopt: true,
+ }
+ })
}).(dexpreopt.GlobalConfig)
}
@@ -131,17 +145,15 @@
archs = archs[:1]
}
- var images []string
+ var images android.Paths
for _, arch := range archs {
- images = append(images, info.images[arch].String())
+ images = append(images, info.images[arch])
}
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) {
@@ -153,24 +165,20 @@
profileIsTextListing = true
} else {
profileClassListing = android.ExistentPathForSource(ctx,
- ctx.Config().DexPreoptProfileDir(), ctx.ModuleName()+".prof")
+ info.global.ProfileDir, ctx.ModuleName()+".prof")
}
}
- if profileClassListing.Valid() {
- deps = append(deps, profileClassListing.Path())
- }
-
dexpreoptConfig := dexpreopt.ModuleConfig{
Name: ctx.ModuleName(),
DexLocation: dexLocation,
- BuildPath: android.PathForModuleOut(ctx, "dexpreopt", ctx.ModuleName()+".jar").String(),
- DexPath: dexJarFile.String(),
+ BuildPath: android.PathForModuleOut(ctx, "dexpreopt", ctx.ModuleName()+".jar").OutputPath,
+ DexPath: dexJarFile,
UncompressedDex: d.uncompressedDex,
HasApkLibraries: false,
PreoptFlags: nil,
- ProfileClassListing: profileClassListing.String(),
+ ProfileClassListing: profileClassListing,
ProfileIsTextListing: profileIsTextListing,
EnforceUsesLibraries: false,
@@ -181,7 +189,7 @@
Archs: archs,
DexPreoptImages: images,
- PreoptBootClassPathDexFiles: info.preoptBootDex.Strings(),
+ PreoptBootClassPathDexFiles: info.preoptBootDex.Paths(),
PreoptBootClassPathDexLocations: info.preoptBootLocations,
PreoptExtractedApk: false,
@@ -190,11 +198,11 @@
ForceCreateAppImage: BoolDefault(d.dexpreoptProperties.Dex_preopt.App_image, false),
NoStripping: Bool(d.dexpreoptProperties.Dex_preopt.No_stripping),
- StripInputPath: dexJarFile.String(),
- StripOutputPath: strippedDexJarFile.String(),
+ StripInputPath: dexJarFile,
+ StripOutputPath: strippedDexJarFile.OutputPath,
}
- dexpreoptRule, err := dexpreopt.GenerateDexpreoptRule(info.global, dexpreoptConfig)
+ dexpreoptRule, err := dexpreopt.GenerateDexpreoptRule(ctx, info.global, dexpreoptConfig)
if err != nil {
ctx.ModuleErrorf("error generating dexpreopt rule: %s", err.Error())
return dexJarFile