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
This commit is contained in:
parent
47f98af97f
commit
3fb1faeeb9
6 changed files with 43 additions and 29 deletions
|
@ -641,6 +641,37 @@ func (c *config) ArtUseReadBarrier() bool {
|
||||||
return Bool(c.ProductVariables.ArtUseReadBarrier)
|
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 {
|
func (c *deviceConfig) Arches() []Arch {
|
||||||
var arches []Arch
|
var arches []Arch
|
||||||
for _, target := range c.config.Targets[Device] {
|
for _, target := range c.config.Targets[Device] {
|
||||||
|
|
|
@ -36,6 +36,7 @@ func androidMakeVarsProvider(ctx MakeVarsContext) {
|
||||||
// Interface for other packages to use to declare make variables
|
// Interface for other packages to use to declare make variables
|
||||||
type MakeVarsContext interface {
|
type MakeVarsContext interface {
|
||||||
Config() Config
|
Config() Config
|
||||||
|
DeviceConfig() DeviceConfig
|
||||||
SingletonContext() SingletonContext
|
SingletonContext() SingletonContext
|
||||||
|
|
||||||
// Verify the make variable matches the Soong version, fail the build
|
// Verify the make variable matches the Soong version, fail the build
|
||||||
|
@ -231,6 +232,10 @@ func (c *makeVarsContext) Config() Config {
|
||||||
return c.config
|
return c.config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *makeVarsContext) DeviceConfig() DeviceConfig {
|
||||||
|
return DeviceConfig{c.config.deviceConfig}
|
||||||
|
}
|
||||||
|
|
||||||
func (c *makeVarsContext) SingletonContext() SingletonContext {
|
func (c *makeVarsContext) SingletonContext() SingletonContext {
|
||||||
return c.ctx
|
return c.ctx
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,7 +192,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.Config().ProductVariables.HostStaticBinaries) {
|
if binary.Properties.Static_executable == nil && ctx.Config().HostStaticBinaries() {
|
||||||
binary.Properties.Static_executable = BoolPtr(true)
|
binary.Properties.Static_executable = BoolPtr(true)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -89,11 +89,7 @@ func makeVarsProvider(ctx android.MakeVarsContext) {
|
||||||
ctx.Strict("GLOBAL_CLANG_CPPFLAGS_NO_OVERRIDE", "")
|
ctx.Strict("GLOBAL_CLANG_CPPFLAGS_NO_OVERRIDE", "")
|
||||||
ctx.Strict("NDK_PREBUILT_SHARED_LIBRARIES", strings.Join(ndkPrebuiltSharedLibs, " "))
|
ctx.Strict("NDK_PREBUILT_SHARED_LIBRARIES", strings.Join(ndkPrebuiltSharedLibs, " "))
|
||||||
|
|
||||||
if ctx.Config().ProductVariables.DeviceVndkVersion != nil {
|
ctx.Strict("BOARD_VNDK_VERSION", ctx.DeviceConfig().VndkVersion())
|
||||||
ctx.Strict("BOARD_VNDK_VERSION", *ctx.Config().ProductVariables.DeviceVndkVersion)
|
|
||||||
} else {
|
|
||||||
ctx.Strict("BOARD_VNDK_VERSION", "")
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.Strict("VNDK_CORE_LIBRARIES", strings.Join(vndkCoreLibraries, " "))
|
ctx.Strict("VNDK_CORE_LIBRARIES", strings.Join(vndkCoreLibraries, " "))
|
||||||
ctx.Strict("VNDK_SAMEPROCESS_LIBRARIES", strings.Join(vndkSpLibraries, " "))
|
ctx.Strict("VNDK_SAMEPROCESS_LIBRARIES", strings.Join(vndkSpLibraries, " "))
|
||||||
|
@ -211,7 +207,7 @@ func makeVarsToolchain(ctx android.MakeVarsContext, secondPrefix string,
|
||||||
hod = "Device"
|
hod = "Device"
|
||||||
}
|
}
|
||||||
|
|
||||||
if target.Os.Class == android.Host && Bool(ctx.Config().ProductVariables.HostStaticBinaries) {
|
if target.Os.Class == android.Host && ctx.Config().HostStaticBinaries() {
|
||||||
productExtraLdflags += "-static"
|
productExtraLdflags += "-static"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ func init() {
|
||||||
func newNameResolver(config android.Config) *android.NameResolver {
|
func newNameResolver(config android.Config) *android.NameResolver {
|
||||||
namespacePathsToExport := make(map[string]bool)
|
namespacePathsToExport := make(map[string]bool)
|
||||||
|
|
||||||
for _, namespaceName := range config.ProductVariables.NamespacesToExport {
|
for _, namespaceName := range config.ExportedNamespaces() {
|
||||||
namespacePathsToExport[namespaceName] = true
|
namespacePathsToExport[namespaceName] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
24
java/app.go
24
java/app.go
|
@ -362,15 +362,7 @@ func overlayResourceGlob(ctx android.ModuleContext, dir android.Path) (res []glo
|
||||||
overlayData := ctx.Config().Get(overlayDataKey).([]overlayGlobResult)
|
overlayData := ctx.Config().Get(overlayDataKey).([]overlayGlobResult)
|
||||||
|
|
||||||
// Runtime resource overlays (RRO) may be turned on by the product config for some modules
|
// Runtime resource overlays (RRO) may be turned on by the product config for some modules
|
||||||
rroEnabled := false
|
rroEnabled := ctx.Config().EnforceRROForModule(ctx.ModuleName())
|
||||||
enforceRROTargets := ctx.Config().ProductVariables.EnforceRROTargets
|
|
||||||
if enforceRROTargets != nil {
|
|
||||||
if len(*enforceRROTargets) == 1 && (*enforceRROTargets)[0] == "*" {
|
|
||||||
rroEnabled = true
|
|
||||||
} else if inList(ctx.ModuleName(), *enforceRROTargets) {
|
|
||||||
rroEnabled = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, data := range overlayData {
|
for _, data := range overlayData {
|
||||||
files := data.paths.PathsInDirectory(filepath.Join(data.dir, dir.String()))
|
files := data.paths.PathsInDirectory(filepath.Join(data.dir, dir.String()))
|
||||||
|
@ -400,13 +392,6 @@ func OverlaySingletonFactory() android.Singleton {
|
||||||
type overlaySingleton struct{}
|
type overlaySingleton struct{}
|
||||||
|
|
||||||
func (overlaySingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
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
|
var overlayData []overlayGlobResult
|
||||||
overlayDirs := ctx.Config().ResourceOverlays()
|
overlayDirs := ctx.Config().ResourceOverlays()
|
||||||
for i := range overlayDirs {
|
for i := range overlayDirs {
|
||||||
|
@ -417,11 +402,8 @@ func (overlaySingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
||||||
result.dir = overlay
|
result.dir = overlay
|
||||||
|
|
||||||
// Mark overlays that will not have Runtime Resource Overlays enforced on them
|
// Mark overlays that will not have Runtime Resource Overlays enforced on them
|
||||||
for _, exclude := range rroExcludedOverlays {
|
// based on the product config
|
||||||
if strings.HasPrefix(overlay, exclude) {
|
result.excludeFromRRO = ctx.Config().EnforceRROExcludedOverlay(overlay)
|
||||||
result.excludeFromRRO = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
files, err := ctx.GlobWithDeps(filepath.Join(overlay, "**/*"), aaptIgnoreFilenames)
|
files, err := ctx.GlobWithDeps(filepath.Join(overlay, "**/*"), aaptIgnoreFilenames)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue