Merge changes Ic88be643,Ibe21efde

* changes:
  Replace ModuleContext.AConfig() with Config()
  Make *Context.Config return a Config instead of a interface{}
This commit is contained in:
Treehugger Robot 2017-11-30 02:21:30 +00:00 committed by Gerrit Code Review
commit 46029a4131
28 changed files with 162 additions and 123 deletions

View File

@ -60,9 +60,7 @@ func AndroidMkSingleton() Singleton {
type androidMkSingleton struct{} type androidMkSingleton struct{}
func (c *androidMkSingleton) GenerateBuildActions(ctx SingletonContext) { func (c *androidMkSingleton) GenerateBuildActions(ctx SingletonContext) {
config := ctx.Config().(Config) if !ctx.Config().EmbeddedInMake() {
if !config.EmbeddedInMake() {
return return
} }
@ -74,7 +72,7 @@ func (c *androidMkSingleton) GenerateBuildActions(ctx SingletonContext) {
sort.Sort(AndroidModulesByName{androidMkModulesList, ctx}) sort.Sort(AndroidModulesByName{androidMkModulesList, ctx})
transMk := PathForOutput(ctx, "Android"+String(config.ProductVariables.Make_suffix)+".mk") transMk := PathForOutput(ctx, "Android"+String(ctx.Config().ProductVariables.Make_suffix)+".mk")
if ctx.Failed() { if ctx.Failed() {
return return
} }
@ -184,8 +182,7 @@ func translateAndroidMkModule(ctx SingletonContext, w io.Writer, mod blueprint.M
} }
config := ctx.Config().(Config) if amod.Arch().ArchType != ctx.Config().Targets[amod.Os().Class][0].Arch.ArchType {
if amod.Arch().ArchType != config.Targets[amod.Os().Class][0].Arch.ArchType {
prefix = "2ND_" + prefix prefix = "2ND_" + prefix
} }
} }

View File

@ -66,7 +66,7 @@ func (a *apiLevelsSingleton) GenerateBuildActions(ctx SingletonContext) {
"N-MR1": 25, "N-MR1": 25,
"O": 26, "O": 26,
} }
for i, codename := range ctx.Config().(Config).PlatformVersionCombinedCodenames() { for i, codename := range ctx.Config().PlatformVersionCombinedCodenames() {
apiLevelsMap[codename] = baseApiLevel + i apiLevelsMap[codename] = baseApiLevel + i
} }

View File

