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)
|
||||
}
|
||||
|
||||
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] {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
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)
|
||||
|
||||
// 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 {
|
||||
|
|
Loading…
Reference in a new issue