summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
Diffstat (limited to 'android')
-rw-r--r--android/Android.bp5
-rw-r--r--android/aconfig_providers.go2
-rw-r--r--android/all_teams.go2
-rw-r--r--android/androidmk.go13
-rw-r--r--android/arch_list.go8
-rw-r--r--android/base_module_context.go4
-rw-r--r--android/compliance_metadata.go2
-rw-r--r--android/config.go163
-rw-r--r--android/config_test.go69
-rw-r--r--android/configurable_properties.go3
-rw-r--r--android/configured_jars.go2
-rw-r--r--android/container.go2
-rw-r--r--android/early_module_context.go7
-rw-r--r--android/filegroup.go52
-rw-r--r--android/gen_notice.go2
-rw-r--r--android/license_metadata.go2
-rw-r--r--android/logtags.go2
-rw-r--r--android/makevars.go2
-rw-r--r--android/module.go49
-rw-r--r--android/module_proxy.go8
-rw-r--r--android/neverallow.go5
-rw-r--r--android/otatools_package_cert_zip.go62
-rw-r--r--android/override_module.go1
-rw-r--r--android/package.go2
-rw-r--r--android/packaging.go41
-rw-r--r--android/paths.go4
-rw-r--r--android/prebuilt.go4
-rw-r--r--android/provider.go8
-rw-r--r--android/selects_test.go78
-rw-r--r--android/test_config.go17
-rw-r--r--android/testing.go6
-rw-r--r--android/variable.go10
-rw-r--r--android/visibility.go2
33 files changed, 486 insertions, 153 deletions
diff --git a/android/Android.bp b/android/Android.bp
index 4b75148fc..71e674767 100644
--- a/android/Android.bp
+++ b/android/Android.bp
@@ -83,6 +83,7 @@ bootstrap_go_package {
"nothing.go",
"notices.go",
"onceper.go",
+ "otatools_package_cert_zip.go",
"override_module.go",
"package.go",
"package_ctx.go",
@@ -171,7 +172,3 @@ bootstrap_go_package {
// Used by plugins
visibility: ["//visibility:public"],
}
-
-otatools_package_filegroup {
- name: "otatools_package_filegroup",
-}
diff --git a/android/aconfig_providers.go b/android/aconfig_providers.go
index 9c71d927d..bb73f0bdd 100644
--- a/android/aconfig_providers.go
+++ b/android/aconfig_providers.go
@@ -248,7 +248,7 @@ func getContainer(m Module) string {
// Please only access the module's internal data through providers.
func getContainerUsingProviders(ctx OtherModuleProviderContext, m Module) string {
container := "system"
- commonInfo, _ := OtherModuleProvider(ctx, m, CommonModuleInfoProvider)
+ commonInfo := OtherModulePointerProviderOrDefault(ctx, m, CommonModuleInfoProvider)
if commonInfo.Vendor || commonInfo.Proprietary || commonInfo.SocSpecific {
container = "vendor"
} else if commonInfo.ProductSpecific {
diff --git a/android/all_teams.go b/android/all_teams.go
index 5e76e53bf..18a050f5d 100644
--- a/android/all_teams.go
+++ b/android/all_teams.go
@@ -116,7 +116,7 @@ func (t *allTeamsSingleton) GenerateBuildActions(ctx SingletonContext) {
testOnly: testModInfo.TestOnly,
topLevelTestTarget: testModInfo.TopLevelTarget,
kind: ctx.ModuleType(module),
- teamName: OtherModuleProviderOrDefault(ctx, module, CommonModuleInfoProvider).Team,
+ teamName: OtherModulePointerProviderOrDefault(ctx, module, CommonModuleInfoProvider).Team,
}
t.teams_for_mods[module.Name()] = entry
diff --git a/android/androidmk.go b/android/androidmk.go
index 694f5d66b..7cc6aef00 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -510,6 +510,9 @@ func (a *AndroidMkEntries) fillInEntries(ctx fillInEntriesContext, mod Module) {
a.EntryMap = make(map[string][]string)
base := mod.base()
name := base.BaseModuleName()
+ if bmn, ok := mod.(baseModuleName); ok {
+ name = bmn.BaseModuleName()
+ }
if a.OverrideName != "" {
name = a.OverrideName
}
@@ -888,14 +891,14 @@ func getSoongOnlyDataFromMods(ctx fillInEntriesContext, mods []Module) ([]distCo
}
}
- commonInfo, _ := OtherModuleProvider(ctx, mod, CommonModuleInfoProvider)
+ commonInfo := OtherModulePointerProviderOrDefault(ctx, mod, CommonModuleInfoProvider)
if commonInfo.SkipAndroidMkProcessing {
continue
}
if info, ok := OtherModuleProvider(ctx, mod, AndroidMkInfoProvider); ok {
// Deep copy the provider info since we need to modify the info later
info := deepCopyAndroidMkProviderInfo(info)
- info.PrimaryInfo.fillInEntries(ctx, mod, &commonInfo)
+ info.PrimaryInfo.fillInEntries(ctx, mod, commonInfo)
if info.PrimaryInfo.disabled() {
continue
}
@@ -1320,7 +1323,7 @@ var AndroidMkInfoProvider = blueprint.NewProvider[*AndroidMkProviderInfo]()
// Please only access the module's internal data through providers.
func translateAndroidMkEntriesInfoModule(ctx SingletonContext, w io.Writer, moduleInfoJSONs *[]*ModuleInfoJSON,
mod Module, providerInfo *AndroidMkProviderInfo) error {
- commonInfo, _ := OtherModuleProvider(ctx, mod, CommonModuleInfoProvider)
+ commonInfo := OtherModulePointerProviderOrDefault(ctx, mod, CommonModuleInfoProvider)
if commonInfo.SkipAndroidMkProcessing {
return nil
}
@@ -1331,11 +1334,11 @@ func translateAndroidMkEntriesInfoModule(ctx SingletonContext, w io.Writer, modu
aconfigUpdateAndroidMkInfos(ctx, mod, &info)
// Any new or special cases here need review to verify correct propagation of license information.
- info.PrimaryInfo.fillInEntries(ctx, mod, &commonInfo)
+ info.PrimaryInfo.fillInEntries(ctx, mod, commonInfo)
info.PrimaryInfo.write(w)
if len(info.ExtraInfo) > 0 {
for _, ei := range info.ExtraInfo {
- ei.fillInEntries(ctx, mod, &commonInfo)
+ ei.fillInEntries(ctx, mod, commonInfo)
ei.write(w)
}
}
diff --git a/android/arch_list.go b/android/arch_list.go
index 389f194e8..8659549ca 100644
--- a/android/arch_list.go
+++ b/android/arch_list.go
@@ -27,6 +27,8 @@ var archVariants = map[ArchType][]string{
"armv8-2a-dotprod",
"armv9-a",
"armv9-2a",
+ "armv9-3a",
+ "armv9-4a",
},
X86: {
"alderlake",
@@ -151,6 +153,12 @@ var androidArchFeatureMap = map[ArchType]map[string][]string{
"armv9-2a": {
"dotprod",
},
+ "armv9-3a": {
+ "dotprod",
+ },
+ "armv9-4a": {
+ "dotprod",
+ },
},
X86: {
"alderlake": {
diff --git a/android/base_module_context.go b/android/base_module_context.go
index eba367034..5cb9e71cf 100644
--- a/android/base_module_context.go
+++ b/android/base_module_context.go
@@ -410,7 +410,7 @@ func (b *baseModuleContext) validateAndroidModuleProxy(
return &aModule
}
- if !OtherModuleProviderOrDefault(b, module, CommonModuleInfoProvider).Enabled {
+ if !OtherModulePointerProviderOrDefault(b, module, CommonModuleInfoProvider).Enabled {
if t, ok := tag.(AllowDisabledModuleDependency); !ok || !t.AllowDisabledModuleDependencyProxy(b, aModule) {
if b.Config().AllowMissingDependencies() {
b.AddMissingDependencies([]string{b.OtherModuleName(aModule)})
@@ -440,7 +440,7 @@ func (b *baseModuleContext) getDirectDepsInternal(name string, tag blueprint.Dep
func (b *baseModuleContext) getDirectDepsProxyInternal(name string, tag blueprint.DependencyTag) []ModuleProxy {
var deps []ModuleProxy
b.VisitDirectDepsProxy(func(module ModuleProxy) {
- if OtherModuleProviderOrDefault(b, module, CommonModuleInfoProvider).BaseModuleName == name {
+ if OtherModulePointerProviderOrDefault(b, module, CommonModuleInfoProvider).BaseModuleName == name {
returnedTag := b.OtherModuleDependencyTag(module)
if tag == nil || returnedTag == tag {
deps = append(deps, module)
diff --git a/android/compliance_metadata.go b/android/compliance_metadata.go
index c15a206ec..16a385300 100644
--- a/android/compliance_metadata.go
+++ b/android/compliance_metadata.go
@@ -304,7 +304,7 @@ func (c *complianceMetadataSingleton) GenerateBuildActions(ctx SingletonContext)
rowId := -1
ctx.VisitAllModuleProxies(func(module ModuleProxy) {
- commonInfo, _ := OtherModuleProvider(ctx, module, CommonModuleInfoProvider)
+ commonInfo := OtherModulePointerProviderOrDefault(ctx, module, CommonModuleInfoProvider)
if !commonInfo.Enabled {
return
}
diff --git a/android/config.go b/android/config.go
index 885960bd3..52d7f3b41 100644
--- a/android/config.go
+++ b/android/config.go
@@ -22,6 +22,7 @@ import (
"fmt"
"os"
"path/filepath"
+ "reflect"
"runtime"
"strconv"
"strings"
@@ -108,6 +109,10 @@ const (
const testKeyDir = "build/make/target/product/security"
+func (c Config) genericConfig() Config {
+ return Config{c.config.genericConfig}
+}
+
// SoongOutDir returns the build output directory for the configuration.
func (c Config) SoongOutDir() string {
return c.soongOutDir
@@ -238,11 +243,6 @@ func (c Config) ReleaseAconfigFlagDefaultPermission() string {
return c.config.productVariables.ReleaseAconfigFlagDefaultPermission
}
-// Enable object size sanitizer
-func (c Config) ReleaseBuildObjectSizeSanitizer() bool {
- return c.config.productVariables.GetBuildFlagBool("RELEASE_BUILD_OBJECT_SIZE_SANITIZER")
-}
-
// The flag indicating behavior for the tree wrt building modules or using prebuilts
// derived from RELEASE_DEFAULT_MODULE_BUILD_FROM_SOURCE
func (c Config) ReleaseDefaultModuleBuildFromSource() bool {
@@ -377,7 +377,7 @@ type config struct {
// regenerate build.ninja.
ninjaFileDepsSet sync.Map
- OncePer
+ *OncePer
// If buildFromSourceStub is true then the Java API stubs are
// built from the source Java files, not the signature text files.
@@ -387,6 +387,17 @@ type config struct {
// modules that aren't mixed-built for at least one variant will cause a build
// failure
ensureAllowlistIntegrity bool
+
+ // If isGeneric is true, this config is the generic config.
+ isGeneric bool
+
+ // InstallPath requires the device name.
+ // This is only for the installPath.
+ deviceNameToInstall *string
+
+ // Copy of this config struct but some product-specific variables are
+ // replaced with the generic configuration values.
+ genericConfig *config
}
type partialCompileFlags struct {
@@ -644,11 +655,9 @@ func NullConfig(outDir, soongOutDir string) Config {
}
}
-// NewConfig creates a new Config object. The srcDir argument specifies the path
-// to the root source directory. It also loads the config file, if found.
-func NewConfig(cmdArgs CmdArgs, availableEnv map[string]string) (Config, error) {
+func initConfig(cmdArgs CmdArgs, availableEnv map[string]string) (*config, error) {
// Make a config with default options.
- config := &config{
+ newConfig := &config{
ProductVariablesFileName: cmdArgs.SoongVariables,
env: availableEnv,
@@ -662,70 +671,72 @@ func NewConfig(cmdArgs CmdArgs, availableEnv map[string]string) (Config, error)
moduleListFile: cmdArgs.ModuleListFile,
fs: pathtools.NewOsFs(absSrcDir),
+ OncePer: &OncePer{},
+
buildFromSourceStub: cmdArgs.BuildFromSourceStub,
}
variant, ok := os.LookupEnv("TARGET_BUILD_VARIANT")
isEngBuild := !ok || variant == "eng"
- config.deviceConfig = &deviceConfig{
- config: config,
+ newConfig.deviceConfig = &deviceConfig{
+ config: newConfig,
}
// Soundness check of the build and source directories. This won't catch strange
// configurations with symlinks, but at least checks the obvious case.
absBuildDir, err := filepath.Abs(cmdArgs.SoongOutDir)
if err != nil {
- return Config{}, err
+ return &config{}, err
}
absSrcDir, err := filepath.Abs(".")
if err != nil {
- return Config{}, err
+ return &config{}, err
}
if strings.HasPrefix(absSrcDir, absBuildDir) {
- return Config{}, fmt.Errorf("Build dir must not contain source directory")
+ return &config{}, fmt.Errorf("Build dir must not contain source directory")
}
// Load any configurable options from the configuration file
- err = loadConfig(config)
+ err = loadConfig(newConfig)
if err != nil {
- return Config{}, err
+ return &config{}, err
}
KatiEnabledMarkerFile := filepath.Join(cmdArgs.SoongOutDir, ".soong.kati_enabled")
if _, err := os.Stat(absolutePath(KatiEnabledMarkerFile)); err == nil {
- config.katiEnabled = true
+ newConfig.katiEnabled = true
}
- determineBuildOS(config)
+ determineBuildOS(newConfig)
// Sets up the map of target OSes to the finer grained compilation targets
// that are configured from the product variables.
- targets, err := decodeTargetProductVariables(config)
+ targets, err := decodeTargetProductVariables(newConfig)
if err != nil {
- return Config{}, err
+ return &config{}, err
}
- config.partialCompileFlags, err = config.parsePartialCompileFlags(isEngBuild)
+ newConfig.partialCompileFlags, err = newConfig.parsePartialCompileFlags(isEngBuild)
if err != nil {
- return Config{}, err
+ return &config{}, err
}
// Make the CommonOS OsType available for all products.
targets[CommonOS] = []Target{commonTargetMap[CommonOS.Name]}
var archConfig []archConfig
- if config.NdkAbis() {
+ if newConfig.NdkAbis() {
archConfig = getNdkAbisConfig()
- } else if config.AmlAbis() {
+ } else if newConfig.AmlAbis() {
archConfig = getAmlAbisConfig()
}
if archConfig != nil {
androidTargets, err := decodeAndroidArchSettings(archConfig)
if err != nil {
- return Config{}, err
+ return &config{}, err
}
targets[Android] = androidTargets
}
@@ -733,37 +744,113 @@ func NewConfig(cmdArgs CmdArgs, availableEnv map[string]string) (Config, error)
multilib := make(map[string]bool)
for _, target := range targets[Android] {
if seen := multilib[target.Arch.ArchType.Multilib]; seen {
- config.multilibConflicts[target.Arch.ArchType] = true
+ newConfig.multilibConflicts[target.Arch.ArchType] = true
}
multilib[target.Arch.ArchType.Multilib] = true
}
// Map of OS to compilation targets.
- config.Targets = targets
+ newConfig.Targets = targets
// Compilation targets for host tools.
- config.BuildOSTarget = config.Targets[config.BuildOS][0]
- config.BuildOSCommonTarget = getCommonTargets(config.Targets[config.BuildOS])[0]
+ newConfig.BuildOSTarget = newConfig.Targets[newConfig.BuildOS][0]
+ newConfig.BuildOSCommonTarget = getCommonTargets(newConfig.Targets[newConfig.BuildOS])[0]
// Compilation targets for Android.
- if len(config.Targets[Android]) > 0 {
- config.AndroidCommonTarget = getCommonTargets(config.Targets[Android])[0]
- config.AndroidFirstDeviceTarget = FirstTarget(config.Targets[Android], "lib64", "lib32")[0]
+ if len(newConfig.Targets[Android]) > 0 {
+ newConfig.AndroidCommonTarget = getCommonTargets(newConfig.Targets[Android])[0]
+ newConfig.AndroidFirstDeviceTarget = FirstTarget(newConfig.Targets[Android], "lib64", "lib32")[0]
}
setBuildMode := func(arg string, mode SoongBuildMode) {
if arg != "" {
- if config.BuildMode != AnalysisNoBazel {
+ if newConfig.BuildMode != AnalysisNoBazel {
fmt.Fprintf(os.Stderr, "buildMode is already set, illegal argument: %s", arg)
os.Exit(1)
}
- config.BuildMode = mode
+ newConfig.BuildMode = mode
}
}
setBuildMode(cmdArgs.ModuleGraphFile, GenerateModuleGraph)
setBuildMode(cmdArgs.DocFile, GenerateDocFile)
- config.productVariables.Build_from_text_stub = boolPtr(config.BuildFromTextStub())
+ newConfig.productVariables.Build_from_text_stub = boolPtr(newConfig.BuildFromTextStub())
+
+ newConfig.deviceNameToInstall = newConfig.productVariables.DeviceName
+
+ return newConfig, err
+}
+
+// Replace variables in config.productVariables that have tags with "generic" key.
+// A generic tag may have a string or an int value for the generic configuration.
+// If the value is "unset", generic configuration will unset the variable.
+func overrideGenericConfig(config *config) {
+ config.genericConfig.isGeneric = true
+ type_pv := reflect.TypeOf(config.genericConfig.productVariables)
+ value_pv := reflect.ValueOf(&config.genericConfig.productVariables)
+ for i := range type_pv.NumField() {
+ type_pv_field := type_pv.Field(i)
+ generic_value := type_pv_field.Tag.Get("generic")
+ // If a product variable has an annotation of "generic" tag, use the
+ // value of the tag to set the generic variable.
+ if generic_value != "" {
+ value_pv_field := value_pv.Elem().Field(i)
+
+ if generic_value == "unset" {
+ // unset the product variable
+ value_pv_field.SetZero()
+ continue
+ }
+
+ kind_of_type_pv := type_pv_field.Type.Kind()
+ is_pointer := false
+ if kind_of_type_pv == reflect.Pointer {
+ is_pointer = true
+ kind_of_type_pv = type_pv_field.Type.Elem().Kind()
+ }
+
+ switch kind_of_type_pv {
+ case reflect.String:
+ if is_pointer {
+ value_pv_field.Set(reflect.ValueOf(stringPtr(generic_value)))
+ } else {
+ value_pv_field.Set(reflect.ValueOf(generic_value))
+ }
+ case reflect.Int:
+ generic_int, err := strconv.Atoi(generic_value)
+ if err != nil {
+ panic(fmt.Errorf("Only an int value can be assigned to int variable: %s", err))
+ }
+ if is_pointer {
+ value_pv_field.Set(reflect.ValueOf(intPtr(generic_int)))
+ } else {
+ value_pv_field.Set(reflect.ValueOf(generic_int))
+ }
+ default:
+ panic(fmt.Errorf("Unknown type to replace for generic variable: %s", &kind_of_type_pv))
+ }
+ }
+ }
+
+ // OncePer must be a singleton.
+ config.genericConfig.OncePer = config.OncePer
+ // keep the device name to get the install path.
+ config.genericConfig.deviceNameToInstall = config.deviceNameToInstall
+}
+
+// NewConfig creates a new Config object. It also loads the config file, if
+// found. The Config object includes a duplicated Config object in it for the
+// generic configuration that does not provide any product specific information.
+func NewConfig(cmdArgs CmdArgs, availableEnv map[string]string) (Config, error) {
+ config, err := initConfig(cmdArgs, availableEnv)
+ if err != nil {
+ return Config{}, err
+ }
+
+ // Initialize generic configuration.
+ config.genericConfig, err = initConfig(cmdArgs, availableEnv)
+ // Update product specific variables with the generic configuration.
+ overrideGenericConfig(config)
return Config{config}, err
}
@@ -951,7 +1038,7 @@ func (c *config) DisplayBuildNumber() bool {
// require them to run and get the current build fingerprint. This ensures they
// don't rebuild on every incremental build when the build number changes.
func (c *config) BuildFingerprintFile(ctx PathContext) Path {
- return PathForArbitraryOutput(ctx, "target", "product", c.DeviceName(), String(c.productVariables.BuildFingerprintFile))
+ return PathForArbitraryOutput(ctx, "target", "product", *c.deviceNameToInstall, String(c.productVariables.BuildFingerprintFile))
}
// BuildNumberFile returns the path to a text file containing metadata
@@ -979,7 +1066,7 @@ func (c *config) BuildHostnameFile(ctx PathContext) Path {
// require them to run and get the current build thumbprint. This ensures they
// don't rebuild on every incremental build when the build thumbprint changes.
func (c *config) BuildThumbprintFile(ctx PathContext) Path {
- return PathForArbitraryOutput(ctx, "target", "product", c.DeviceName(), String(c.productVariables.BuildThumbprintFile))
+ return PathForArbitraryOutput(ctx, "target", "product", *c.deviceNameToInstall, String(c.productVariables.BuildThumbprintFile))
}
// DeviceName returns the name of the current device target.
diff --git a/android/config_test.go b/android/config_test.go
index d1b26c12a..81b7c3eb5 100644
--- a/android/config_test.go
+++ b/android/config_test.go
@@ -281,3 +281,72 @@ func TestPartialCompile(t *testing.T) {
})
}
}
+
+type configTestProperties struct {
+ Use_generic_config *bool
+}
+
+type configTestModule struct {
+ ModuleBase
+ properties configTestProperties
+}
+
+func (d *configTestModule) GenerateAndroidBuildActions(ctx ModuleContext) {
+ deviceName := ctx.Config().DeviceName()
+ if ctx.ModuleName() == "foo" {
+ if ctx.Module().UseGenericConfig() {
+ ctx.PropertyErrorf("use_generic_config", "must not be set for this test")
+ }
+ } else if ctx.ModuleName() == "bar" {
+ if !ctx.Module().UseGenericConfig() {
+ ctx.ModuleErrorf("\"use_generic_config: true\" must be set for this test")
+ }
+ }
+
+ if ctx.Module().UseGenericConfig() {
+ if deviceName != "generic" {
+ ctx.ModuleErrorf("Device name for this module must be \"generic\" but %q\n", deviceName)
+ }
+ } else {
+ if deviceName == "generic" {
+ ctx.ModuleErrorf("Device name for this module must not be \"generic\"\n")
+ }
+ }
+}
+
+func configTestModuleFactory() Module {
+ module := &configTestModule{}
+ module.AddProperties(&module.properties)
+ InitAndroidModule(module)
+ return module
+}
+
+var prepareForConfigTest = GroupFixturePreparers(
+ FixtureRegisterWithContext(func(ctx RegistrationContext) {
+ ctx.RegisterModuleType("test", configTestModuleFactory)
+ }),
+)
+
+func TestGenericConfig(t *testing.T) {
+ bp := `
+ test {
+ name: "foo",
+ }
+
+ test {
+ name: "bar",
+ use_generic_config: true,
+ }
+ `
+
+ result := GroupFixturePreparers(
+ prepareForConfigTest,
+ FixtureWithRootAndroidBp(bp),
+ ).RunTest(t)
+
+ foo := result.Module("foo", "").(*configTestModule)
+ bar := result.Module("bar", "").(*configTestModule)
+
+ AssertBoolEquals(t, "Do not use generic config", false, foo.UseGenericConfig())
+ AssertBoolEquals(t, "Use generic config", true, bar.UseGenericConfig())
+}
diff --git a/android/configurable_properties.go b/android/configurable_properties.go
index 2c794a186..bde33e99b 100644
--- a/android/configurable_properties.go
+++ b/android/configurable_properties.go
@@ -7,7 +7,8 @@ import "github.com/google/blueprint/proptools"
// to indicate a "default" case.
func CreateSelectOsToBool(cases map[string]*bool) proptools.Configurable[bool] {
var resultCases []proptools.ConfigurableCase[bool]
- for pattern, value := range cases {
+ for _, pattern := range SortedKeys(cases) {
+ value := cases[pattern]
if pattern == "" {
resultCases = append(resultCases, proptools.NewConfigurableCase(
[]proptools.ConfigurablePattern{proptools.NewDefaultConfigurablePattern()},
diff --git a/android/configured_jars.go b/android/configured_jars.go
index c7b808f3d..657826e98 100644
--- a/android/configured_jars.go
+++ b/android/configured_jars.go
@@ -264,7 +264,7 @@ func (l *ConfiguredJarList) DevicePaths(cfg Config, ostype OsType) []string {
subdir = filepath.Join("apex", apex, "javalib")
}
- if ostype.Class == Host {
+ if ostype.Class == Host || cfg.IsEnvTrue("ART_USE_SIMULATOR") {
paths[i] = filepath.Join(cfg.Getenv("OUT_DIR"), "host", cfg.PrebuiltOS(), subdir, name)
} else {
paths[i] = filepath.Join("/", subdir, name)
diff --git a/android/container.go b/android/container.go
index 5d223b86a..547fe816c 100644
--- a/android/container.go
+++ b/android/container.go
@@ -39,7 +39,7 @@ type StubsAvailableModule interface {
// Returns true if the dependency module is a stubs module
var depIsStubsModule exceptionHandleFunc = func(mctx ModuleContext, _ Module, dep ModuleProxy) bool {
- return OtherModuleProviderOrDefault(mctx, dep, CommonModuleInfoProvider).IsStubsModule
+ return OtherModulePointerProviderOrDefault(mctx, dep, CommonModuleInfoProvider).IsStubsModule
}
// Returns true if the dependency module belongs to any of the apexes.
diff --git a/android/early_module_context.go b/android/early_module_context.go
index 8d2828545..300edf194 100644
--- a/android/early_module_context.go
+++ b/android/early_module_context.go
@@ -146,6 +146,13 @@ func (e *earlyModuleContext) Module() Module {
}
func (e *earlyModuleContext) Config() Config {
+ // Only the system image may use the generic config.
+ // If a module builds multiple image variations, provide the generic config only for the core
+ // variant which is installed in the system partition. Other image variant may still read the
+ // original configurations.
+ if e.Module().base().UseGenericConfig() && e.Module().base().commonProperties.ImageVariation == "" {
+ return e.EarlyModuleContext.Config().(Config).genericConfig()
+ }
return e.EarlyModuleContext.Config().(Config)
}
diff --git a/android/filegroup.go b/android/filegroup.go
index 9bcfd0a83..4fad52aaa 100644
--- a/android/filegroup.go
+++ b/android/filegroup.go
@@ -33,7 +33,6 @@ var PrepareForTestWithFilegroup = FixtureRegisterWithContext(func(ctx Registrati
func RegisterFilegroupBuildComponents(ctx RegistrationContext) {
ctx.RegisterModuleType("filegroup", FileGroupFactory)
ctx.RegisterModuleType("filegroup_defaults", FileGroupDefaultsFactory)
- ctx.RegisterModuleType("otatools_package_filegroup", OtatoolsFileGroupFactory)
}
type fileGroupProperties struct {
@@ -164,54 +163,3 @@ func (fg *fileGroup) IDEInfo(ctx BaseModuleContext, dpInfo *IdeInfo) {
}
}
}
-
-type OtatoolsFileGroup struct {
- ModuleBase
-}
-
-func OtatoolsFileGroupFactory() Module {
- module := &OtatoolsFileGroup{}
- InitAndroidModule(module)
- AddLoadHook(module, func(ctx LoadHookContext) {
- module.createOTAToolsPackagefilegroup(ctx)
- })
- return module
-}
-
-func (fg *OtatoolsFileGroup) GenerateAndroidBuildActions(ctx ModuleContext) {
-}
-
-// Create the filegroup to collect cert files for otatools.zip.
-func (fg *OtatoolsFileGroup) createOTAToolsPackagefilegroup(ctx LoadHookContext) {
- ctx.CreateModuleInDirectory(
- FileGroupFactory,
- ".",
- &struct {
- Name *string
- Srcs []string
- Visibility []string
- }{
- Name: proptools.StringPtr("soong_generated_otatools_package_filegroup"),
- Srcs: []string{
- "build/make/target/product/security/**/*.x509.pem",
- "build/make/target/product/security/**/*.pk8",
- "device/**/*.pk8",
- "device/**/verifiedboot*",
- "device/**/*.pem",
- "device/**/oem*.prop",
- "device/**/*.avbpubkey",
- "external/avb/test/data/**/testkey_*.pem",
- "external/avb/test/data/**/atx_metadata.bin",
- "packages/modules/**/*.x509.pem",
- "packages/modules/**/*.pk8",
- "packages/modules/**/*.key.pem",
- "vendor/**/*.pk8",
- "vendor/**/verifiedboot*",
- "vendor/**/*.pem",
- "vendor/**/oem*.prop",
- "vendor/**/*.avbpubkey",
- },
- Visibility: []string{"//build/make/tools/otatools_package"},
- },
- )
-}
diff --git a/android/gen_notice.go b/android/gen_notice.go
index ae831185f..45f90f47c 100644
--- a/android/gen_notice.go
+++ b/android/gen_notice.go
@@ -60,7 +60,7 @@ func (s *genNoticeBuildRules) GenerateBuildActions(ctx SingletonContext) {
for _, name := range gm.For {
mods := ctx.ModuleVariantsFromName(m, name)
for _, mod := range mods {
- if !OtherModuleProviderOrDefault(ctx, mod, CommonModuleInfoProvider).Enabled { // don't depend on variants without build rules
+ if !OtherModulePointerProviderOrDefault(ctx, mod, CommonModuleInfoProvider).Enabled { // don't depend on variants without build rules
continue
}
modules = append(modules, mod)
diff --git a/android/license_metadata.go b/android/license_metadata.go
index e79febb8f..0b880dd8a 100644
--- a/android/license_metadata.go
+++ b/android/license_metadata.go
@@ -65,7 +65,7 @@ func buildLicenseMetadata(ctx *moduleContext, licenseMetadataFile WritablePath)
var allDepMetadataDepSets []depset.DepSet[Path]
ctx.VisitDirectDepsProxy(func(dep ModuleProxy) {
- if !OtherModuleProviderOrDefault(ctx, dep, CommonModuleInfoProvider).Enabled {
+ if !OtherModulePointerProviderOrDefault(ctx, dep, CommonModuleInfoProvider).Enabled {
return
}
diff --git a/android/logtags.go b/android/logtags.go
index ef7a61259..074f402e7 100644
--- a/android/logtags.go
+++ b/android/logtags.go
@@ -43,7 +43,7 @@ func MergedLogtagsPath(ctx PathContext) OutputPath {
func (l *logtagsSingleton) GenerateBuildActions(ctx SingletonContext) {
var allLogtags Paths
ctx.VisitAllModuleProxies(func(module ModuleProxy) {
- if !OtherModuleProviderOrDefault(ctx, module, CommonModuleInfoProvider).ExportedToMake {
+ if !OtherModulePointerProviderOrDefault(ctx, module, CommonModuleInfoProvider).ExportedToMake {
return
}
if logtagsInfo, ok := OtherModuleProvider(ctx, module, LogtagsProviderKey); ok {
diff --git a/android/makevars.go b/android/makevars.go
index e1d947dff..7017e7db0 100644
--- a/android/makevars.go
+++ b/android/makevars.go
@@ -259,7 +259,7 @@ func (s *makeVarsSingleton) GenerateBuildActions(ctx SingletonContext) {
singletonDists.lock.Unlock()
ctx.VisitAllModuleProxies(func(m ModuleProxy) {
- commonInfo, _ := OtherModuleProvider(ctx, m, CommonModuleInfoProvider)
+ commonInfo := OtherModulePointerProviderOrDefault(ctx, m, CommonModuleInfoProvider)
if provider, ok := OtherModuleProvider(ctx, m, ModuleMakeVarsInfoProvider); ok &&
commonInfo.Enabled {
mctx := &makeVarsContext{
diff --git a/android/module.go b/android/module.go
index 334e5b722..c0abfd0a3 100644
--- a/android/module.go
+++ b/android/module.go
@@ -22,6 +22,7 @@ import (
"reflect"
"slices"
"sort"
+ "strconv"
"strings"
"github.com/google/blueprint"
@@ -44,6 +45,14 @@ type Module interface {
// For more information, see Module.GenerateBuildActions within Blueprint's module_ctx.go
GenerateAndroidBuildActions(ModuleContext)
+ // CleanupAfterBuildActions is called after ModuleBase.GenerateBuildActions is finished.
+ // If all interactions with this module are handled via providers instead of direct access
+ // to the module then it can free memory attached to the module.
+ // This is a temporary measure to reduce memory usage, eventually blueprint's reference
+ // to the Module should be dropped after GenerateAndroidBuildActions once all accesses
+ // can be done through providers.
+ CleanupAfterBuildActions()
+
// Add dependencies to the components of a module, i.e. modules that are created
// by the module and which are considered to be part of the creating module.
//
@@ -128,6 +137,9 @@ type Module interface {
// WARNING: This should not be used outside build/soong/fsgen
// Overrides returns the list of modules which should not be installed if this module is installed.
Overrides() []string
+
+ // If this is true, the module must not read product-specific configurations.
+ UseGenericConfig() bool
}
// Qualified id for a module
@@ -507,6 +519,10 @@ type commonProperties struct {
// List of module names that are prevented from being installed when this module gets
// installed.
Overrides []string
+
+ // Set to true if this module must be generic and does not require product-specific information.
+ // To be included in the system image, this property must be set to true.
+ Use_generic_config *bool
}
// Properties common to all modules inheriting from ModuleBase. Unlike commonProperties, these
@@ -1002,11 +1018,19 @@ func (m *ModuleBase) baseDepsMutator(ctx BottomUpMutatorContext) {
pv := ctx.Config().productVariables
fullManifest := pv.DeviceArch != nil && pv.DeviceName != nil
if fullManifest {
- addRequiredDeps(ctx)
addVintfFragmentDeps(ctx)
}
}
+// required property can be overridden too; handle it separately
+func (m *ModuleBase) baseOverridablePropertiesDepsMutator(ctx BottomUpMutatorContext) {
+ pv := ctx.Config().productVariables
+ fullManifest := pv.DeviceArch != nil && pv.DeviceName != nil
+ if fullManifest {
+ addRequiredDeps(ctx)
+ }
+}
+
// addRequiredDeps adds required, target_required, and host_required as dependencies.
func addRequiredDeps(ctx BottomUpMutatorContext) {
addDep := func(target Target, depName string) {
@@ -1488,7 +1512,7 @@ func (m *ModuleBase) computeInstallDeps(ctx ModuleContext) ([]depset.DepSet[Inst
// Installation is still handled by Make, so anything hidden from Make is not
// installable.
info := OtherModuleProviderOrDefault(ctx, dep, InstallFilesProvider)
- commonInfo := OtherModuleProviderOrDefault(ctx, dep, CommonModuleInfoProvider)
+ commonInfo := OtherModulePointerProviderOrDefault(ctx, dep, CommonModuleInfoProvider)
if !commonInfo.HideFromMake && !commonInfo.SkipInstall {
installDeps = append(installDeps, info.TransitiveInstallFiles)
}
@@ -1505,7 +1529,7 @@ func (m *ModuleBase) computeInstallDeps(ctx ModuleContext) ([]depset.DepSet[Inst
// should also install the output files of the given dependency and dependency tag.
func isInstallDepNeeded(ctx ModuleContext, dep ModuleProxy) bool {
// Don't add a dependency from the platform to a library provided by an apex.
- if OtherModuleProviderOrDefault(ctx, dep, CommonModuleInfoProvider).UninstallableApexPlatformVariant {
+ if OtherModulePointerProviderOrDefault(ctx, dep, CommonModuleInfoProvider).UninstallableApexPlatformVariant {
return false
}
// Only install modules if the dependency tag is an InstallDepNeeded tag.
@@ -1928,7 +1952,7 @@ type ApiLevelOrPlatform struct {
IsPlatform bool
}
-var CommonModuleInfoProvider = blueprint.NewProvider[CommonModuleInfo]()
+var CommonModuleInfoProvider = blueprint.NewProvider[*CommonModuleInfo]()
type PrebuiltModuleInfo struct {
SourceExists bool
@@ -2336,7 +2360,7 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext)
if mm, ok := m.module.(interface{ BaseModuleName() string }); ok {
commonData.BaseModuleName = mm.BaseModuleName()
}
- SetProvider(ctx, CommonModuleInfoProvider, commonData)
+ SetProvider(ctx, CommonModuleInfoProvider, &commonData)
if p, ok := m.module.(PrebuiltInterface); ok && p.Prebuilt() != nil {
SetProvider(ctx, PrebuiltModuleInfoProvider, PrebuiltModuleInfo{
SourceExists: p.Prebuilt().SourceExists(),
@@ -2371,8 +2395,12 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext)
})
}
}
+
+ m.module.CleanupAfterBuildActions()
}
+func (m *ModuleBase) CleanupAfterBuildActions() {}
+
func SetJarJarPrefixHandler(handler func(ModuleContext)) {
if jarJarPrefixHandler != nil {
panic("jarJarPrefixHandler already set")
@@ -2580,6 +2608,10 @@ func (m *ModuleBase) Overrides() []string {
return m.commonProperties.Overrides
}
+func (m *ModuleBase) UseGenericConfig() bool {
+ return proptools.Bool(m.commonProperties.Use_generic_config)
+}
+
type ConfigContext interface {
Config() Config
}
@@ -2680,6 +2712,13 @@ func (e configurationEvalutor) EvaluateConfiguration(condition proptools.Configu
return proptools.ConfigurableValueString(v)
case "bool":
return proptools.ConfigurableValueBool(v == "true")
+ case "int":
+ i, err := strconv.ParseInt(v, 10, 64)
+ if err != nil {
+ ctx.OtherModulePropertyErrorf(m, property, "integer soong_config_variable was not an int: %q", v)
+ return proptools.ConfigurableValueUndefined()
+ }
+ return proptools.ConfigurableValueInt(i)
case "string_list":
return proptools.ConfigurableValueStringList(strings.Split(v, " "))
default:
diff --git a/android/module_proxy.go b/android/module_proxy.go
index 77abc11e6..81d90e9a0 100644
--- a/android/module_proxy.go
+++ b/android/module_proxy.go
@@ -27,6 +27,10 @@ func (m ModuleProxy) GenerateAndroidBuildActions(context ModuleContext) {
panic("method is not implemented on ModuleProxy")
}
+func (m ModuleProxy) CleanupAfterBuildActions() {
+ panic("method is not implemented on ModuleProxy")
+}
+
func (m ModuleProxy) ComponentDepsMutator(ctx BottomUpMutatorContext) {
panic("method is not implemented on ModuleProxy")
}
@@ -231,3 +235,7 @@ func (m ModuleProxy) Overrides() []string {
func (m ModuleProxy) VintfFragments(ctx ConfigurableEvaluatorContext) []string {
panic("method is not implemented on ModuleProxy")
}
+
+func (m ModuleProxy) UseGenericConfig() bool {
+ panic("method is not implemented on ModuleProxy")
+}
diff --git a/android/neverallow.go b/android/neverallow.go
index 5c90501d7..98b443ee4 100644
--- a/android/neverallow.go
+++ b/android/neverallow.go
@@ -311,9 +311,9 @@ func createLimitGenruleRules() []Rule {
"trusty_tee_package",
// Trusty vm target names
"trusty_desktop_vm_arm64.bin",
- "trusty_desktop_vm_x86_64.elf",
+ "trusty_desktop_vm_x86_64.bin",
"trusty_desktop_test_vm_arm64.bin",
- "trusty_desktop_test_vm_x86_64.elf",
+ "trusty_desktop_test_vm_x86_64.bin",
"trusty_test_vm_arm64.bin",
"trusty_test_vm_x86_64.elf",
"trusty_test_vm_os_arm64.bin",
@@ -388,6 +388,7 @@ func createPrebuiltEtcBpDefineRule() Rule {
"prebuilt_radio",
"prebuilt_gpu",
"prebuilt_vendor_overlay",
+ "prebuilt_tee",
).
DefinedInBpFile().
Because("module type not allowed to be defined in bp file")
diff --git a/android/otatools_package_cert_zip.go b/android/otatools_package_cert_zip.go
new file mode 100644
index 000000000..3a654cfe5
--- /dev/null
+++ b/android/otatools_package_cert_zip.go
@@ -0,0 +1,62 @@
+// Copyright 2025 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package android
+
+import (
+ "github.com/google/blueprint"
+)
+
+func init() {
+ RegisterOtatoolsPackageBuildComponents(InitRegistrationContext)
+ pctx.HostBinToolVariable("SoongZipCmd", "soong_zip")
+}
+
+func RegisterOtatoolsPackageBuildComponents(ctx RegistrationContext) {
+ ctx.RegisterModuleType("otatools_package_cert_files", OtatoolsPackageFactory)
+}
+
+type OtatoolsPackage struct {
+ ModuleBase
+}
+
+func OtatoolsPackageFactory() Module {
+ module := &OtatoolsPackage{}
+ InitAndroidModule(module)
+ return module
+}
+
+var (
+ otatoolsPackageCertRule = pctx.AndroidStaticRule("otatools_package_cert_files", blueprint.RuleParams{
+ Command: "echo '$out : ' $$(cat $in) > ${out}.d && ${SoongZipCmd} -o $out -l $in",
+ CommandDeps: []string{"${SoongZipCmd}"},
+ Depfile: "${out}.d",
+ Description: "Zip otatools-package cert files",
+ })
+)
+
+func (fg *OtatoolsPackage) GenerateAndroidBuildActions(ctx ModuleContext) {
+ if ctx.ModuleDir() != "build/make/tools/otatools_package" {
+ ctx.ModuleErrorf("There can only be one otatools_package_cert_files module in build/make/tools/otatools_package")
+ return
+ }
+ fileListFile := PathForArbitraryOutput(ctx, ".module_paths", "OtaToolsCertFiles.list")
+ otatoolsPackageCertZip := PathForModuleOut(ctx, "otatools_package_cert_files.zip")
+ ctx.Build(pctx, BuildParams{
+ Rule: otatoolsPackageCertRule,
+ Input: fileListFile,
+ Output: otatoolsPackageCertZip,
+ })
+ ctx.SetOutputFiles([]Path{otatoolsPackageCertZip}, "")
+}
diff --git a/android/override_module.go b/android/override_module.go
index 50ddc9b35..96620ef7a 100644
--- a/android/override_module.go
+++ b/android/override_module.go
@@ -367,6 +367,7 @@ func checkPrebuiltReplacesOverride(ctx BottomUpMutatorContext, b OverridableModu
}
func overridableModuleDepsMutator(ctx BottomUpMutatorContext) {
+ ctx.Module().base().baseOverridablePropertiesDepsMutator(ctx)
if b, ok := ctx.Module().(OverridableModule); ok && b.Enabled(ctx) {
b.OverridablePropertiesDepsMutator(ctx)
}
diff --git a/android/package.go b/android/package.go
index 0f6a7678c..52bddf9d9 100644
--- a/android/package.go
+++ b/android/package.go
@@ -62,7 +62,7 @@ func (p *packageModule) DepsMutator(ctx BottomUpMutatorContext) {
}
func (p *packageModule) GenerateBuildActions(ctx blueprint.ModuleContext) {
- ctx.SetProvider(CommonModuleInfoProvider, CommonModuleInfo{
+ ctx.SetProvider(CommonModuleInfoProvider, &CommonModuleInfo{
Enabled: true,
PrimaryLicensesProperty: p.primaryLicensesProperty,
})
diff --git a/android/packaging.go b/android/packaging.go
index bb1fe4e45..bf1840929 100644
--- a/android/packaging.go
+++ b/android/packaging.go
@@ -506,13 +506,11 @@ func (p *PackagingBase) GatherPackagingSpecsWithFilterAndModifier(ctx ModuleCont
// all packaging specs gathered from the high priority deps.
var highPriorities []PackagingSpec
- // Name of the dependency which requested the packaging spec.
- // If this dep is overridden, the packaging spec will not be installed via this dependency chain.
- // (the packaging spec might still be installed if there are some other deps which depend on it).
- var depNames []string
-
// list of module names overridden
- var overridden []string
+ overridden := make(map[string]bool)
+
+ // all installed modules which are not overridden.
+ modulesToInstall := make(map[string]bool)
var arches []ArchType
for _, target := range getSupportedTargets(ctx) {
@@ -529,6 +527,7 @@ func (p *PackagingBase) GatherPackagingSpecsWithFilterAndModifier(ctx ModuleCont
return false
}
+ // find all overridden modules and packaging specs
ctx.VisitDirectDepsProxy(func(child ModuleProxy) {
depTag := ctx.OtherModuleDependencyTag(child)
if pi, ok := depTag.(PackagingItem); !ok || !pi.IsPackagingItem() {
@@ -556,20 +555,32 @@ func (p *PackagingBase) GatherPackagingSpecsWithFilterAndModifier(ctx ModuleCont
regularPriorities = append(regularPriorities, ps)
}
- depNames = append(depNames, child.Name())
- overridden = append(overridden, ps.overrides.ToSlice()...)
+ for o := range ps.overrides.Iter() {
+ overridden[o] = true
+ }
+ }
+ })
+
+ // gather modules to install, skipping overridden modules
+ ctx.WalkDeps(func(child, parent Module) bool {
+ owner := ctx.OtherModuleName(child)
+ if o, ok := child.(OverridableModule); ok {
+ if overriddenBy := o.GetOverriddenBy(); overriddenBy != "" {
+ owner = overriddenBy
+ }
+ }
+ if overridden[owner] {
+ return false
}
+ modulesToInstall[owner] = true
+ return true
})
filterOverridden := func(input []PackagingSpec) []PackagingSpec {
- // input minus packaging specs that are overridden
+ // input minus packaging specs that are not installed
var filtered []PackagingSpec
- for index, ps := range input {
- if ps.owner != "" && InList(ps.owner, overridden) {
- continue
- }
- // The dependency which requested this packaging spec has been overridden.
- if InList(depNames[index], overridden) {
+ for _, ps := range input {
+ if !modulesToInstall[ps.owner] {
continue
}
filtered = append(filtered, ps)
diff --git a/android/paths.go b/android/paths.go
index f7fcd35ff..6612d37d3 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -683,7 +683,7 @@ func getPathsFromModuleDep(ctx ModuleWithDepsPathContext, path, moduleName, tag
if module == nil {
return nil, missingDependencyError{[]string{moduleName}}
}
- if !OtherModuleProviderOrDefault(ctx, *module, CommonModuleInfoProvider).Enabled {
+ if !OtherModulePointerProviderOrDefault(ctx, *module, CommonModuleInfoProvider).Enabled {
return nil, missingDependencyError{[]string{moduleName}}
}
@@ -2054,7 +2054,7 @@ func pathForInstall(ctx PathContext, os OsType, arch ArchType, partition string,
var partitionPaths []string
if os.Class == Device {
- partitionPaths = []string{"target", "product", ctx.Config().DeviceName(), partition}
+ partitionPaths = []string{"target", "product", *ctx.Config().deviceNameToInstall, partition}
} else {
osName := os.String()
if os == Linux {
diff --git a/android/prebuilt.go b/android/prebuilt.go
index 0178f769c..1ff009bf5 100644
--- a/android/prebuilt.go
+++ b/android/prebuilt.go
@@ -358,7 +358,7 @@ func IsModulePreferred(module Module) bool {
}
func IsModulePreferredProxy(ctx OtherModuleProviderContext, module ModuleProxy) bool {
- if OtherModuleProviderOrDefault(ctx, module, CommonModuleInfoProvider).ReplacedByPrebuilt {
+ if OtherModulePointerProviderOrDefault(ctx, module, CommonModuleInfoProvider).ReplacedByPrebuilt {
// A source module that has been replaced by a prebuilt counterpart.
return false
}
@@ -397,7 +397,7 @@ func GetEmbeddedPrebuilt(module Module) *Prebuilt {
// the right module. This function is only safe to call after all TransitionMutators
// have run, e.g. in GenerateAndroidBuildActions.
func PrebuiltGetPreferred(ctx BaseModuleContext, module Module) Module {
- if !OtherModuleProviderOrDefault(ctx, module, CommonModuleInfoProvider).ReplacedByPrebuilt {
+ if !OtherModulePointerProviderOrDefault(ctx, module, CommonModuleInfoProvider).ReplacedByPrebuilt {
return module
}
if _, ok := OtherModuleProvider(ctx, module, PrebuiltModuleInfoProvider); ok {
diff --git a/android/provider.go b/android/provider.go
index d005daf55..aae93ef88 100644
--- a/android/provider.go
+++ b/android/provider.go
@@ -41,6 +41,14 @@ func OtherModuleProviderOrDefault[K any](ctx OtherModuleProviderContext, module
return value
}
+func OtherModulePointerProviderOrDefault[K *T, T any](ctx OtherModuleProviderContext, module blueprint.Module, provider blueprint.ProviderKey[K]) K {
+ if value, ok := OtherModuleProvider(ctx, module, provider); ok {
+ return value
+ }
+ var val T
+ return &val
+}
+
// ModuleProviderContext is a helper interface that is a subset of ModuleContext or BottomUpMutatorContext
// for use in ModuleProvider.
type ModuleProviderContext interface {
diff --git a/android/selects_test.go b/android/selects_test.go
index 7f20a3d66..8e469f8e3 100644
--- a/android/selects_test.go
+++ b/android/selects_test.go
@@ -666,6 +666,81 @@ func TestSelects(t *testing.T) {
},
},
{
+ name: "Select on integer soong config variable",
+ bp: `
+ my_module_type {
+ name: "foo",
+ my_string: select(soong_config_variable("my_namespace", "my_variable"), {
+ 34: "34",
+ default: "other",
+ }),
+ }
+ `,
+ vendorVars: map[string]map[string]string{
+ "my_namespace": {
+ "my_variable": "34",
+ },
+ },
+ vendorVarTypes: map[string]map[string]string{
+ "my_namespace": {
+ "my_variable": "int",
+ },
+ },
+ provider: selectsTestProvider{
+ my_string: proptools.StringPtr("34"),
+ },
+ },
+ {
+ name: "Select on integer soong config variable default",
+ bp: `
+ my_module_type {
+ name: "foo",
+ my_string: select(soong_config_variable("my_namespace", "my_variable"), {
+ 34: "34",
+ default: "other",
+ }),
+ }
+ `,
+ vendorVars: map[string]map[string]string{
+ "my_namespace": {
+ "my_variable": "5",
+ },
+ },
+ vendorVarTypes: map[string]map[string]string{
+ "my_namespace": {
+ "my_variable": "int",
+ },
+ },
+ provider: selectsTestProvider{
+ my_string: proptools.StringPtr("other"),
+ },
+ },
+ {
+ name: "Assign to integer property",
+ bp: `
+ my_module_type {
+ name: "foo",
+ my_int64: select(soong_config_variable("my_namespace", "my_variable"), {
+ any @ val: val,
+ default: "other",
+ }),
+ }
+ `,
+ vendorVars: map[string]map[string]string{
+ "my_namespace": {
+ "my_variable": "5",
+ },
+ },
+ vendorVarTypes: map[string]map[string]string{
+ "my_namespace": {
+ "my_variable": "int",
+ },
+ },
+ provider: selectsTestProvider{
+ my_int64: proptools.Int64Ptr(5),
+ },
+ },
+ {
name: "Mismatched condition types",
bp: `
my_module_type {
@@ -1132,6 +1207,7 @@ my_module_type {
type selectsTestProvider struct {
my_bool *bool
my_string *string
+ my_int64 *int64
my_string_list *[]string
my_paths *[]string
replacing_string_list *[]string
@@ -1181,6 +1257,7 @@ var selectsTestProviderKey = blueprint.NewProvider[selectsTestProvider]()
type selectsMockModuleProperties struct {
My_bool proptools.Configurable[bool]
+ My_int64 proptools.Configurable[int64]
My_string proptools.Configurable[string]
My_string_list proptools.Configurable[[]string]
My_paths proptools.Configurable[[]string] `android:"path"`
@@ -1213,6 +1290,7 @@ func (p *selectsMockModule) GenerateAndroidBuildActions(ctx ModuleContext) {
SetProvider(ctx, selectsTestProviderKey, selectsTestProvider{
my_bool: optionalToPtr(p.properties.My_bool.Get(ctx)),
my_string: optionalToPtr(p.properties.My_string.Get(ctx)),
+ my_int64: optionalToPtr(p.properties.My_int64.Get(ctx)),
my_string_list: optionalToPtr(p.properties.My_string_list.Get(ctx)),
my_paths: optionalToPtr(p.properties.My_paths.Get(ctx)),
replacing_string_list: optionalToPtr(p.properties.Replacing_string_list.Get(ctx)),
diff --git a/android/test_config.go b/android/test_config.go
index 3609e6b78..5d79df099 100644
--- a/android/test_config.go
+++ b/android/test_config.go
@@ -23,8 +23,7 @@ import (
"github.com/google/blueprint/proptools"
)
-// TestConfig returns a Config object for testing.
-func TestConfig(buildDir string, env map[string]string, bp string, fs map[string][]byte) Config {
+func initTestConfig(buildDir string, env map[string]string) *config {
envCopy := make(map[string]string)
for k, v := range env {
envCopy[k] = v
@@ -58,6 +57,7 @@ func TestConfig(buildDir string, env map[string]string, bp string, fs map[string
soongOutDir: filepath.Join(buildDir, "soong"),
captureBuild: true,
env: envCopy,
+ OncePer: &OncePer{},
// Set testAllowNonExistentPaths so that test contexts don't need to specify every path
// passed to PathForSource or PathForModuleSrc.
@@ -69,10 +69,21 @@ func TestConfig(buildDir string, env map[string]string, bp string, fs map[string
config: config,
}
config.TestProductVariables = &config.productVariables
+ config.deviceNameToInstall = config.TestProductVariables.DeviceName
+
+ determineBuildOS(config)
+
+ return config
+}
+
+// TestConfig returns a Config object for testing.
+func TestConfig(buildDir string, env map[string]string, bp string, fs map[string][]byte) Config {
+ config := initTestConfig(buildDir, env)
config.mockFileSystem(bp, fs)
- determineBuildOS(config)
+ config.genericConfig = initTestConfig(buildDir, env)
+ overrideGenericConfig(config)
return Config{config}
}
diff --git a/android/testing.go b/android/testing.go
index 08c8083a6..d2949ec8e 100644
--- a/android/testing.go
+++ b/android/testing.go
@@ -1197,11 +1197,11 @@ func AndroidMkInfoForTest(t *testing.T, ctx *TestContext, mod Module) *AndroidMk
info := OtherModuleProviderOrDefault(ctx, mod, AndroidMkInfoProvider)
aconfigUpdateAndroidMkInfos(ctx, mod, info)
- commonInfo, _ := OtherModuleProvider(ctx, mod, CommonModuleInfoProvider)
- info.PrimaryInfo.fillInEntries(ctx, mod, &commonInfo)
+ commonInfo := OtherModulePointerProviderOrDefault(ctx, mod, CommonModuleInfoProvider)
+ info.PrimaryInfo.fillInEntries(ctx, mod, commonInfo)
if len(info.ExtraInfo) > 0 {
for _, ei := range info.ExtraInfo {
- ei.fillInEntries(ctx, mod, &commonInfo)
+ ei.fillInEntries(ctx, mod, commonInfo)
}
}
diff --git a/android/variable.go b/android/variable.go
index c59857ad9..8c9a0b1a5 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -65,12 +65,6 @@ type variableProperties struct {
Enabled proptools.Configurable[bool] `android:"arch_variant,replace_instead_of_append"`
} `android:"arch_variant"`
- // similar to `Unbundled_build`, but `Always_use_prebuilt_sdks` means that it uses prebuilt
- // sdk specifically.
- Always_use_prebuilt_sdks struct {
- Enabled proptools.Configurable[bool] `android:"arch_variant,replace_instead_of_append"`
- } `android:"arch_variant"`
-
Malloc_low_memory struct {
Cflags []string `android:"arch_variant"`
Shared_libs []string `android:"arch_variant"`
@@ -231,8 +225,8 @@ type ProductVariables struct {
Platform_version_last_stable *string `json:",omitempty"`
Platform_version_known_codenames *string `json:",omitempty"`
- DeviceName *string `json:",omitempty"`
- DeviceProduct *string `json:",omitempty"`
+ DeviceName *string `json:",omitempty" generic:"generic"`
+ DeviceProduct *string `json:",omitempty" generic:"generic"`
DeviceArch *string `json:",omitempty"`
DeviceArchVariant *string `json:",omitempty"`
DeviceCpuVariant *string `json:",omitempty"`
diff --git a/android/visibility.go b/android/visibility.go
index 416a3f15f..915368710 100644
--- a/android/visibility.go
+++ b/android/visibility.go
@@ -551,7 +551,7 @@ func visibilityRuleEnforcer(ctx BottomUpMutatorContext) {
rule := effectiveVisibilityRules(ctx.Config(), depQualified)
if !rule.matches(qualified) {
- ctx.ModuleErrorf("depends on %s which is not visible to this module\nYou may need to add %q to its visibility, %#v", depQualified, "//"+ctx.ModuleDir(), ctx.OtherModuleDependencyTag(dep))
+ ctx.ModuleErrorf("depends on %s which is not visible to this module\nYou may need to add %q to its visibility", depQualified, "//"+ctx.ModuleDir())
}
})
}