@ -305,7 +305,7 @@ func archMutator(mctx BottomUpMutatorContext) {
primaryModules := make(map[int]bool) primaryModules := make(map[int]bool)
for _, class := range osClasses { for _, class := range osClasses {
targets := mctx.AConfig().Targets[class] targets := mctx.Config().Targets[class]
if len(targets) == 0 { if len(targets) == 0 {
continue continue
} }
@ -325,7 +325,7 @@ func archMutator(mctx BottomUpMutatorContext) {
var prefer32 bool var prefer32 bool
switch class { switch class {
case Device: case Device:
prefer32 = mctx.AConfig().DevicePrefer32BitExecutables() prefer32 = mctx.Config().DevicePrefer32BitExecutables()
case HostCross: case HostCross:
// Windows builds always prefer 32-bit // Windows builds always prefer 32-bit
prefer32 = true prefer32 = true
@ -774,7 +774,7 @@ func (a *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
// that are being compiled for 64-bit. Its expected use case is binaries like linker and // that are being compiled for 64-bit. Its expected use case is binaries like linker and
// debuggerd that need to know when they are a 32-bit process running on a 64-bit device // debuggerd that need to know when they are a 32-bit process running on a 64-bit device
if os.Class == Device { if os.Class == Device {
if ctx.AConfig().Android64() { if ctx.Config().Android64() {
field := "Android64" field := "Android64"
prefix := "target.android64" prefix := "target.android64"
a.appendProperties(ctx, genProps, targetProp, field, prefix) a.appendProperties(ctx, genProps, targetProp, field, prefix)
@ -785,13 +785,13 @@ func (a *ModuleBase) setArchProperties(ctx BottomUpMutatorContext) {
} }
if arch.ArchType == X86 && (hasArmAbi(arch) || if arch.ArchType == X86 && (hasArmAbi(arch) ||
hasArmAndroidArch(ctx.AConfig().Targets[Device])) { hasArmAndroidArch(ctx.Config().Targets[Device])) {
field := "Arm_on_x86" field := "Arm_on_x86"
prefix := "target.arm_on_x86" prefix := "target.arm_on_x86"
a.appendProperties(ctx, genProps, targetProp, field, prefix) a.appendProperties(ctx, genProps, targetProp, field, prefix)
} }
if arch.ArchType == X86_64 && (hasArmAbi(arch) || if arch.ArchType == X86_64 && (hasArmAbi(arch) ||
hasArmAndroidArch(ctx.AConfig().Targets[Device])) { hasArmAndroidArch(ctx.Config().Targets[Device])) {
field := "Arm_on_x86_64" field := "Arm_on_x86_64"
prefix := "target.arm_on_x86_64" prefix := "target.arm_on_x86_64"
a.appendProperties(ctx, genProps, targetProp, field, prefix) a.appendProperties(ctx, genProps, targetProp, field, prefix)

View File

@ -48,7 +48,7 @@ func EnvSingleton() Singleton {
type envSingleton struct{} type envSingleton struct{}
func (c *envSingleton) GenerateBuildActions(ctx SingletonContext) { func (c *envSingleton) GenerateBuildActions(ctx SingletonContext) {
envDeps := ctx.Config().(Config).EnvDeps() envDeps := ctx.Config().EnvDeps()
envFile := PathForOutput(ctx, ".soong.environment") envFile := PathForOutput(ctx, ".soong.environment")
if ctx.Failed() { if ctx.Failed() {

View File

@ -26,7 +26,7 @@ import (
// before the module has been split into architecture variants, and before defaults modules have // before the module has been split into architecture variants, and before defaults modules have
// been applied. // been applied.
type LoadHookContext interface { type LoadHookContext interface {
// TODO: a new context that includes AConfig() but not Target(), etc.? // TODO: a new context that includes Config() but not Target(), etc.?
BaseContext BaseContext
AppendProperties(...interface{}) AppendProperties(...interface{})
PrependProperties(...interface{}) PrependProperties(...interface{})

View File

@ -105,13 +105,11 @@ type makeVarsVariable struct {
} }
func (s *makeVarsSingleton) GenerateBuildActions(ctx SingletonContext) { func (s *makeVarsSingleton) GenerateBuildActions(ctx SingletonContext) {
config := ctx.Config().(Config) if !ctx.Config().EmbeddedInMake() {
if !config.EmbeddedInMake() {
return return
} }
outFile := PathForOutput(ctx, "make_vars"+proptools.String(config.ProductVariables.Make_suffix)+".mk").String() outFile := PathForOutput(ctx, "make_vars"+proptools.String(ctx.Config().ProductVariables.Make_suffix)+".mk").String()
if ctx.Failed() { if ctx.Failed() {
return return
@ -120,7 +118,7 @@ func (s *makeVarsSingleton) GenerateBuildActions(ctx SingletonContext) {
vars := []makeVarsVariable{} vars := []makeVarsVariable{}
for _, provider := range makeVarsProviders { for _, provider := range makeVarsProviders {
mctx := &makeVarsContext{ mctx := &makeVarsContext{
config: config, config: ctx.Config(),
ctx: ctx, ctx: ctx,
pctx: provider.pctx, pctx: provider.pctx,
} }

View File

@ -19,6 +19,7 @@ import (
"path/filepath" "path/filepath"
"sort" "sort"
"strings" "strings"
"text/scanner"
"github.com/google/blueprint" "github.com/google/blueprint"
"github.com/google/blueprint/pathtools" "github.com/google/blueprint/pathtools"
@ -70,13 +71,36 @@ type androidBaseContext interface {
} }
type BaseContext interface { type BaseContext interface {
blueprint.BaseModuleContext BaseModuleContext
androidBaseContext androidBaseContext
} }
// BaseModuleContext is the same as blueprint.BaseModuleContext except that Config() returns
// a Config instead of an interface{}.
type BaseModuleContext interface {
ModuleName() string
ModuleDir() string
Config() Config
ContainsProperty(name string) bool
Errorf(pos scanner.Position, fmt string, args ...interface{})
ModuleErrorf(fmt string, args ...interface{})
PropertyErrorf(property, fmt string, args ...interface{})
Failed() bool
// GlobWithDeps returns a list of files that match the specified pattern but do not match any
// of the patterns in excludes. It also adds efficient dependencies to rerun the primary
// builder whenever a file matching the pattern as added or removed, without rerunning if a
// file that does not match the pattern is added to a searched directory.
GlobWithDeps(pattern string, excludes []string) ([]string, error)
Fs() pathtools.FileSystem
AddNinjaFileDeps(deps ...string)
}
type ModuleContext interface { type ModuleContext interface {
androidBaseContext androidBaseContext
blueprint.BaseModuleContext BaseModuleContext
// Deprecated: use ModuleContext.Build instead. // Deprecated: use ModuleContext.Build instead.
ModuleBuild(pctx PackageContext, params ModuleBuildParams) ModuleBuild(pctx PackageContext, params ModuleBuildParams)
@ -482,7 +506,7 @@ func (a *ModuleBase) generateModuleTarget(ctx ModuleContext) {
Rule: blueprint.Phony, Rule: blueprint.Phony,
Output: name, Output: name,
Implicits: allInstalledFiles, Implicits: allInstalledFiles,
Default: !ctx.Config().(Config).EmbeddedInMake(), Default: !ctx.Config().EmbeddedInMake(),
}) })
deps = append(deps, name) deps = append(deps, name)
a.installTarget = name a.installTarget = name
@ -501,7 +525,7 @@ func (a *ModuleBase) generateModuleTarget(ctx ModuleContext) {
if len(deps) > 0 { if len(deps) > 0 {
suffix := "" suffix := ""
if ctx.Config().(Config).EmbeddedInMake() { if ctx.Config().EmbeddedInMake() {
suffix = "-soong" suffix = "-soong"
} }
@ -605,6 +629,10 @@ func (a *androidModuleContext) ninjaError(desc string, outputs []string, err err
return return
} }
func (a *androidModuleContext) Config() Config {
return a.ModuleContext.Config().(Config)
}
func (a *androidModuleContext) ModuleBuild(pctx PackageContext, params ModuleBuildParams) { func (a *androidModuleContext) ModuleBuild(pctx PackageContext, params ModuleBuildParams) {
a.Build(pctx, BuildParams(params)) a.Build(pctx, BuildParams(params))
} }
@ -692,7 +720,7 @@ func (a *androidModuleContext) validateAndroidModule(module blueprint.Module) Mo
} }
if !aModule.Enabled() { if !aModule.Enabled() {
if a.AConfig().AllowMissingDependencies() { if a.Config().AllowMissingDependencies() {
a.AddMissingDependencies([]string{a.OtherModuleName(aModule)}) a.AddMissingDependencies([]string{a.OtherModuleName(aModule)})
} else { } else {
a.ModuleErrorf("depends on disabled module %q", a.OtherModuleName(aModule)) a.ModuleErrorf("depends on disabled module %q", a.OtherModuleName(aModule))
@ -850,11 +878,11 @@ func (a *androidModuleContext) skipInstall(fullInstallPath OutputPath) bool {
} }
if a.Device() { if a.Device() {
if a.AConfig().SkipDeviceInstall() { if a.Config().SkipDeviceInstall() {
return true return true
} }
if a.AConfig().SkipMegaDeviceInstall(fullInstallPath.String()) { if a.Config().SkipMegaDeviceInstall(fullInstallPath.String()) {
return true return true
} }
} }
@ -899,7 +927,7 @@ func (a *androidModuleContext) installFile(installPath OutputPath, name string,
Input: srcPath, Input: srcPath,
Implicits: implicitDeps, Implicits: implicitDeps,
OrderOnly: orderOnlyDeps, OrderOnly: orderOnlyDeps,
Default: !a.AConfig().EmbeddedInMake(), Default: !a.Config().EmbeddedInMake(),
}) })
a.installFiles = append(a.installFiles, fullInstallPath) a.installFiles = append(a.installFiles, fullInstallPath)
@ -919,7 +947,7 @@ func (a *androidModuleContext) InstallSymlink(installPath OutputPath, name strin
Description: "install symlink " + fullInstallPath.Base(), Description: "install symlink " + fullInstallPath.Base(),
Output: fullInstallPath, Output: fullInstallPath,
OrderOnly: Paths{srcPath}, OrderOnly: Paths{srcPath},
Default: !a.AConfig().EmbeddedInMake(), Default: !a.Config().EmbeddedInMake(),
Args: map[string]string{ Args: map[string]string{
"fromPath": srcPath.String(), "fromPath": srcPath.String(),
}, },
@ -1094,7 +1122,7 @@ func (c *buildTargetSingleton) GenerateBuildActions(ctx SingletonContext) {
}) })
suffix := "" suffix := ""
if ctx.Config().(Config).EmbeddedInMake() { if ctx.Config().EmbeddedInMake() {
suffix = "-soong" suffix = "-soong"
} }
@ -1106,7 +1134,7 @@ func (c *buildTargetSingleton) GenerateBuildActions(ctx SingletonContext) {
}) })
// Make will generate the MODULES-IN-* targets // Make will generate the MODULES-IN-* targets
if ctx.Config().(Config).EmbeddedInMake() { if ctx.Config().EmbeddedInMake() {
return return
} }
@ -1151,7 +1179,7 @@ func (c *buildTargetSingleton) GenerateBuildActions(ctx SingletonContext) {
Implicits: modulesInDir[dir], Implicits: modulesInDir[dir],
// HACK: checkbuild should be an optional build, but force it // HACK: checkbuild should be an optional build, but force it
// enabled for now in standalone builds // enabled for now in standalone builds
Default: !ctx.Config().(Config).EmbeddedInMake(), Default: !ctx.Config().EmbeddedInMake(),
}) })
} }

View File

@ -108,7 +108,7 @@ func PostDepsMutators(f RegisterMutatorFunc) {
type AndroidTopDownMutator func(TopDownMutatorContext) type AndroidTopDownMutator func(TopDownMutatorContext)
type TopDownMutatorContext interface { type TopDownMutatorContext interface {
blueprint.BaseModuleContext BaseModuleContext
androidBaseContext androidBaseContext
OtherModuleExists(name string) bool OtherModuleExists(name string) bool
@ -139,8 +139,22 @@ type androidTopDownMutatorContext struct {
type AndroidBottomUpMutator func(BottomUpMutatorContext) type AndroidBottomUpMutator func(BottomUpMutatorContext)
type BottomUpMutatorContext interface { type BottomUpMutatorContext interface {
blueprint.BottomUpMutatorContext BaseModuleContext
androidBaseContext androidBaseContext
OtherModuleExists(name string) bool
Rename(name string)
Module() blueprint.Module
AddDependency(module blueprint.Module, tag blueprint.DependencyTag, name ...string)
AddReverseDependency(module blueprint.Module, tag blueprint.DependencyTag, name string)
CreateVariations(...string) []blueprint.Module
CreateLocalVariations(...string) []blueprint.Module
SetDependencyVariation(string)
AddVariationDependencies([]blueprint.Variation, blueprint.DependencyTag, ...string)
AddFarVariationDependencies([]blueprint.Variation, blueprint.DependencyTag, ...string)
AddInterVariantDependency(tag blueprint.DependencyTag, from, to blueprint.Module)
ReplaceDependencies(string)
} }
type androidBottomUpMutatorContext struct { type androidBottomUpMutatorContext struct {
@ -193,6 +207,14 @@ func depsMutator(ctx BottomUpMutatorContext) {
} }
} }
func (a *androidTopDownMutatorContext) Config() Config {
return a.config
}
func (a *androidBottomUpMutatorContext) Config() Config {
return a.config
}
func (a *androidTopDownMutatorContext) Module() Module { func (a *androidTopDownMutatorContext) Module() Module {
module, _ := a.TopDownMutatorContext.Module().(Module) module, _ := a.TopDownMutatorContext.Module().(Module)
return module return module

View File

@ -47,7 +47,7 @@ type configErrorWrapper struct {
var _ PathContext = &configErrorWrapper{} var _ PathContext = &configErrorWrapper{}
var _ errorfContext = &configErrorWrapper{} var _ errorfContext = &configErrorWrapper{}
func (e *configErrorWrapper) Config() interface{} { func (e *configErrorWrapper) Config() Config {
return e.config return e.config
} }
func (e *configErrorWrapper) Errorf(format string, args ...interface{}) { func (e *configErrorWrapper) Errorf(format string, args ...interface{}) {

View File

@ -29,7 +29,7 @@ import (
// Path methods. // Path methods.
type PathContext interface { type PathContext interface {
Fs() pathtools.FileSystem Fs() pathtools.FileSystem
Config() interface{} Config() Config
AddNinjaFileDeps(deps ...string) AddNinjaFileDeps(deps ...string)
} }
@ -37,8 +37,8 @@ type PathGlobContext interface {
GlobWithDeps(globPattern string, excludes []string) ([]string, error) GlobWithDeps(globPattern string, excludes []string) ([]string, error)
} }
var _ PathContext = blueprint.SingletonContext(nil) var _ PathContext = SingletonContext(nil)
var _ PathContext = blueprint.ModuleContext(nil) var _ PathContext = ModuleContext(nil)
type ModuleInstallPathContext interface { type ModuleInstallPathContext interface {
PathContext PathContext
@ -67,15 +67,6 @@ type moduleErrorf interface {
var _ moduleErrorf = blueprint.ModuleContext(nil) var _ moduleErrorf = blueprint.ModuleContext(nil)
// pathConfig returns the android Config interface associated to the context.
// Panics if the context isn't affiliated with an android build.
func pathConfig(ctx PathContext) Config {
if ret, ok := ctx.Config().(Config); ok {
return ret
}
panic("Paths may only be used on Soong builds")
}
// reportPathError will register an error with the attached context. It // reportPathError will register an error with the attached context. It
// attempts ctx.ModuleErrorf for a better error message first, then falls // attempts ctx.ModuleErrorf for a better error message first, then falls
// back to ctx.Errorf. // back to ctx.Errorf.
@ -197,7 +188,7 @@ type Paths []Path
// PathsForSource returns Paths rooted from SrcDir // PathsForSource returns Paths rooted from SrcDir
func PathsForSource(ctx PathContext, paths []string) Paths { func PathsForSource(ctx PathContext, paths []string) Paths {
if pathConfig(ctx).AllowMissingDependencies() { if ctx.Config().AllowMissingDependencies() {
if modCtx, ok := ctx.(ModuleContext); ok { if modCtx, ok := ctx.(ModuleContext); ok {
ret := make(Paths, 0, len(paths)) ret := make(Paths, 0, len(paths))
intermediates := pathForModule(modCtx).withRel("missing") intermediates := pathForModule(modCtx).withRel("missing")
@ -247,7 +238,7 @@ func PathsForModuleSrc(ctx ModuleContext, paths []string) Paths {
// source directory, but strip the local source directory from the beginning of // source directory, but strip the local source directory from the beginning of
// each string. // each string.
func pathsForModuleSrcFromFullPath(ctx ModuleContext, paths []string) Paths { func pathsForModuleSrcFromFullPath(ctx ModuleContext, paths []string) Paths {
prefix := filepath.Join(ctx.AConfig().srcDir, ctx.ModuleDir()) + "/" prefix := filepath.Join(ctx.Config().srcDir, ctx.ModuleDir()) + "/"
if prefix == "./" { if prefix == "./" {
prefix = "" prefix = ""
} }
@ -271,7 +262,7 @@ func PathsWithOptionalDefaultForModuleSrc(ctx ModuleContext, input []string, def
} }
// Use Glob so that if the default doesn't exist, a dependency is added so that when it // Use Glob so that if the default doesn't exist, a dependency is added so that when it
// is created, we're run again. // is created, we're run again.
path := filepath.Join(ctx.AConfig().srcDir, ctx.ModuleDir(), def) path := filepath.Join(ctx.Config().srcDir, ctx.ModuleDir(), def)
return ctx.Glob(path, []string{}) return ctx.Glob(path, []string{})
} }
@ -476,14 +467,14 @@ var _ Path = SourcePath{}
// code that is embedding ninja variables in paths // code that is embedding ninja variables in paths
func safePathForSource(ctx PathContext, path string) SourcePath { func safePathForSource(ctx PathContext, path string) SourcePath {
p := validateSafePath(ctx, path) p := validateSafePath(ctx, path)
ret := SourcePath{basePath{p, pathConfig(ctx), ""}} ret := SourcePath{basePath{p, ctx.Config(), ""}}
abs, err := filepath.Abs(ret.String()) abs, err := filepath.Abs(ret.String())
if err != nil { if err != nil {
reportPathError(ctx, "%s", err.Error()) reportPathError(ctx, "%s", err.Error())
return ret return ret
} }
buildroot, err := filepath.Abs(pathConfig(ctx).buildDir) buildroot, err := filepath.Abs(ctx.Config().buildDir)
if err != nil { if err != nil {
reportPathError(ctx, "%s", err.Error()) reportPathError(ctx, "%s", err.Error())
return ret return ret
@ -501,14 +492,14 @@ func safePathForSource(ctx PathContext, path string) SourcePath {
// On error, it will return a usable, but invalid SourcePath, and report a ModuleError. // On error, it will return a usable, but invalid SourcePath, and report a ModuleError.
func PathForSource(ctx PathContext, pathComponents ...string) SourcePath { func PathForSource(ctx PathContext, pathComponents ...string) SourcePath {
p := validatePath(ctx, pathComponents...) p := validatePath(ctx, pathComponents...)
ret := SourcePath{basePath{p, pathConfig(ctx), ""}} ret := SourcePath{basePath{p, ctx.Config(), ""}}
abs, err := filepath.Abs(ret.String()) abs, err := filepath.Abs(ret.String())
if err != nil { if err != nil {
reportPathError(ctx, "%s", err.Error()) reportPathError(ctx, "%s", err.Error())
return ret return ret
} }
buildroot, err := filepath.Abs(pathConfig(ctx).buildDir) buildroot, err := filepath.Abs(ctx.Config().buildDir)
if err != nil { if err != nil {
reportPathError(ctx, "%s", err.Error()) reportPathError(ctx, "%s", err.Error())
return ret return ret
@ -536,14 +527,14 @@ func ExistentPathForSource(ctx PathContext, intermediates string, pathComponents
} }
p := validatePath(ctx, pathComponents...) p := validatePath(ctx, pathComponents...)
path := SourcePath{basePath{p, pathConfig(ctx), ""}} path := SourcePath{basePath{p, ctx.Config(), ""}}
abs, err := filepath.Abs(path.String()) abs, err := filepath.Abs(path.String())
if err != nil { if err != nil {
reportPathError(ctx, "%s", err.Error()) reportPathError(ctx, "%s", err.Error())
return OptionalPath{} return OptionalPath{}
} }
buildroot, err := filepath.Abs(pathConfig(ctx).buildDir) buildroot, err := filepath.Abs(ctx.Config().buildDir)
if err != nil { if err != nil {
reportPathError(ctx, "%s", err.Error()) reportPathError(ctx, "%s", err.Error())
return OptionalPath{} return OptionalPath{}
@ -652,7 +643,7 @@ var _ Path = OutputPath{}
// On error, it will return a usable, but invalid OutputPath, and report a ModuleError. // On error, it will return a usable, but invalid OutputPath, and report a ModuleError.
func PathForOutput(ctx PathContext, pathComponents ...string) OutputPath { func PathForOutput(ctx PathContext, pathComponents ...string) OutputPath {
path := validatePath(ctx, pathComponents...) path := validatePath(ctx, pathComponents...)
return OutputPath{basePath{path, pathConfig(ctx), ""}} return OutputPath{basePath{path, ctx.Config(), ""}}
} }
func (p OutputPath) writablePath() {} func (p OutputPath) writablePath() {}
@ -853,7 +844,7 @@ func PathForModuleInstall(ctx ModuleInstallPathContext, pathComponents ...string
if ctx.InstallInSanitizerDir() { if ctx.InstallInSanitizerDir() {
partition = "data/asan/" + partition partition = "data/asan/" + partition
} }
outPaths = []string{"target", "product", ctx.AConfig().DeviceName(), partition} outPaths = []string{"target", "product", ctx.Config().DeviceName(), partition}
} else { } else {
switch ctx.Os() { switch ctx.Os() {
case Linux: case Linux:
@ -905,7 +896,7 @@ func PathForPhony(ctx PathContext, phony string) WritablePath {
if strings.ContainsAny(phony, "$/") { if strings.ContainsAny(phony, "$/") {
reportPathError(ctx, "Phony target contains invalid character ($ or /): %s", phony) reportPathError(ctx, "Phony target contains invalid character ($ or /): %s", phony)
} }
return OutputPath{basePath{phony, pathConfig(ctx), ""}} return OutputPath{basePath{phony, ctx.Config(), ""}}
} }
type testPath struct { type testPath struct {

View File

@ -194,7 +194,7 @@ func (moduleInstallPathContextImpl) Fs() pathtools.FileSystem {
return pathtools.MockFs(nil) return pathtools.MockFs(nil)
} }
func (m moduleInstallPathContextImpl) Config() interface{} { func (m moduleInstallPathContextImpl) Config() Config {
return m.androidBaseContextImpl.config return m.androidBaseContextImpl.config
} }

View File

@ -21,8 +21,7 @@ import (
// SingletonContext // SingletonContext
type SingletonContext interface { type SingletonContext interface {
// TODO(ccross): make this return an android.Config Config() Config
Config() interface{}
ModuleName(module blueprint.Module) string ModuleName(module blueprint.Module) string
ModuleDir(module blueprint.Module) string ModuleDir(module blueprint.Module) string
@ -87,6 +86,10 @@ type singletonContextAdaptor struct {
blueprint.SingletonContext blueprint.SingletonContext
} }
func (s singletonContextAdaptor) Config() Config {
return s.SingletonContext.Config().(Config)
}
func (s singletonContextAdaptor) Variable(pctx PackageContext, name, value string) { func (s singletonContextAdaptor) Variable(pctx PackageContext, name, value string) {
s.SingletonContext.Variable(pctx.PackageContext, name, value) s.SingletonContext.Variable(pctx.PackageContext, name, value)
} }

View File

@ -258,7 +258,7 @@ func variableMutator(mctx BottomUpMutatorContext) {
property := "product_variables." + proptools.PropertyNameForField(name) property := "product_variables." + proptools.PropertyNameForField(name)
// Check that the variable was set for the product // Check that the variable was set for the product
val := reflect.ValueOf(mctx.Config().(Config).ProductVariables).FieldByName(name) val := reflect.ValueOf(mctx.Config().ProductVariables).FieldByName(name)
if !val.IsValid() || val.Kind() != reflect.Ptr || val.IsNil() { if !val.IsValid() || val.Kind() != reflect.Ptr || val.IsNil() {
continue continue
} }

View File

@ -182,7 +182,7 @@ func (binary *binaryDecorator) linkerInit(ctx BaseModuleContext) {
if !ctx.toolchain().Bionic() { if !ctx.toolchain().Bionic() {
if ctx.Os() == android.Linux { if ctx.Os() == android.Linux {
if binary.Properties.Static_executable == nil && Bool(ctx.AConfig().ProductVariables.HostStaticBinaries) { if binary.Properties.Static_executable == nil && Bool(ctx.Config().ProductVariables.HostStaticBinaries) {
binary.Properties.Static_executable = BoolPtr(true) binary.Properties.Static_executable = BoolPtr(true)
} }
} else { } else {
@ -204,7 +204,7 @@ func (binary *binaryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags
flags = binary.baseLinker.linkerFlags(ctx, flags) flags = binary.baseLinker.linkerFlags(ctx, flags)
if ctx.Host() && !binary.static() { if ctx.Host() && !binary.static() {
if !ctx.AConfig().IsEnvTrue("DISABLE_HOST_PIE") { if !ctx.Config().IsEnvTrue("DISABLE_HOST_PIE") {
flags.LdFlags = append(flags.LdFlags, "-pie") flags.LdFlags = append(flags.LdFlags, "-pie")
if ctx.Windows() { if ctx.Windows() {
flags.LdFlags = append(flags.LdFlags, "-Wl,-e_mainCRTStartup") flags.LdFlags = append(flags.LdFlags, "-Wl,-e_mainCRTStartup")

View File

@ -945,7 +945,7 @@ func (c *Module) clang(ctx BaseModuleContext) bool {
clang = true clang = true
} }
if ctx.Device() && ctx.AConfig().DeviceUsesClang() { if ctx.Device() && ctx.Config().DeviceUsesClang() {
clang = true clang = true
} }
} }
@ -1441,10 +1441,10 @@ func vendorMutator(mctx android.BottomUpMutatorContext) {
} }
func getCurrentNdkPrebuiltVersion(ctx DepsContext) string { func getCurrentNdkPrebuiltVersion(ctx DepsContext) string {
if ctx.AConfig().PlatformSdkVersionInt() > config.NdkMaxPrebuiltVersionInt { if ctx.Config().PlatformSdkVersionInt() > config.NdkMaxPrebuiltVersionInt {
return strconv.Itoa(config.NdkMaxPrebuiltVersionInt) return strconv.Itoa(config.NdkMaxPrebuiltVersionInt)
} }
return ctx.AConfig().PlatformSdkVersion() return ctx.Config().PlatformSdkVersion()
} }
var Bool = proptools.Bool var Bool = proptools.Bool

View File

@ -82,7 +82,7 @@ func (c *cmakelistsGeneratorSingleton) GenerateBuildActions(ctx android.Singleto
func getEnvVariable(name string, ctx android.SingletonContext) string { func getEnvVariable(name string, ctx android.SingletonContext) string {
// Using android.Config.Getenv instead of os.getEnv to guarantee soong will // Using android.Config.Getenv instead of os.getEnv to guarantee soong will
// re-run in case this environment variable changes. // re-run in case this environment variable changes.
return ctx.Config().(android.Config).Getenv(name) return ctx.Config().Getenv(name)
} }
func exists(path string) bool { func exists(path string) bool {

View File

@ -218,7 +218,7 @@ func warningsAreAllowed(subdir string) bool {
} }
func addToModuleList(ctx ModuleContext, list string, module string) { func addToModuleList(ctx ModuleContext, list string, module string) {
getWallWerrorMap(ctx.AConfig(), list).Store(module, true) getWallWerrorMap(ctx.Config(), list).Store(module, true)
} }
// Create a Flags struct that collects the compile flags from global values, // Create a Flags struct that collects the compile flags from global values,
@ -360,7 +360,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
fmt.Sprintf("${config.%sGlobalCflags}", hod)) fmt.Sprintf("${config.%sGlobalCflags}", hod))
} }
if Bool(ctx.AConfig().ProductVariables.Brillo) { if Bool(ctx.Config().ProductVariables.Brillo) {
flags.GlobalFlags = append(flags.GlobalFlags, "-D__BRILLO__") flags.GlobalFlags = append(flags.GlobalFlags, "-D__BRILLO__")
} }

View File

@ -117,7 +117,7 @@ func normalizeNdkApiLevel(ctx android.BaseContext, apiLevel string,
return apiLevel, nil return apiLevel, nil
} }
minVersion := ctx.AConfig().MinSupportedSdkVersion() minVersion := ctx.Config().MinSupportedSdkVersion()
firstArchVersions := map[android.ArchType]int{ firstArchVersions := map[android.ArchType]int{
android.Arm: minVersion, android.Arm: minVersion,
android.Arm64: 21, android.Arm64: 21,
@ -188,7 +188,7 @@ func shouldUseVersionScript(stub *stubDecorator) (bool, error) {
} }
func generateStubApiVariants(mctx android.BottomUpMutatorContext, c *stubDecorator) { func generateStubApiVariants(mctx android.BottomUpMutatorContext, c *stubDecorator) {
platformVersion := mctx.AConfig().PlatformSdkVersionInt() platformVersion := mctx.Config().PlatformSdkVersionInt()
firstSupportedVersion, err := normalizeNdkApiLevel(mctx, String(c.properties.First_version), firstSupportedVersion, err := normalizeNdkApiLevel(mctx, String(c.properties.First_version),
mctx.Arch()) mctx.Arch())
@ -207,7 +207,7 @@ func generateStubApiVariants(mctx android.BottomUpMutatorContext, c *stubDecorat
for version := firstGenVersion; version <= platformVersion; version++ { for version := firstGenVersion; version <= platformVersion; version++ {
versionStrs = append(versionStrs, strconv.Itoa(version)) versionStrs = append(versionStrs, strconv.Itoa(version))
} }
versionStrs = append(versionStrs, mctx.AConfig().PlatformVersionActiveCodenames()...) versionStrs = append(versionStrs, mctx.Config().PlatformVersionActiveCodenames()...)
versionStrs = append(versionStrs, "current") versionStrs = append(versionStrs, "current")
modules := mctx.CreateVariations(versionStrs...) modules := mctx.CreateVariations(versionStrs...)

View File

@ -181,7 +181,7 @@ func (pgo *pgo) begin(ctx BaseModuleContext) {
// //
// TODO Validate that each benchmark instruments at least one module // TODO Validate that each benchmark instruments at least one module
pgo.Properties.ShouldProfileModule = false pgo.Properties.ShouldProfileModule = false
pgoBenchmarks := ctx.AConfig().Getenv("ANDROID_PGO_INSTRUMENT") pgoBenchmarks := ctx.Config().Getenv("ANDROID_PGO_INSTRUMENT")
pgoBenchmarksMap := make(map[string]bool) pgoBenchmarksMap := make(map[string]bool)
for _, b := range strings.Split(pgoBenchmarks, ",") { for _, b := range strings.Split(pgoBenchmarks, ",") {
pgoBenchmarksMap[b] = true pgoBenchmarksMap[b] = true
@ -215,7 +215,7 @@ func (pgo *pgo) flags(ctx ModuleContext, flags Flags) Flags {
return props.addProfileGatherFlags(ctx, flags) return props.addProfileGatherFlags(ctx, flags)
} }
if !ctx.AConfig().IsEnvTrue("ANDROID_PGO_NO_PROFILE_USE") { if !ctx.Config().IsEnvTrue("ANDROID_PGO_NO_PROFILE_USE") {
return props.addProfileUseFlags(ctx, flags) return props.addProfileUseFlags(ctx, flags)
} }

View File

@ -53,7 +53,7 @@ func (p *relocationPacker) packingInit(ctx BaseModuleContext) {
if ctx.Target().Os != android.Android { if ctx.Target().Os != android.Android {
enabled = false enabled = false
} }
if ctx.AConfig().Getenv("DISABLE_RELOCATION_PACKER") == "true" { if ctx.Config().Getenv("DISABLE_RELOCATION_PACKER") == "true" {
enabled = false enabled = false
} }
if ctx.useSdk() { if ctx.useSdk() {
@ -68,7 +68,7 @@ func (p *relocationPacker) packingInit(ctx BaseModuleContext) {
} }
func (p *relocationPacker) needsPacking(ctx ModuleContext) bool { func (p *relocationPacker) needsPacking(ctx ModuleContext) bool {
if ctx.AConfig().EmbeddedInMake() { if ctx.Config().EmbeddedInMake() {
return false return false
} }
return p.Properties.PackingRelocations return p.Properties.PackingRelocations

View File

@ -151,12 +151,12 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) {
if ctx.clang() { if ctx.clang() {
if ctx.Host() { if ctx.Host() {
globalSanitizers = ctx.AConfig().SanitizeHost() globalSanitizers = ctx.Config().SanitizeHost()
} else { } else {
arches := ctx.AConfig().SanitizeDeviceArch() arches := ctx.Config().SanitizeDeviceArch()
if len(arches) == 0 || inList(ctx.Arch().ArchType.Name, arches) { if len(arches) == 0 || inList(ctx.Arch().ArchType.Name, arches) {
globalSanitizers = ctx.AConfig().SanitizeDevice() globalSanitizers = ctx.Config().SanitizeDevice()
globalSanitizersDiag = ctx.AConfig().SanitizeDeviceDiag() globalSanitizersDiag = ctx.Config().SanitizeDeviceDiag()
} }
} }
} }
@ -194,13 +194,13 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) {
} }
if found, globalSanitizers = removeFromList("cfi", globalSanitizers); found && s.Cfi == nil { if found, globalSanitizers = removeFromList("cfi", globalSanitizers); found && s.Cfi == nil {
if !ctx.AConfig().CFIDisabledForPath(ctx.ModuleDir()) { if !ctx.Config().CFIDisabledForPath(ctx.ModuleDir()) {
s.Cfi = boolPtr(true) s.Cfi = boolPtr(true)
} }
} }
if found, globalSanitizers = removeFromList("integer_overflow", globalSanitizers); found && s.Integer_overflow == nil { if found, globalSanitizers = removeFromList("integer_overflow", globalSanitizers); found && s.Integer_overflow == nil {
if !ctx.AConfig().IntegerOverflowDisabledForPath(ctx.ModuleDir()) { if !ctx.Config().IntegerOverflowDisabledForPath(ctx.ModuleDir()) {
s.Integer_overflow = boolPtr(true) s.Integer_overflow = boolPtr(true)
} }
} }
@ -225,15 +225,15 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) {
} }
// Enable CFI for all components in the include paths // Enable CFI for all components in the include paths
if s.Cfi == nil && ctx.AConfig().CFIEnabledForPath(ctx.ModuleDir()) { if s.Cfi == nil && ctx.Config().CFIEnabledForPath(ctx.ModuleDir()) {
s.Cfi = boolPtr(true) s.Cfi = boolPtr(true)
if inList("cfi", ctx.AConfig().SanitizeDeviceDiag()) { if inList("cfi", ctx.Config().SanitizeDeviceDiag()) {
s.Diag.Cfi = boolPtr(true) s.Diag.Cfi = boolPtr(true)
} }
} }
// CFI needs gold linker, and mips toolchain does not have one. // CFI needs gold linker, and mips toolchain does not have one.
if !ctx.AConfig().EnableCFI() || ctx.Arch().ArchType == android.Mips || ctx.Arch().ArchType == android.Mips64 { if !ctx.Config().EnableCFI() || ctx.Arch().ArchType == android.Mips || ctx.Arch().ArchType == android.Mips64 {
s.Cfi = nil s.Cfi = nil
s.Diag.Cfi = nil s.Diag.Cfi = nil
} }
@ -611,7 +611,7 @@ func sanitizerMutator(t sanitizerType) func(android.BottomUpMutatorContext) {
modules[1].(*Module).Properties.HideFromMake = true modules[1].(*Module).Properties.HideFromMake = true
} }
} else { } else {
cfiStaticLibs := cfiStaticLibs(mctx.AConfig()) cfiStaticLibs := cfiStaticLibs(mctx.Config())
cfiStaticLibsMutex.Lock() cfiStaticLibsMutex.Lock()
*cfiStaticLibs = append(*cfiStaticLibs, c.Name()) *cfiStaticLibs = append(*cfiStaticLibs, c.Name())

View File

@ -30,7 +30,7 @@ type stripper struct {
} }
func (stripper *stripper) needsStrip(ctx ModuleContext) bool { func (stripper *stripper) needsStrip(ctx ModuleContext) bool {
return !ctx.AConfig().EmbeddedInMake() && !Bool(stripper.StripProperties.Strip.None) return !ctx.Config().EmbeddedInMake() && !Bool(stripper.StripProperties.Strip.None)
} }
func (stripper *stripper) strip(ctx ModuleContext, in, out android.ModuleOutPath, func (stripper *stripper) strip(ctx ModuleContext, in, out android.ModuleOutPath,

View File

@ -58,7 +58,7 @@ func (tidy *tidyFeature) flags(ctx ModuleContext, flags Flags) Flags {
} }
// If not explicitly set, check the global tidy flag // If not explicitly set, check the global tidy flag
if tidy.Properties.Tidy == nil && !ctx.AConfig().ClangTidy() { if tidy.Properties.Tidy == nil && !ctx.Config().ClangTidy() {
return flags return flags
} }
@ -82,7 +82,7 @@ func (tidy *tidyFeature) flags(ctx ModuleContext, flags Flags) Flags {
flags.TidyFlags = append(flags.TidyFlags, "-extra-arg-before=-D__clang_analyzer__") flags.TidyFlags = append(flags.TidyFlags, "-extra-arg-before=-D__clang_analyzer__")
tidyChecks := "-checks=" tidyChecks := "-checks="
if checks := ctx.AConfig().TidyChecks(); len(checks) > 0 { if checks := ctx.Config().TidyChecks(); len(checks) > 0 {
tidyChecks += checks tidyChecks += checks
} else { } else {
tidyChecks += config.TidyChecksForDir(ctx.ModuleDir()) tidyChecks += config.TidyChecksForDir(ctx.ModuleDir())

View File

@ -134,7 +134,7 @@ func (g *Module) DepsMutator(ctx android.BottomUpMutatorContext) {
if g, ok := ctx.Module().(*Module); ok { if g, ok := ctx.Module().(*Module); ok {
if len(g.properties.Tools) > 0 { if len(g.properties.Tools) > 0 {
ctx.AddFarVariationDependencies([]blueprint.Variation{ ctx.AddFarVariationDependencies([]blueprint.Variation{
{"arch", ctx.AConfig().BuildOsVariant}, {"arch", ctx.Config().BuildOsVariant},
}, hostToolDepTag, g.properties.Tools...) }, hostToolDepTag, g.properties.Tools...)
} }
} }
@ -168,7 +168,7 @@ func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if t, ok := module.(HostToolProvider); ok { if t, ok := module.(HostToolProvider); ok {
if !t.(android.Module).Enabled() { if !t.(android.Module).Enabled() {
if ctx.AConfig().AllowMissingDependencies() { if ctx.Config().AllowMissingDependencies() {
ctx.AddMissingDependencies([]string{tool}) ctx.AddMissingDependencies([]string{tool})
} else { } else {
ctx.ModuleErrorf("depends on disabled module %q", tool) ctx.ModuleErrorf("depends on disabled module %q", tool)

View File

@ -120,9 +120,9 @@ func (a *AndroidApp) GenerateAndroidBuildActions(ctx android.ModuleContext) {
certificate := String(a.appProperties.Certificate) certificate := String(a.appProperties.Certificate)
if certificate == "" { if certificate == "" {
certificate = ctx.AConfig().DefaultAppCertificate(ctx).String() certificate = ctx.Config().DefaultAppCertificate(ctx).String()
} else if dir, _ := filepath.Split(certificate); dir == "" { } else if dir, _ := filepath.Split(certificate); dir == "" {
certificate = filepath.Join(ctx.AConfig().DefaultAppCertificateDir(ctx).String(), certificate) certificate = filepath.Join(ctx.Config().DefaultAppCertificateDir(ctx).String(), certificate)
} else { } else {
certificate = filepath.Join(android.PathForSource(ctx).String(), certificate) certificate = filepath.Join(android.PathForSource(ctx).String(), certificate)
} }
@ -236,34 +236,34 @@ func (a *AndroidApp) aapt2Flags(ctx android.ModuleContext) (flags []string, deps
sdkVersion := String(a.deviceProperties.Sdk_version) sdkVersion := String(a.deviceProperties.Sdk_version)
switch sdkVersion { switch sdkVersion {
case "", "current", "system_current", "test_current": case "", "current", "system_current", "test_current":
sdkVersion = ctx.AConfig().AppsDefaultVersionName() sdkVersion = ctx.Config().AppsDefaultVersionName()
} }
linkFlags = append(linkFlags, "--min-sdk-version "+sdkVersion) linkFlags = append(linkFlags, "--min-sdk-version "+sdkVersion)
linkFlags = append(linkFlags, "--target-sdk-version "+sdkVersion) linkFlags = append(linkFlags, "--target-sdk-version "+sdkVersion)
// Product characteristics // Product characteristics
if !hasProduct && len(ctx.AConfig().ProductAAPTCharacteristics()) > 0 { if !hasProduct && len(ctx.Config().ProductAAPTCharacteristics()) > 0 {
linkFlags = append(linkFlags, "--product", ctx.AConfig().ProductAAPTCharacteristics()) linkFlags = append(linkFlags, "--product", ctx.Config().ProductAAPTCharacteristics())
} }
// Product AAPT config // Product AAPT config
for _, aaptConfig := range ctx.AConfig().ProductAAPTConfig() { for _, aaptConfig := range ctx.Config().ProductAAPTConfig() {
linkFlags = append(linkFlags, "-c", aaptConfig) linkFlags = append(linkFlags, "-c", aaptConfig)
} }
// Product AAPT preferred config // Product AAPT preferred config
if len(ctx.AConfig().ProductAAPTPreferredConfig()) > 0 { if len(ctx.Config().ProductAAPTPreferredConfig()) > 0 {
linkFlags = append(linkFlags, "--preferred-density", ctx.AConfig().ProductAAPTPreferredConfig()) linkFlags = append(linkFlags, "--preferred-density", ctx.Config().ProductAAPTPreferredConfig())
} }
// Version code // Version code
if !hasVersionCode { if !hasVersionCode {
linkFlags = append(linkFlags, "--version-code", ctx.AConfig().PlatformSdkVersion()) linkFlags = append(linkFlags, "--version-code", ctx.Config().PlatformSdkVersion())
} }
if !hasVersionName { if !hasVersionName {
versionName := proptools.NinjaEscape([]string{ctx.AConfig().AppsDefaultVersionName()})[0] versionName := proptools.NinjaEscape([]string{ctx.Config().AppsDefaultVersionName()})[0]
linkFlags = append(linkFlags, "--version-name ", versionName) linkFlags = append(linkFlags, "--version-name ", versionName)
} }
@ -313,7 +313,7 @@ type overlayGlobResult struct {
const overlayDataKey = "overlayDataKey" const overlayDataKey = "overlayDataKey"
func overlayResourceGlob(ctx android.ModuleContext, dir android.Path) []globbedResourceDir { func overlayResourceGlob(ctx android.ModuleContext, dir android.Path) []globbedResourceDir {
overlayData := ctx.AConfig().Get(overlayDataKey).([]overlayGlobResult) overlayData := ctx.Config().Get(overlayDataKey).([]overlayGlobResult)
var ret []globbedResourceDir var ret []globbedResourceDir
@ -338,7 +338,7 @@ type overlaySingleton struct{}
func (overlaySingleton) GenerateBuildActions(ctx android.SingletonContext) { func (overlaySingleton) GenerateBuildActions(ctx android.SingletonContext) {
var overlayData []overlayGlobResult var overlayData []overlayGlobResult
for _, overlay := range ctx.Config().(android.Config).ResourceOverlays() { for _, overlay := range ctx.Config().ResourceOverlays() {
var result overlayGlobResult var result overlayGlobResult
result.dir = overlay result.dir = overlay
files, err := ctx.GlobWithDeps(filepath.Join(overlay, "**/*"), aaptIgnoreFilenames) files, err := ctx.GlobWithDeps(filepath.Join(overlay, "**/*"), aaptIgnoreFilenames)
@ -359,7 +359,7 @@ func (overlaySingleton) GenerateBuildActions(ctx android.SingletonContext) {
overlayData = append(overlayData, result) overlayData = append(overlayData, result)
} }
ctx.Config().(android.Config).Once(overlayDataKey, func() interface{} { ctx.Config().Once(overlayDataKey, func() interface{} {
return overlayData return overlayData
}) })
} }

View File

@ -386,7 +386,7 @@ func TransformDesugar(ctx android.ModuleContext, outputFile android.WritablePath
dumpDir := android.PathForModuleOut(ctx, "desugar", "classes") dumpDir := android.PathForModuleOut(ctx, "desugar", "classes")
javaFlags := "" javaFlags := ""
if ctx.AConfig().UseOpenJDK9() { if ctx.Config().UseOpenJDK9() {
javaFlags = "--add-opens java.base/java.lang.invoke=ALL-UNNAMED" javaFlags = "--add-opens java.base/java.lang.invoke=ALL-UNNAMED"
} }

View File

@ -271,7 +271,7 @@ func decodeSdkDep(ctx android.BaseContext, v string) sdkDep {
jarPath := android.ExistentPathForSource(ctx, "sdkdir", jar) jarPath := android.ExistentPathForSource(ctx, "sdkdir", jar)
aidlPath := android.ExistentPathForSource(ctx, "sdkdir", aidl) aidlPath := android.ExistentPathForSource(ctx, "sdkdir", aidl)
if (!jarPath.Valid() || !aidlPath.Valid()) && ctx.AConfig().AllowMissingDependencies() { if (!jarPath.Valid() || !aidlPath.Valid()) && ctx.Config().AllowMissingDependencies() {
return sdkDep{ return sdkDep{
invalidVersion: true, invalidVersion: true,
module: "sdk_v" + v, module: "sdk_v" + v,
@ -303,7 +303,7 @@ func decodeSdkDep(ctx android.BaseContext, v string) sdkDep {
// } // }
//} //}
if ctx.AConfig().UnbundledBuild() && v != "" { if ctx.Config().UnbundledBuild() && v != "" {
return toFile(v) return toFile(v)
} }
@ -331,14 +331,14 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
sdkDep := decodeSdkDep(ctx, String(j.deviceProperties.Sdk_version)) sdkDep := decodeSdkDep(ctx, String(j.deviceProperties.Sdk_version))
if sdkDep.useDefaultLibs { if sdkDep.useDefaultLibs {
ctx.AddDependency(ctx.Module(), bootClasspathTag, config.DefaultBootclasspathLibraries...) ctx.AddDependency(ctx.Module(), bootClasspathTag, config.DefaultBootclasspathLibraries...)
if ctx.AConfig().TargetOpenJDK9() { if ctx.Config().TargetOpenJDK9() {
ctx.AddDependency(ctx.Module(), systemModulesTag, config.DefaultSystemModules) ctx.AddDependency(ctx.Module(), systemModulesTag, config.DefaultSystemModules)
} }
if !proptools.Bool(j.properties.No_framework_libs) { if !proptools.Bool(j.properties.No_framework_libs) {
ctx.AddDependency(ctx.Module(), libTag, config.DefaultLibraries...) ctx.AddDependency(ctx.Module(), libTag, config.DefaultLibraries...)
} }
} else if sdkDep.useModule { } else if sdkDep.useModule {
if ctx.AConfig().TargetOpenJDK9() { if ctx.Config().TargetOpenJDK9() {
ctx.AddDependency(ctx.Module(), systemModulesTag, sdkDep.systemModules) ctx.AddDependency(ctx.Module(), systemModulesTag, sdkDep.systemModules)
} }
ctx.AddDependency(ctx.Module(), bootClasspathTag, sdkDep.module) ctx.AddDependency(ctx.Module(), bootClasspathTag, sdkDep.module)
@ -346,7 +346,7 @@ func (j *Module) deps(ctx android.BottomUpMutatorContext) {
} else if j.deviceProperties.System_modules == nil { } else if j.deviceProperties.System_modules == nil {
ctx.PropertyErrorf("no_standard_libs", ctx.PropertyErrorf("no_standard_libs",
"system_modules is required to be set when no_standard_libs is true, did you mean no_framework_libs?") "system_modules is required to be set when no_standard_libs is true, did you mean no_framework_libs?")
} else if *j.deviceProperties.System_modules != "none" && ctx.AConfig().TargetOpenJDK9() { } else if *j.deviceProperties.System_modules != "none" && ctx.Config().TargetOpenJDK9() {
ctx.AddDependency(ctx.Module(), systemModulesTag, *j.deviceProperties.System_modules) ctx.AddDependency(ctx.Module(), systemModulesTag, *j.deviceProperties.System_modules)
} }
} }
@ -503,10 +503,10 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB
// javac flags. // javac flags.
javacFlags := j.properties.Javacflags javacFlags := j.properties.Javacflags
if ctx.AConfig().TargetOpenJDK9() { if ctx.Config().TargetOpenJDK9() {
javacFlags = append(javacFlags, j.properties.Openjdk9.Javacflags...) javacFlags = append(javacFlags, j.properties.Openjdk9.Javacflags...)
} }
if ctx.AConfig().MinimizeJavaDebugInfo() { if ctx.Config().MinimizeJavaDebugInfo() {
// Override the -g flag passed globally to remove local variable debug info to reduce // Override the -g flag passed globally to remove local variable debug info to reduce
// disk and memory usage. // disk and memory usage.
javacFlags = append(javacFlags, "-g:source,lines") javacFlags = append(javacFlags, "-g:source,lines")
@ -523,7 +523,7 @@ func (j *Module) collectBuilderFlags(ctx android.ModuleContext, deps deps) javaB
flags.javaVersion = *j.properties.Java_version flags.javaVersion = *j.properties.Java_version
} else if ctx.Device() && sdk <= 23 { } else if ctx.Device() && sdk <= 23 {
flags.javaVersion = "1.7" flags.javaVersion = "1.7"
} else if ctx.Device() && sdk <= 26 || !ctx.AConfig().TargetOpenJDK9() { } else if ctx.Device() && sdk <= 26 || !ctx.Config().TargetOpenJDK9() {
flags.javaVersion = "1.8" flags.javaVersion = "1.8"
} else if ctx.Device() && String(j.deviceProperties.Sdk_version) != "" && sdk == 10000 { } else if ctx.Device() && String(j.deviceProperties.Sdk_version) != "" && sdk == 10000 {
// TODO(ccross): once we generate stubs we should be able to use 1.9 for sdk_version: "current" // TODO(ccross): once we generate stubs we should be able to use 1.9 for sdk_version: "current"
@ -558,7 +558,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
deps := j.collectDeps(ctx) deps := j.collectDeps(ctx)
flags := j.collectBuilderFlags(ctx, deps) flags := j.collectBuilderFlags(ctx, deps)
if ctx.AConfig().TargetOpenJDK9() { if ctx.Config().TargetOpenJDK9() {
j.properties.Srcs = append(j.properties.Srcs, j.properties.Openjdk9.Srcs...) j.properties.Srcs = append(j.properties.Srcs, j.properties.Openjdk9.Srcs...)
} }
srcFiles := ctx.ExpandSources(j.properties.Srcs, j.properties.Exclude_srcs) srcFiles := ctx.ExpandSources(j.properties.Srcs, j.properties.Exclude_srcs)
@ -613,7 +613,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
} }
enable_sharding := false enable_sharding := false
if ctx.Device() && !ctx.AConfig().IsEnvFalse("TURBINE_ENABLED") { if ctx.Device() && !ctx.Config().IsEnvFalse("TURBINE_ENABLED") {
if j.properties.Javac_shard_size != nil && *(j.properties.Javac_shard_size) > 0 { if j.properties.Javac_shard_size != nil && *(j.properties.Javac_shard_size) > 0 {
enable_sharding = true enable_sharding = true
if len(j.properties.Annotation_processors) != 0 || if len(j.properties.Annotation_processors) != 0 ||
@ -634,7 +634,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
} }
if len(uniqueSrcFiles) > 0 || len(srcJars) > 0 { if len(uniqueSrcFiles) > 0 || len(srcJars) > 0 {
var extraJarDeps android.Paths var extraJarDeps android.Paths
if ctx.AConfig().IsEnvTrue("RUN_ERROR_PRONE") { if ctx.Config().IsEnvTrue("RUN_ERROR_PRONE") {
// If error-prone is enabled, add an additional rule to compile the java files into // If error-prone is enabled, add an additional rule to compile the java files into
// a separate set of classes (so that they don't overwrite the normal ones and require // a separate set of classes (so that they don't overwrite the normal ones and require
// a rebuild when error-prone is turned off). // a rebuild when error-prone is turned off).
@ -737,13 +737,13 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
outputFile = j.desugar(ctx, flags, outputFile, jarName) outputFile = j.desugar(ctx, flags, outputFile, jarName)
} }
if ctx.AConfig().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") { if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT_FRAMEWORK") {
if inList(ctx.ModuleName(), config.InstrumentFrameworkModules) { if inList(ctx.ModuleName(), config.InstrumentFrameworkModules) {
j.properties.Instrument = true j.properties.Instrument = true
} }
} }
if ctx.AConfig().IsEnvTrue("EMMA_INSTRUMENT") && j.properties.Instrument { if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT") && j.properties.Instrument {
outputFile = j.instrument(ctx, flags, outputFile, jarName) outputFile = j.instrument(ctx, flags, outputFile, jarName)
} }
@ -846,11 +846,11 @@ func (j *Module) compileDex(ctx android.ModuleContext, flags javaBuilderFlags,
dxFlags = append(dxFlags, "--no-locals") dxFlags = append(dxFlags, "--no-locals")
} }
if ctx.AConfig().Getenv("NO_OPTIMIZE_DX") != "" { if ctx.Config().Getenv("NO_OPTIMIZE_DX") != "" {
dxFlags = append(dxFlags, "--no-optimize") dxFlags = append(dxFlags, "--no-optimize")
} }
if ctx.AConfig().Getenv("GENERATE_DEX_DEBUG") != "" { if ctx.Config().Getenv("GENERATE_DEX_DEBUG") != "" {
dxFlags = append(dxFlags, dxFlags = append(dxFlags,
"--debug", "--debug",
"--verbose", "--verbose",
@ -875,7 +875,7 @@ func (j *Module) compileDex(ctx android.ModuleContext, flags javaBuilderFlags,
func (j *Module) minSdkVersionNumber(ctx android.ModuleContext) string { func (j *Module) minSdkVersionNumber(ctx android.ModuleContext) string {
switch String(j.deviceProperties.Sdk_version) { switch String(j.deviceProperties.Sdk_version) {
case "", "current", "test_current", "system_current": case "", "current", "test_current", "system_current":
return strconv.Itoa(ctx.AConfig().DefaultAppTargetSdkInt()) return strconv.Itoa(ctx.Config().DefaultAppTargetSdkInt())
default: default:
return String(j.deviceProperties.Sdk_version) return String(j.deviceProperties.Sdk_version)
} }

View File

@ -121,7 +121,7 @@ func (system *SystemModules) GenerateAndroidBuildActions(ctx android.ModuleConte
jars = append(jars, android.PathsForModuleSrc(ctx, system.properties.Jars)...) jars = append(jars, android.PathsForModuleSrc(ctx, system.properties.Jars)...)
if ctx.AConfig().TargetOpenJDK9() { if ctx.Config().TargetOpenJDK9() {
system.outputFile = TransformJarsToSystemModules(ctx, "java.base", jars) system.outputFile = TransformJarsToSystemModules(ctx, "java.base", jars)
} }
} }