aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2018-03-12 15:30:26 -0700
committerDan Willemsen <dwillemsen@google.com>2018-04-17 10:34:23 -0700
commit050ca73dbfdd360a209daf93a6f7d059a8705569 (patch)
tree3332693a54c93fb13b220f44ea3a5ea7e171a65a
parente9216117dd376aa48476c0ef448fcbd818961861 (diff)
downloadbuild_soong-050ca73dbfdd360a209daf93a6f7d059a8705569.tar.gz
build_soong-050ca73dbfdd360a209daf93a6f7d059a8705569.tar.bz2
build_soong-050ca73dbfdd360a209daf93a6f7d059a8705569.zip
Use Config/DeviceConfig functions to access ProductVariables
An upcoming change will stop exporting ProductVariables from Config, so switch to using existing accessor functions, and add more when they're missing. Bug: 76168832 Test: out/soong/build.ninja is identical Change-Id: Ie0135bdbd2df3258ef3ddb53e5f8fc00aa9b97f7 Merged-In: Ie0135bdbd2df3258ef3ddb53e5f8fc00aa9b97f7 (cherry picked from commit 3fb1faeeb98143e132ca4d6f1cac42d6f060888b)
-rw-r--r--android/config.go31
-rw-r--r--android/makevars.go5
-rw-r--r--cc/binary.go2
-rw-r--r--cc/makevars.go8
-rw-r--r--cmd/soong_build/main.go2
-rw-r--r--java/app.go24
6 files changed, 43 insertions, 29 deletions
diff --git a/android/config.go b/android/config.go
index db833eca..e14f42ee 100644
--- a/android/config.go
+++ b/android/config.go
@@ -641,6 +641,37 @@ func (c *config) ArtUseReadBarrier() bool {
return Bool(c.ProductVariables.ArtUseReadBarrier)
}
+func (c *config) EnforceRROForModule(name string) bool {
+ enforceList := c.ProductVariables.EnforceRROTargets
+ if enforceList != nil {
+ if len(*enforceList) == 1 && (*enforceList)[0] == "*" {
+ return true
+ }
+ return InList(name, *enforceList)
+ }
+ return false
+}
+
+func (c *config) EnforceRROExcludedOverlay(path string) bool {
+ excluded := c.ProductVariables.EnforceRROExcludedOverlays
+ if excluded != nil {
+ for _, exclude := range *excluded {
+ if strings.HasPrefix(path, exclude) {
+ return true
+ }
+ }
+ }
+ return false
+}
+
+func (c *config) ExportedNamespaces() []string {
+ return append([]string(nil), c.ProductVariables.NamespacesToExport...)
+}
+
+func (c *config) HostStaticBinaries() bool {
+ return Bool(c.ProductVariables.HostStaticBinaries)
+}
+
func (c *deviceConfig) Arches() []Arch {
var arches []Arch
for _, target := range c.config.Targets[Device] {
diff --git a/android/makevars.go b/android/makevars.go
index b6cd571f..37923575 100644
--- a/android/makevars.go
+++ b/android/makevars.go
@@ -36,6 +36,7 @@ func androidMakeVarsProvider(ctx MakeVarsContext) {
// Interface for other packages to use to declare make variables
type MakeVarsContext interface {
Config() Config
+ DeviceConfig() DeviceConfig
SingletonContext() SingletonContext
// Verify the make variable matches the Soong version, fail the build
@@ -231,6 +232,10 @@ func (c *makeVarsContext) Config() Config {
return c.config
}
+func (c *makeVarsContext) DeviceConfig() DeviceConfig {
+ return DeviceConfig{c.config.deviceConfig}
+}
+
func (c *makeVarsContext) SingletonContext() SingletonContext {
return c.ctx
}
diff --git a/cc/binary.go b/cc/binary.go
index c3e899a0..9e7b70b2 100644
--- a/cc/binary.go
+++ b/cc/binary.go
@@ -192,7 +192,7 @@ func (binary *binaryDecorator) linkerInit(ctx BaseModuleContext) {
if !ctx.toolchain().Bionic() {
if ctx.Os() == android.Linux {
- if binary.Properties.Static_executable == nil && Bool(ctx.Config().ProductVariables.HostStaticBinaries) {
+ if binary.Properties.Static_executable == nil && ctx.Config().HostStaticBinaries() {
binary.Properties.Static_executable = BoolPtr(true)
}
} else {
diff --git a/cc/makevars.go b/cc/makevars.go
index b87494e6..3bb00a1a 100644
--- a/cc/makevars.go
+++ b/cc/makevars.go
@@ -89,11 +89,7 @@ func makeVarsProvider(ctx android.MakeVarsContext) {
ctx.Strict("GLOBAL_CLANG_CPPFLAGS_NO_OVERRIDE", "")
ctx.Strict("NDK_PREBUILT_SHARED_LIBRARIES", strings.Join(ndkPrebuiltSharedLibs, " "))
- if ctx.Config().ProductVariables.DeviceVndkVersion != nil {
- ctx.Strict("BOARD_VNDK_VERSION", *ctx.Config().ProductVariables.DeviceVndkVersion)
- } else {
- ctx.Strict("BOARD_VNDK_VERSION", "")
- }
+ ctx.Strict("BOARD_VNDK_VERSION", ctx.DeviceConfig().VndkVersion())
ctx.Strict("VNDK_CORE_LIBRARIES", strings.Join(vndkCoreLibraries, " "))
ctx.Strict("VNDK_SAMEPROCESS_LIBRARIES", strings.Join(vndkSpLibraries, " "))
@@ -211,7 +207,7 @@ func makeVarsToolchain(ctx android.MakeVarsContext, secondPrefix string,
hod = "Device"
}
- if target.Os.Class == android.Host && Bool(ctx.Config().ProductVariables.HostStaticBinaries) {
+ if target.Os.Class == android.Host && ctx.Config().HostStaticBinaries() {
productExtraLdflags += "-static"
}
diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go
index 40beab8c..a4c6898d 100644
--- a/cmd/soong_build/main.go
+++ b/cmd/soong_build/main.go
@@ -36,7 +36,7 @@ func init() {
func newNameResolver(config android.Config) *android.NameResolver {
namespacePathsToExport := make(map[string]bool)
- for _, namespaceName := range config.ProductVariables.NamespacesToExport {
+ for _, namespaceName := range config.ExportedNamespaces() {
namespacePathsToExport[namespaceName] = true
}
diff --git a/java/app.go b/java/app.go
index ac88df79..c94d22f0 100644
--- a/java/app.go
+++ b/java/app.go
@@ -362,15 +362,7 @@ func overlayResourceGlob(ctx android.ModuleContext, dir android.Path) (res []glo
overlayData := ctx.Config().Get(overlayDataKey).([]overlayGlobResult)
// Runtime resource overlays (RRO) may be turned on by the product config for some modules
- rroEnabled := false
- enforceRROTargets := ctx.Config().ProductVariables.EnforceRROTargets
- if enforceRROTargets != nil {
- if len(*enforceRROTargets) == 1 && (*enforceRROTargets)[0] == "*" {
- rroEnabled = true
- } else if inList(ctx.ModuleName(), *enforceRROTargets) {
- rroEnabled = true
- }
- }
+ rroEnabled := ctx.Config().EnforceRROForModule(ctx.ModuleName())
for _, data := range overlayData {
files := data.paths.PathsInDirectory(filepath.Join(data.dir, dir.String()))
@@ -400,13 +392,6 @@ func OverlaySingletonFactory() android.Singleton {
type overlaySingleton struct{}
func (overlaySingleton) GenerateBuildActions(ctx android.SingletonContext) {
-
- // Specific overlays may be excluded from Runtime Resource Overlays by the product config
- var rroExcludedOverlays []string
- if ctx.Config().ProductVariables.EnforceRROExcludedOverlays != nil {
- rroExcludedOverlays = *ctx.Config().ProductVariables.EnforceRROExcludedOverlays
- }
-
var overlayData []overlayGlobResult
overlayDirs := ctx.Config().ResourceOverlays()
for i := range overlayDirs {
@@ -417,11 +402,8 @@ func (overlaySingleton) GenerateBuildActions(ctx android.SingletonContext) {
result.dir = overlay
// Mark overlays that will not have Runtime Resource Overlays enforced on them
- for _, exclude := range rroExcludedOverlays {
- if strings.HasPrefix(overlay, exclude) {
- result.excludeFromRRO = true
- }
- }
+ // based on the product config
+ result.excludeFromRRO = ctx.Config().EnforceRROExcludedOverlay(overlay)
files, err := ctx.GlobWithDeps(filepath.Join(overlay, "**/*"), aaptIgnoreFilenames)
if err != nil {