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
This commit is contained in:
Colin Cross
2019-02-15 10:39:37 -08:00
parent 501d7e594a
commit 69f59a3327
13 changed files with 645 additions and 477 deletions

View File

@@ -56,11 +56,13 @@ type DexpreoptProperties struct {
}
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 @@ 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(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 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Mo
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 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Mo
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 @@ func (d *dexpreopter) dexpreopt(ctx android.ModuleContext, dexJarFile android.Mo
Archs: archs,
DexPreoptImages: images,
PreoptBootClassPathDexFiles: info.preoptBootDex.Strings(),
PreoptBootClassPathDexFiles: info.preoptBootDex.Paths(),
PreoptBootClassPathDexLocations: info.preoptBootLocations,
PreoptExtractedApk: false,
@@ -190,11 +198,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.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