Merge "Build and dist updatepackage" into main
diff --git a/aconfig/all_aconfig_declarations.go b/aconfig/all_aconfig_declarations.go
index f3c68c3..5a52624 100644
--- a/aconfig/all_aconfig_declarations.go
+++ b/aconfig/all_aconfig_declarations.go
@@ -129,6 +129,7 @@
invalidExportedFlags := android.PathForIntermediates(ctx, "invalid_exported_flags.txt")
GenerateExportedFlagCheck(ctx, invalidExportedFlags, parsedFlagsFile, this.properties)
depsFiles = append(depsFiles, invalidExportedFlags)
+ ctx.Phony("droidcore", invalidExportedFlags)
}
}
diff --git a/android/Android.bp b/android/Android.bp
index 4b75148..97d634f 100644
--- a/android/Android.bp
+++ b/android/Android.bp
@@ -12,6 +12,7 @@
"blueprint-gobtools",
"blueprint-metrics",
"blueprint-pool",
+ "blueprint-syncmap",
"sbox_proto",
"soong",
"soong-android_team_proto",
@@ -83,6 +84,7 @@
"nothing.go",
"notices.go",
"onceper.go",
+ "otatools_package_cert_zip.go",
"override_module.go",
"package.go",
"package_ctx.go",
@@ -171,7 +173,3 @@
// 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 9c71d92..bb73f0b 100644
--- a/android/aconfig_providers.go
+++ b/android/aconfig_providers.go
@@ -248,7 +248,7 @@
// 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 5e76e53..18a050f 100644
--- a/android/all_teams.go
+++ b/android/all_teams.go
@@ -116,7 +116,7 @@
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 694f5d6..e328359 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -435,13 +435,18 @@
suffix = *dist.Suffix
}
- productString := ""
- if dist.Append_artifact_with_product != nil && *dist.Append_artifact_with_product {
- productString = fmt.Sprintf("_%s", ctx.Config().DeviceProduct())
+ prependProductString := ""
+ if proptools.Bool(dist.Prepend_artifact_with_product) {
+ prependProductString = fmt.Sprintf("%s-", ctx.Config().DeviceProduct())
}
- if suffix != "" || productString != "" {
- dest = strings.TrimSuffix(dest, ext) + suffix + productString + ext
+ appendProductString := ""
+ if proptools.Bool(dist.Append_artifact_with_product) {
+ appendProductString = fmt.Sprintf("_%s", ctx.Config().DeviceProduct())
+ }
+
+ if suffix != "" || appendProductString != "" || prependProductString != "" {
+ dest = prependProductString + strings.TrimSuffix(dest, ext) + suffix + appendProductString + ext
}
if dist.Dir != nil {
@@ -510,6 +515,9 @@
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 +896,14 @@
}
}
- 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 +1328,7 @@
// 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 +1339,11 @@
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 389f194..8659549 100644
--- a/android/arch_list.go
+++ b/android/arch_list.go
@@ -27,6 +27,8 @@
"armv8-2a-dotprod",
"armv9-a",
"armv9-2a",
+ "armv9-3a",
+ "armv9-4a",
},
X86: {
"alderlake",
@@ -151,6 +153,12 @@
"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 eba3670..5cb9e71 100644
--- a/android/base_module_context.go
+++ b/android/base_module_context.go
@@ -410,7 +410,7 @@
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) 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 c15a206..16a3853 100644
--- a/android/compliance_metadata.go
+++ b/android/compliance_metadata.go
@@ -304,7 +304,7 @@
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 885960b..52d7f3b 100644
--- a/android/config.go
+++ b/android/config.go
@@ -22,6 +22,7 @@
"fmt"
"os"
"path/filepath"
+ "reflect"
"runtime"
"strconv"
"strings"
@@ -108,6 +109,10 @@
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 @@
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 @@
// 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 @@
// 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 @@
}
}
-// 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 @@
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 @@
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 @@
// 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 @@
// 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 d1b26c1..81b7c3e 100644
--- a/android/config_test.go
+++ b/android/config_test.go
@@ -281,3 +281,72 @@
})
}
}
+
+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 2c794a1..bde33e9 100644
--- a/android/configurable_properties.go
+++ b/android/configurable_properties.go
@@ -7,7 +7,8 @@
// 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 c7b808f..657826e 100644
--- a/android/configured_jars.go
+++ b/android/configured_jars.go
@@ -264,7 +264,7 @@
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 5d223b8..547fe81 100644
--- a/android/container.go
+++ b/android/container.go
@@ -39,7 +39,7 @@
// 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 8d28285..300edf1 100644
--- a/android/early_module_context.go
+++ b/android/early_module_context.go
@@ -146,6 +146,13 @@
}
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 9bcfd0a..4fad52a 100644
--- a/android/filegroup.go
+++ b/android/filegroup.go
@@ -33,7 +33,6 @@
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 @@
}
}
}
-
-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 ae83118..45f90f4 100644
--- a/android/gen_notice.go
+++ b/android/gen_notice.go
@@ -60,7 +60,7 @@
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 e79febb..0b880dd 100644
--- a/android/license_metadata.go
+++ b/android/license_metadata.go
@@ -65,7 +65,7 @@
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 ef7a612..074f402 100644
--- a/android/logtags.go
+++ b/android/logtags.go
@@ -43,7 +43,7 @@
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 e1d947d..7017e7d 100644
--- a/android/makevars.go
+++ b/android/makevars.go
@@ -259,7 +259,7 @@
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 334e5b7..1538861 100644
--- a/android/module.go
+++ b/android/module.go
@@ -22,6 +22,7 @@
"reflect"
"slices"
"sort"
+ "strconv"
"strings"
"github.com/google/blueprint"
@@ -44,6 +45,14 @@
// 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 @@
// 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
@@ -196,6 +208,12 @@
// no change to the artifact file name.
Append_artifact_with_product *bool `android:"arch_variant"`
+ // If true, then the artifact file will be prepended with <product name>-. For
+ // example, if the product is coral and the module is an android_app module
+ // of name foo, then the artifact would be coral-foo.apk. If false, there is
+ // no change to the artifact file name.
+ Prepend_artifact_with_product *bool `android:"arch_variant"`
+
// A string tag to select the OutputFiles associated with the tag.
//
// If no tag is specified then it will select the default dist paths provided
@@ -507,6 +525,10 @@
// 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 +1024,19 @@
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 +1518,7 @@
// 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 +1535,7 @@
// 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 +1958,7 @@
IsPlatform bool
}
-var CommonModuleInfoProvider = blueprint.NewProvider[CommonModuleInfo]()
+var CommonModuleInfoProvider = blueprint.NewProvider[*CommonModuleInfo]()
type PrebuiltModuleInfo struct {
SourceExists bool
@@ -2336,7 +2366,7 @@
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 +2401,12 @@
})
}
}
+
+ m.module.CleanupAfterBuildActions()
}
+func (m *ModuleBase) CleanupAfterBuildActions() {}
+
func SetJarJarPrefixHandler(handler func(ModuleContext)) {
if jarJarPrefixHandler != nil {
panic("jarJarPrefixHandler already set")
@@ -2580,6 +2614,10 @@
return m.commonProperties.Overrides
}
+func (m *ModuleBase) UseGenericConfig() bool {
+ return proptools.Bool(m.commonProperties.Use_generic_config)
+}
+
type ConfigContext interface {
Config() Config
}
@@ -2680,6 +2718,13 @@
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 77abc11..81d90e9 100644
--- a/android/module_proxy.go
+++ b/android/module_proxy.go
@@ -27,6 +27,10 @@
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) 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 5c90501..98b443e 100644
--- a/android/neverallow.go
+++ b/android/neverallow.go
@@ -311,9 +311,9 @@
"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 @@
"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 0000000..3a654cf
--- /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 50ddc9b..96620ef 100644
--- a/android/override_module.go
+++ b/android/override_module.go
@@ -367,6 +367,7 @@
}
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 0f6a767..52bddf9 100644
--- a/android/package.go
+++ b/android/package.go
@@ -62,7 +62,7 @@
}
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 bb1fe4e..bf18409 100644
--- a/android/packaging.go
+++ b/android/packaging.go
@@ -506,13 +506,11 @@
// 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 @@
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 @@
regularPriorities = append(regularPriorities, ps)
}
- depNames = append(depNames, child.Name())
- overridden = append(overridden, ps.overrides.ToSlice()...)
+ for o := range ps.overrides.Iter() {
+ overridden[o] = true
+ }
}
})
- filterOverridden := func(input []PackagingSpec) []PackagingSpec {
- // input minus packaging specs that are overridden
- var filtered []PackagingSpec
- for index, ps := range input {
- if ps.owner != "" && InList(ps.owner, overridden) {
- continue
+ // 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
}
- // The dependency which requested this packaging spec has been overridden.
- if InList(depNames[index], overridden) {
+ }
+ if overridden[owner] {
+ return false
+ }
+ modulesToInstall[owner] = true
+ return true
+ })
+
+ filterOverridden := func(input []PackagingSpec) []PackagingSpec {
+ // input minus packaging specs that are not installed
+ var filtered []PackagingSpec
+ for _, ps := range input {
+ if !modulesToInstall[ps.owner] {
continue
}
filtered = append(filtered, ps)
diff --git a/android/paths.go b/android/paths.go
index f7fcd35..6612d37 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -683,7 +683,7 @@
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 @@
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 0178f76..1ff009b 100644
--- a/android/prebuilt.go
+++ b/android/prebuilt.go
@@ -358,7 +358,7 @@
}
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 @@
// 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 d005daf..aae93ef 100644
--- a/android/provider.go
+++ b/android/provider.go
@@ -41,6 +41,14 @@
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/raw_files.go b/android/raw_files.go
index fd37196..ebba4d1 100644
--- a/android/raw_files.go
+++ b/android/raw_files.go
@@ -26,6 +26,7 @@
"testing"
"github.com/google/blueprint"
+ "github.com/google/blueprint/syncmap"
"github.com/google/blueprint/proptools"
)
@@ -213,10 +214,10 @@
var rawFileSetKey OnceKey = NewOnceKey("raw file set")
-func getRawFileSet(config Config) *SyncMap[string, rawFileInfo] {
+func getRawFileSet(config Config) *syncmap.SyncMap[string, rawFileInfo] {
return config.Once(rawFileSetKey, func() any {
- return &SyncMap[string, rawFileInfo]{}
- }).(*SyncMap[string, rawFileInfo])
+ return &syncmap.SyncMap[string, rawFileInfo]{}
+ }).(*syncmap.SyncMap[string, rawFileInfo])
}
// ContentFromFileRuleForTests returns the content that was passed to a WriteFileRule for use
diff --git a/android/selects_test.go b/android/selects_test.go
index 7f20a3d..8e469f8 100644
--- a/android/selects_test.go
+++ b/android/selects_test.go
@@ -666,6 +666,81 @@
},
},
{
+ 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 @@
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 @@
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 @@
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 3609e6b..5d79df0 100644
--- a/android/test_config.go
+++ b/android/test_config.go
@@ -23,8 +23,7 @@
"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 @@
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 @@
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/test_suites.go b/android/test_suites.go
index 9eaf785..dbcd48c 100644
--- a/android/test_suites.go
+++ b/android/test_suites.go
@@ -42,6 +42,12 @@
var TestSuiteInfoProvider = blueprint.NewProvider[TestSuiteInfo]()
+type SupportFilesInfo struct {
+ SupportFiles InstallPaths
+}
+
+var SupportFilesInfoProvider = blueprint.NewProvider[SupportFilesInfo]()
+
func (t *testSuiteFiles) GenerateBuildActions(ctx SingletonContext) {
files := make(map[string]map[string]InstallPaths)
diff --git a/android/testing.go b/android/testing.go
index 08c8083..d2949ec 100644
--- a/android/testing.go
+++ b/android/testing.go
@@ -1197,11 +1197,11 @@
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/util.go b/android/util.go
index 7b305b5..4520f40 100644
--- a/android/util.go
+++ b/android/util.go
@@ -23,7 +23,6 @@
"runtime"
"sort"
"strings"
- "sync"
"github.com/google/blueprint/proptools"
)
@@ -646,35 +645,6 @@
}
}
-// SyncMap is a wrapper around sync.Map that provides type safety via generics.
-type SyncMap[K comparable, V any] struct {
- sync.Map
-}
-
-// Load returns the value stored in the map for a key, or the zero value if no
-// value is present.
-// The ok result indicates whether value was found in the map.
-func (m *SyncMap[K, V]) Load(key K) (value V, ok bool) {
- v, ok := m.Map.Load(key)
- if !ok {
- return *new(V), false
- }
- return v.(V), true
-}
-
-// Store sets the value for a key.
-func (m *SyncMap[K, V]) Store(key K, value V) {
- m.Map.Store(key, value)
-}
-
-// LoadOrStore returns the existing value for the key if present.
-// Otherwise, it stores and returns the given value.
-// The loaded result is true if the value was loaded, false if stored.
-func (m *SyncMap[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool) {
- v, loaded := m.Map.LoadOrStore(key, value)
- return v.(V), loaded
-}
-
// AppendIfNotZero append the given value to the slice if it is not the zero value
// for its type.
func AppendIfNotZero[T comparable](slice []T, value T) []T {
diff --git a/android/variable.go b/android/variable.go
index 7eb08a0..5980efd 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -65,12 +65,6 @@
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 @@
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 416a3f1..9153687 100644
--- a/android/visibility.go
+++ b/android/visibility.go
@@ -551,7 +551,7 @@
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())
}
})
}
diff --git a/apex/androidmk.go b/apex/androidmk.go
index 3a81ee4..0a5644a 100644
--- a/apex/androidmk.go
+++ b/apex/androidmk.go
@@ -75,7 +75,7 @@
// populated by Soong for unconverted APEXes, or Bazel in mixed mode. Use
// apexFile#isBazelPrebuilt to differentiate.
func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, moduleDir string,
- apexAndroidMkData android.AndroidMkData) []string {
+ apexAndroidMkData android.AndroidMkData) (archSpecificModuleNames []string, moduleNames []string) {
// apexBundleName comes from the 'name' property or soong module.
// apexName comes from 'name' property of apex_manifest.
@@ -84,11 +84,12 @@
// However, symbol files for apex files are installed under /apex/<apexBundleName> to avoid
// conflicts between two apexes with the same apexName.
- moduleNames := []string{}
-
for _, fi := range a.filesInfo {
linkToSystemLib := a.linkToSystemLib && fi.transitiveDep && fi.availableToPlatform()
moduleName := a.fullModuleName(apexBundleName, linkToSystemLib, &fi)
+ if !android.InList(moduleName, moduleNames) {
+ moduleNames = append(moduleNames, moduleName)
+ }
// This name will be added to LOCAL_REQUIRED_MODULES of the APEX. We need to be
// arch-specific otherwise we will end up installing both ABIs even when only
@@ -100,8 +101,8 @@
case "lib64":
aName = aName + ":64"
}
- if !android.InList(aName, moduleNames) {
- moduleNames = append(moduleNames, aName)
+ if !android.InList(aName, archSpecificModuleNames) {
+ archSpecificModuleNames = append(archSpecificModuleNames, aName)
}
if linkToSystemLib {
@@ -216,7 +217,7 @@
fmt.Fprintf(w, "%s: %s\n", fi.androidMkModuleName, moduleName)
}
}
- return moduleNames
+ return
}
func (a *apexBundle) writeRequiredModules(w io.Writer, moduleNames []string) {
@@ -235,9 +236,10 @@
return android.AndroidMkData{
// While we do not provide a value for `Extra`, AconfigUpdateAndroidMkData may add some, which we must honor.
Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
+ archSpecificModuleNames := []string{}
moduleNames := []string{}
if a.installable() {
- moduleNames = a.androidMkForFiles(w, name, moduleDir, data)
+ archSpecificModuleNames, moduleNames = a.androidMkForFiles(w, name, moduleDir, data)
}
fmt.Fprintln(w, "\ninclude $(CLEAR_VARS) # apex.apexBundle")
@@ -274,7 +276,7 @@
}
android.AndroidMkEmitAssignList(w, "LOCAL_OVERRIDES_MODULES", a.overridableProperties.Overrides)
- a.writeRequiredModules(w, moduleNames)
+ a.writeRequiredModules(w, archSpecificModuleNames)
// AconfigUpdateAndroidMkData may have added elements to Extra. Process them here.
for _, extra := range data.Extra {
extra(w, a.outputFile)
@@ -296,6 +298,9 @@
fmt.Fprintln(w, dist)
}
+ fmt.Fprintf(w, "ALL_MODULES.$(my_register_name).SYMBOLIC_OUTPUT_PATH := $(foreach m,%s,$(ALL_MODULES.$(m).SYMBOLIC_OUTPUT_PATH))\n", strings.Join(moduleNames, " "))
+ fmt.Fprintf(w, "ALL_MODULES.$(my_register_name).ELF_SYMBOL_MAPPING_PATH := $(foreach m,%s,$(ALL_MODULES.$(m).ELF_SYMBOL_MAPPING_PATH))\n", strings.Join(moduleNames, " "))
+
distCoverageFiles(w, "ndk_apis_usedby_apex", a.nativeApisUsedByModuleFile.String())
distCoverageFiles(w, "ndk_apis_backedby_apex", a.nativeApisBackedByModuleFile.String())
distCoverageFiles(w, "java_apis_used_by_apex", a.javaApisUsedByModuleFile.String())
diff --git a/apex/apex.go b/apex/apex.go
index dc44e58..a726098 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -569,19 +569,6 @@
shBinary
)
-var (
- classes = map[string]apexFileClass{
- "app": app,
- "appSet": appSet,
- "etc": etc,
- "javaSharedLib": javaSharedLib,
- "nativeExecutable": nativeExecutable,
- "nativeSharedLib": nativeSharedLib,
- "nativeTest": nativeTest,
- "shBinary": shBinary,
- }
-)
-
// apexFile represents a file in an APEX bundle. This is created during the first half of
// GenerateAndroidBuildActions by traversing the dependencies of the APEX. Then in the second half
// of the function, this is used to create commands that copies the files into a staging directory,
@@ -1502,7 +1489,7 @@
func apexFileForJavaModuleWithFile(ctx android.ModuleContext, module android.Module,
javaInfo *java.JavaInfo, dexImplementationJar android.Path) apexFile {
dirInApex := "javalib"
- commonInfo := android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoProvider)
+ commonInfo := android.OtherModulePointerProviderOrDefault(ctx, module, android.CommonModuleInfoProvider)
af := newApexFile(ctx, dexImplementationJar, commonInfo.BaseModuleName, dirInApex, javaSharedLib, module)
af.jacocoReportClassesFile = javaInfo.JacocoReportClassesFile
if lintInfo, ok := android.OtherModuleProvider(ctx, module, java.LintProvider); ok {
@@ -1608,7 +1595,7 @@
// modules. This is used in check* functions below.
func (a *apexBundle) WalkPayloadDeps(ctx android.BaseModuleContext, do android.PayloadDepsCallback) {
ctx.WalkDepsProxy(func(child, parent android.ModuleProxy) bool {
- if !android.OtherModuleProviderOrDefault(ctx, child, android.CommonModuleInfoProvider).CanHaveApexVariants {
+ if !android.OtherModulePointerProviderOrDefault(ctx, child, android.CommonModuleInfoProvider).CanHaveApexVariants {
return false
}
// Filter-out unwanted depedendencies
@@ -1821,7 +1808,7 @@
if _, ok := depTag.(android.ExcludeFromApexContentsTag); ok {
return false
}
- commonInfo := android.OtherModuleProviderOrDefault(ctx, child, android.CommonModuleInfoProvider)
+ commonInfo := android.OtherModulePointerProviderOrDefault(ctx, child, android.CommonModuleInfoProvider)
if !commonInfo.Enabled {
return false
}
@@ -1839,7 +1826,7 @@
if ch.IsStubs {
ctx.PropertyErrorf(propertyName, "%q is a stub. Remove it from the list.", depName)
}
- fi := apexFileForNativeLibrary(ctx, child, &commonInfo, ch, vctx.handleSpecialLibs)
+ fi := apexFileForNativeLibrary(ctx, child, commonInfo, ch, vctx.handleSpecialLibs)
fi.isJniLib = isJniLib
vctx.filesInfo = append(vctx.filesInfo, fi)
// Collect the list of stub-providing libs except:
@@ -1856,11 +1843,11 @@
case executableTag:
if ccInfo, ok := android.OtherModuleProvider(ctx, child, cc.CcInfoProvider); ok {
- vctx.filesInfo = append(vctx.filesInfo, apexFileForExecutable(ctx, child, &commonInfo, ccInfo))
+ vctx.filesInfo = append(vctx.filesInfo, apexFileForExecutable(ctx, child, commonInfo, ccInfo))
return true // track transitive dependencies
}
if _, ok := android.OtherModuleProvider(ctx, child, rust.RustInfoProvider); ok {
- vctx.filesInfo = append(vctx.filesInfo, apexFileForRustExecutable(ctx, child, &commonInfo))
+ vctx.filesInfo = append(vctx.filesInfo, apexFileForRustExecutable(ctx, child, commonInfo))
return true // track transitive dependencies
} else {
ctx.PropertyErrorf("binaries",
@@ -1868,7 +1855,7 @@
}
case shBinaryTag:
if csh, ok := android.OtherModuleProvider(ctx, child, sh.ShBinaryInfoProvider); ok {
- vctx.filesInfo = append(vctx.filesInfo, apexFileForShBinary(ctx, child, &commonInfo, &csh))
+ vctx.filesInfo = append(vctx.filesInfo, apexFileForShBinary(ctx, child, commonInfo, &csh))
} else {
ctx.PropertyErrorf("sh_binaries", "%q is not a sh_binary module", depName)
}
@@ -1922,7 +1909,7 @@
af.certificate = java.PresignedCertificate
vctx.filesInfo = append(vctx.filesInfo, af)
} else {
- vctx.filesInfo = append(vctx.filesInfo, apexFilesForAndroidApp(ctx, child, &commonInfo, appInfo)...)
+ vctx.filesInfo = append(vctx.filesInfo, apexFilesForAndroidApp(ctx, child, commonInfo, appInfo)...)
if !appInfo.Prebuilt && !appInfo.TestHelperApp {
return true // track transitive dependencies
}
@@ -1969,8 +1956,12 @@
}
case testTag:
if ccInfo, ok := android.OtherModuleProvider(ctx, child, cc.CcInfoProvider); ok {
- af := apexFileForExecutable(ctx, child, &commonInfo, ccInfo)
- af.class = nativeTest
+ af := apexFileForExecutable(ctx, child, commonInfo, ccInfo)
+ // We make this a nativeExecutable instead of a nativeTest because we don't want
+ // the androidmk modules generated in AndroidMkForFiles to be treated as real
+ // tests that are then packaged into suites. Our AndroidMkForFiles does not
+ // implement enough functionality to support real tests.
+ af.class = nativeExecutable
vctx.filesInfo = append(vctx.filesInfo, af)
return true // track transitive dependencies
} else {
@@ -2006,7 +1997,7 @@
// tags used below are private (e.g. `cc.sharedDepTag`).
if cc.IsSharedDepTag(depTag) || cc.IsRuntimeDepTag(depTag) {
if ch, ok := android.OtherModuleProvider(ctx, child, cc.LinkableInfoProvider); ok {
- af := apexFileForNativeLibrary(ctx, child, &commonInfo, ch, vctx.handleSpecialLibs)
+ af := apexFileForNativeLibrary(ctx, child, commonInfo, ch, vctx.handleSpecialLibs)
af.transitiveDep = true
if ch.IsStubs || ch.HasStubsVariants {
@@ -2068,7 +2059,7 @@
}
linkableInfo := android.OtherModuleProviderOrDefault(ctx, child, cc.LinkableInfoProvider)
- af := apexFileForNativeLibrary(ctx, child, &commonInfo, linkableInfo, vctx.handleSpecialLibs)
+ af := apexFileForNativeLibrary(ctx, child, commonInfo, linkableInfo, vctx.handleSpecialLibs)
af.transitiveDep = true
vctx.filesInfo = append(vctx.filesInfo, af)
return true // track transitive dependencies
@@ -2100,7 +2091,7 @@
javaInfo := android.OtherModuleProviderOrDefault(ctx, child, java.JavaInfoProvider)
af := apexFileForJavaModule(ctx, child, javaInfo)
vctx.filesInfo = append(vctx.filesInfo, af)
- if profileAf := apexFileForJavaModuleProfile(ctx, &commonInfo, javaInfo); profileAf != nil {
+ if profileAf := apexFileForJavaModuleProfile(ctx, commonInfo, javaInfo); profileAf != nil {
vctx.filesInfo = append(vctx.filesInfo, *profileAf)
}
return true // track transitive dependencies
@@ -2116,7 +2107,7 @@
ctx.ModuleErrorf("unexpected tag %s for indirect dependency %q", android.PrettyPrintTag(depTag), depName)
} else if android.IsVintfDepTag(depTag) {
if vf, ok := android.OtherModuleProvider(ctx, child, android.VintfFragmentInfoProvider); ok {
- apexFile := apexFileForVintfFragment(ctx, child, &commonInfo, &vf)
+ apexFile := apexFileForVintfFragment(ctx, child, commonInfo, &vf)
vctx.filesInfo = append(vctx.filesInfo, apexFile)
}
}
diff --git a/apex/apex_singleton.go b/apex/apex_singleton.go
index 0bf4ba7..797f47b 100644
--- a/apex/apex_singleton.go
+++ b/apex/apex_singleton.go
@@ -164,7 +164,7 @@
prebuiltInfo, exists := android.OtherModuleProvider(ctx, m, android.PrebuiltInfoProvider)
// Use prebuiltInfoProvider to filter out non apex soong modules.
// Use HideFromMake to filter out the unselected variants of a specific apex.
- if exists && !android.OtherModuleProviderOrDefault(ctx, m, android.CommonModuleInfoProvider).HideFromMake {
+ if exists && !android.OtherModulePointerProviderOrDefault(ctx, m, android.CommonModuleInfoProvider).HideFromMake {
prebuiltInfos = append(prebuiltInfos, prebuiltInfo)
}
})
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 36a6974..327e018 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -11468,6 +11468,16 @@
// 1. The contents of the selected apex_contributions are visible to make
// 2. The rest of the apexes in the mainline module family (source or other prebuilt) is hidden from make
checkHideFromMake(t, ctx, tc.expectedVisibleModuleName, tc.expectedHiddenModuleNames)
+
+ // Check that source_apex_name is written as LOCAL_MODULE for make packaging
+ if tc.expectedVisibleModuleName == "prebuilt_com.google.android.foo.v2" {
+ apex := ctx.ModuleForTests(t, "prebuilt_com.google.android.foo.v2", "android_common_prebuilt_com.android.foo").Module()
+ entries := android.AndroidMkEntriesForTest(t, ctx, apex)[0]
+
+ expected := "com.google.android.foo"
+ actual := entries.EntryMap["LOCAL_MODULE"][0]
+ android.AssertStringEquals(t, "LOCAL_MODULE", expected, actual)
+ }
}
}
diff --git a/apex/builder.go b/apex/builder.go
index 8042a3b..23c2ed8 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -1111,7 +1111,7 @@
// Skip dependencies that are only available to APEXes; they are developed with updatability
// in mind and don't need manual approval.
- if android.OtherModuleProviderOrDefault(ctx, to, android.CommonModuleInfoProvider).NotAvailableForPlatform {
+ if android.OtherModulePointerProviderOrDefault(ctx, to, android.CommonModuleInfoProvider).NotAvailableForPlatform {
return !externalDep
}
diff --git a/apex/prebuilt.go b/apex/prebuilt.go
index 89b0091..fdd9a75 100644
--- a/apex/prebuilt.go
+++ b/apex/prebuilt.go
@@ -15,7 +15,9 @@
package apex
import (
+ "fmt"
"slices"
+ "sort"
"strconv"
"strings"
@@ -80,6 +82,10 @@
// systemServerDexJars stores the list of dexjars for system server jars in the prebuilt for use when
// dexpreopting system server jars that are later in the system server classpath.
systemServerDexJars android.Paths
+
+ // Certificate information of any apk packaged inside the prebuilt apex.
+ // This will be nil if the prebuilt apex does not contain any apk.
+ apkCertsFile android.WritablePath
}
type sanitizedPrebuilt interface {
@@ -273,6 +279,10 @@
entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.installable())
entries.AddStrings("LOCAL_OVERRIDES_MODULES", p.prebuiltCommonProperties.Overrides...)
entries.SetString("LOCAL_APEX_KEY_PATH", p.apexKeysPath.String())
+ if p.apkCertsFile != nil {
+ entries.SetString("LOCAL_APKCERTS_FILE", p.apkCertsFile.String())
+ }
+
},
},
},
@@ -286,6 +296,14 @@
len(p.prebuiltCommonProperties.Exported_systemserverclasspath_fragments) > 0
}
+type appInPrebuiltApexDepTag struct {
+ blueprint.BaseDependencyTag
+}
+
+func (appInPrebuiltApexDepTag) ExcludeFromVisibilityEnforcement() {}
+
+var appInPrebuiltApexTag = appInPrebuiltApexDepTag{}
+
// prebuiltApexContentsDeps adds dependencies onto the prebuilt apex module's contents.
func (p *prebuiltCommon) prebuiltApexContentsDeps(ctx android.BottomUpMutatorContext) {
module := ctx.Module()
@@ -432,6 +450,12 @@
ApexFileProperties
PrebuiltCommonProperties
+
+ // List of apps that are bundled inside this prebuilt apex.
+ // This will be used to create the certificate info of those apps for apkcerts.txt
+ // This dependency will only be used for apkcerts.txt processing.
+ // Notably, building the prebuilt apex will not build the source app.
+ Apps []string
}
func (a *Prebuilt) hasSanitizedSource(sanitizer string) bool {
@@ -545,6 +569,9 @@
func (p *Prebuilt) ComponentDepsMutator(ctx android.BottomUpMutatorContext) {
p.prebuiltApexContentsDeps(ctx)
+ for _, app := range p.properties.Apps {
+ ctx.AddDependency(p, appInPrebuiltApexTag, app)
+ }
}
var _ ApexTransitionMutator = (*Prebuilt)(nil)
@@ -677,11 +704,59 @@
p.provenanceMetaDataFile = provenance.GenerateArtifactProvenanceMetaData(ctx, p.inputApex, p.installedFile)
}
+ p.addApkCertsInfo(ctx)
+
ctx.SetOutputFiles(android.Paths{p.outputApex}, "")
android.SetProvider(ctx, filesystem.ApexKeyPathInfoProvider, filesystem.ApexKeyPathInfo{p.apexKeysPath})
}
+// `addApkCertsInfo` sets a provider that will be used to create apkcerts.txt
+func (p *Prebuilt) addApkCertsInfo(ctx android.ModuleContext) {
+ formatLine := func(cert java.Certificate, name, partition string) string {
+ pem := cert.AndroidMkString()
+ var key string
+ if cert.Key == nil {
+ key = ""
+ } else {
+ key = cert.Key.String()
+ }
+ return fmt.Sprintf(`name="%s" certificate="%s" private_key="%s" partition="%s"`, name, pem, key, partition)
+ }
+
+ // Determine if this prebuilt_apex contains any .apks
+ var appInfos java.AppInfos
+ ctx.VisitDirectDepsProxyWithTag(appInPrebuiltApexTag, func(app android.ModuleProxy) {
+ if appInfo, ok := android.OtherModuleProvider(ctx, app, java.AppInfoProvider); ok {
+ appInfos = append(appInfos, *appInfo)
+ } else {
+ ctx.ModuleErrorf("App %s does not set AppInfoProvider\n", app.Name())
+ }
+ })
+ sort.Slice(appInfos, func(i, j int) bool {
+ return appInfos[i].InstallApkName < appInfos[j].InstallApkName
+ })
+
+ if len(appInfos) == 0 {
+ return
+ }
+
+ // Set a provider for use by `android_device`.
+ // `android_device` will create an apkcerts.txt with the list of installed apps for that device.
+ android.SetProvider(ctx, java.AppInfosProvider, appInfos)
+
+ // Set a Make variable for legacy apkcerts.txt creation
+ // p.apkCertsFile will become `LOCAL_APKCERTS_FILE`
+ var lines []string
+ for _, appInfo := range appInfos {
+ lines = append(lines, formatLine(appInfo.Certificate, appInfo.InstallApkName+".apk", p.PartitionTag(ctx.DeviceConfig())))
+ }
+ if len(lines) > 0 {
+ p.apkCertsFile = android.PathForModuleOut(ctx, "apkcerts.txt")
+ android.WriteFileRule(ctx, p.apkCertsFile, strings.Join(lines, "\n"))
+ }
+}
+
func (p *Prebuilt) ProvenanceMetaDataFile() android.Path {
return p.provenanceMetaDataFile
}
diff --git a/bloaty/bloaty.go b/bloaty/bloaty.go
index a076d47..d78a907 100644
--- a/bloaty/bloaty.go
+++ b/bloaty/bloaty.go
@@ -85,7 +85,7 @@
func (singleton *sizesSingleton) GenerateBuildActions(ctx android.SingletonContext) {
var deps android.Paths
ctx.VisitAllModuleProxies(func(m android.ModuleProxy) {
- if !android.OtherModuleProviderOrDefault(ctx, m, android.CommonModuleInfoProvider).ExportedToMake {
+ if !android.OtherModulePointerProviderOrDefault(ctx, m, android.CommonModuleInfoProvider).ExportedToMake {
return
}
filePaths, ok := android.OtherModuleProvider(ctx, m, fileSizeMeasurerKey)
diff --git a/cc/cc.go b/cc/cc.go
index ae6f3b0..c616165 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -2438,6 +2438,27 @@
}
}
+func (c *Module) CleanupAfterBuildActions() {
+ // Clear as much of Module as possible to reduce memory usage.
+ c.generators = nil
+ c.compiler = nil
+ c.installer = nil
+ c.features = nil
+ c.coverage = nil
+ c.fuzzer = nil
+ c.sabi = nil
+ c.lto = nil
+ c.afdo = nil
+ c.orderfile = nil
+
+ // TODO: these can be cleared after nativeBinaryInfoProperties and nativeLibInfoProperties are switched to
+ // using providers.
+ // c.linker = nil
+ // c.stl = nil
+ // c.sanitize = nil
+ // c.library = nil
+}
+
func CreateCommonLinkableInfo(ctx android.ModuleContext, mod VersionedLinkableInterface) *LinkableInfo {
info := &LinkableInfo{
StaticExecutable: mod.StaticExecutable(),
@@ -3422,7 +3443,7 @@
return
}
- commonInfo := android.OtherModuleProviderOrDefault(ctx, dep, android.CommonModuleInfoProvider)
+ commonInfo := android.OtherModulePointerProviderOrDefault(ctx, dep, android.CommonModuleInfoProvider)
if commonInfo.Target.Os != ctx.Os() {
ctx.ModuleErrorf("OS mismatch between %q (%s) and %q (%s)", ctx.ModuleName(), ctx.Os().Name, depName, dep.Target().Os.Name)
return
@@ -3676,7 +3697,7 @@
c.sabi.Properties.ReexportedSystemIncludes, depExporterInfo.SystemIncludeDirs.Strings()...)
}
- makeLibName := MakeLibName(ccInfo, linkableInfo, &commonInfo, commonInfo.BaseModuleName) + libDepTag.makeSuffix
+ makeLibName := MakeLibName(ccInfo, linkableInfo, commonInfo, commonInfo.BaseModuleName) + libDepTag.makeSuffix
switch {
case libDepTag.header():
c.Properties.AndroidMkHeaderLibs = append(
@@ -3703,7 +3724,7 @@
switch depTag {
case runtimeDepTag:
c.Properties.AndroidMkRuntimeLibs = append(
- c.Properties.AndroidMkRuntimeLibs, MakeLibName(ccInfo, linkableInfo, &commonInfo,
+ c.Properties.AndroidMkRuntimeLibs, MakeLibName(ccInfo, linkableInfo, commonInfo,
commonInfo.BaseModuleName)+libDepTag.makeSuffix)
case objDepTag:
depPaths.Objs.objFiles = append(depPaths.Objs.objFiles, linkFile.Path())
@@ -3779,7 +3800,7 @@
// platform APIs, use stubs only when it is from an APEX (and not from
// platform) However, for host, ramdisk, vendor_ramdisk, recovery or
// bootstrap modules, always link to non-stub variant
- isNotInPlatform := android.OtherModuleProviderOrDefault(ctx, dep, android.CommonModuleInfoProvider).NotInPlatform
+ isNotInPlatform := android.OtherModulePointerProviderOrDefault(ctx, dep, android.CommonModuleInfoProvider).NotInPlatform
useStubs = isNotInPlatform && !bootstrap
} else {
diff --git a/cc/compdb.go b/cc/compdb.go
index 4132e09..3818e9c 100644
--- a/cc/compdb.go
+++ b/cc/compdb.go
@@ -193,7 +193,7 @@
}
builds[src.String()] = compDbEntry{
Directory: android.AbsSrcDirForExistingUseCases(),
- Arguments: getArguments(src, ctx, ccModule, ccPath, cxxPath),
+ Arguments: args,
File: src.String(),
}
}
diff --git a/cc/config/arm64_device.go b/cc/config/arm64_device.go
index 45b1580..25edb79 100644
--- a/cc/config/arm64_device.go
+++ b/cc/config/arm64_device.go
@@ -53,6 +53,16 @@
"-mbranch-protection=standard",
"-fno-stack-protector",
},
+ "armv9-3a": []string{
+ "-march=armv9.3-a",
+ "-mbranch-protection=standard",
+ "-fno-stack-protector",
+ },
+ "armv9-4a": []string{
+ "-march=armv9.4-a",
+ "-mbranch-protection=standard",
+ "-fno-stack-protector",
+ },
}
arm64Ldflags = []string{
diff --git a/cc/fdo_profile.go b/cc/fdo_profile.go
index 1a33957..c79ea10 100644
--- a/cc/fdo_profile.go
+++ b/cc/fdo_profile.go
@@ -17,6 +17,8 @@
import (
"android/soong/android"
"github.com/google/blueprint"
+
+ "github.com/google/blueprint/proptools"
)
func init() {
@@ -34,7 +36,7 @@
}
type fdoProfileProperties struct {
- Profile *string `android:"arch_variant"`
+ Profile proptools.Configurable[string] `android:"arch_variant,replace_instead_of_append"`
}
// FdoProfileInfo is provided by FdoProfileProvider
@@ -47,8 +49,9 @@
// GenerateAndroidBuildActions of fdo_profile does not have any build actions
func (fp *fdoProfile) GenerateAndroidBuildActions(ctx android.ModuleContext) {
- if fp.properties.Profile != nil {
- path := android.PathForModuleSrc(ctx, *fp.properties.Profile)
+ profile := fp.properties.Profile.GetOrDefault(ctx, "")
+ if profile != "" {
+ path := android.PathForModuleSrc(ctx, profile)
android.SetProvider(ctx, FdoProfileProvider, FdoProfileInfo{
Path: path,
})
diff --git a/cc/fuzz.go b/cc/fuzz.go
index ba34387..79874fc 100644
--- a/cc/fuzz.go
+++ b/cc/fuzz.go
@@ -486,7 +486,7 @@
sharedLibsInstallDirPrefix = "lib/vendor"
}
- commonInfo := android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoProvider)
+ commonInfo := android.OtherModulePointerProviderOrDefault(ctx, module, android.CommonModuleInfoProvider)
isHost := commonInfo.Target.Os.Class == android.Host
hostOrTargetString := "target"
if commonInfo.Target.HostCross {
diff --git a/cc/library_sdk_member.go b/cc/library_sdk_member.go
index d1440ea..4629030 100644
--- a/cc/library_sdk_member.go
+++ b/cc/library_sdk_member.go
@@ -573,9 +573,8 @@
func getRequiredMemberOutputFile(ctx android.SdkMemberContext, ccModule *Module) android.Path {
var path android.Path
- outputFile := ccModule.OutputFile()
- if outputFile.Valid() {
- path = outputFile.Path()
+ if info, ok := android.OtherModuleProvider(ctx.SdkModuleContext(), ccModule, LinkableInfoProvider); ok && info.OutputFile.Valid() {
+ path = info.OutputFile.Path()
} else {
ctx.SdkModuleContext().ModuleErrorf("member variant %s does not have a valid output file", ccModule)
}
diff --git a/cc/ndk_abi.go b/cc/ndk_abi.go
index a59cc11..b96a779 100644
--- a/cc/ndk_abi.go
+++ b/cc/ndk_abi.go
@@ -40,7 +40,7 @@
func (n *ndkAbiDumpSingleton) GenerateBuildActions(ctx android.SingletonContext) {
var depPaths android.Paths
ctx.VisitAllModuleProxies(func(module android.ModuleProxy) {
- if !android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
+ if !android.OtherModulePointerProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
return
}
@@ -78,7 +78,7 @@
func (n *ndkAbiDiffSingleton) GenerateBuildActions(ctx android.SingletonContext) {
var depPaths android.Paths
ctx.VisitAllModuleProxies(func(module android.ModuleProxy) {
- if !android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
+ if !android.OtherModulePointerProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
return
}
diff --git a/cc/ndk_sysroot.go b/cc/ndk_sysroot.go
index 82a19d0..1677862 100644
--- a/cc/ndk_sysroot.go
+++ b/cc/ndk_sysroot.go
@@ -212,7 +212,7 @@
var licensePaths android.Paths
ctx.VisitAllModuleProxies(func(module android.ModuleProxy) {
- if !android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
+ if !android.OtherModulePointerProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
return
}
diff --git a/cc/sanitize.go b/cc/sanitize.go
index b704ef4..f0b0308 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -1422,6 +1422,7 @@
sanitizers = append(sanitizers,
"bool",
"integer-divide-by-zero",
+ "object-size",
"return",
"returns-nonnull-attribute",
"shift-exponent",
@@ -1438,10 +1439,6 @@
//"shift-base",
//"signed-integer-overflow",
)
-
- if mctx.Config().ReleaseBuildObjectSizeSanitizer() {
- sanitizers = append(sanitizers, "object-size")
- }
}
sanitizers = append(sanitizers, sanProps.Misc_undefined...)
}
diff --git a/cc/tidy.go b/cc/tidy.go
index e8e1dc2..bf273e9 100644
--- a/cc/tidy.go
+++ b/cc/tidy.go
@@ -220,7 +220,7 @@
// (1) Collect all obj/tidy files into OS-specific groups.
ctx.VisitAllModuleVariantProxies(module, func(variant android.ModuleProxy) {
- osName := android.OtherModuleProviderOrDefault(ctx, variant, android.CommonModuleInfoProvider).Target.Os.Name
+ osName := android.OtherModulePointerProviderOrDefault(ctx, variant, android.CommonModuleInfoProvider).Target.Os.Name
info := android.OtherModuleProviderOrDefault(ctx, variant, CcObjectInfoProvider)
addToOSGroup(osName, info.ObjFiles, allObjFileGroups, subsetObjFileGroups)
addToOSGroup(osName, info.TidyFiles, allTidyFileGroups, subsetTidyFileGroups)
diff --git a/ci_tests/ci_test_package_zip.go b/ci_tests/ci_test_package_zip.go
index 95249aa..4cadffd 100644
--- a/ci_tests/ci_test_package_zip.go
+++ b/ci_tests/ci_test_package_zip.go
@@ -68,7 +68,7 @@
pctx = android.NewPackageContext("android/soong/ci_tests")
// test_package module type should only be used for the following modules.
// TODO: remove "_soong" from the module names inside when eliminating the corresponding make modules
- moduleNamesAllowed = []string{"continuous_native_tests_soong", "continuous_instrumentation_tests_soong", "platform_tests"}
+ moduleNamesAllowed = []string{"continuous_instrumentation_tests_soong", "continuous_instrumentation_metric_tests_soong", "continuous_native_tests_soong", "continuous_native_metric_tests_soong", "platform_tests"}
)
func (p *testPackageZip) DepsMutator(ctx android.BottomUpMutatorContext) {
@@ -150,12 +150,6 @@
p.output = createOutput(ctx, pctx)
ctx.SetOutputFiles(android.Paths{p.output}, "")
-
- // dist the test output
- if ctx.ModuleName() == "platform_tests" {
- distedName := ctx.Config().Getenv("TARGET_PRODUCT") + "-tests-FILE_NAME_TAG_PLACEHOLDER.zip"
- ctx.DistForGoalWithFilename("platform_tests", p.output, distedName)
- }
}
func createOutput(ctx android.ModuleContext, pctx android.PackageContext) android.ModuleOutPath {
@@ -284,6 +278,10 @@
android.AndroidMkEntries{
Class: "ETC",
OutputFile: android.OptionalPathForPath(p.output),
+ ExtraEntries: []android.AndroidMkExtraEntriesFunc{
+ func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
+ entries.SetBool("LOCAL_UNINSTALLABLE_MODULE", true)
+ }},
},
}
}
diff --git a/cmd/find_input_delta/find_input_delta_lib/internal_state.go b/cmd/find_input_delta/find_input_delta_lib/internal_state.go
index bf4f866..0f88159 100644
--- a/cmd/find_input_delta/find_input_delta_lib/internal_state.go
+++ b/cmd/find_input_delta/find_input_delta_lib/internal_state.go
@@ -95,9 +95,14 @@
}
ret := []*fid_proto.PartialCompileInput{}
for _, v := range rc.File {
+ // Only include timestamp when there is no CRC.
+ timeNsec := proto.Int64(v.ModTime().UnixNano())
+ if v.CRC32 != 0 {
+ timeNsec = nil
+ }
pci := &fid_proto.PartialCompileInput{
Name: proto.String(v.Name),
- MtimeNsec: proto.Int64(v.ModTime().UnixNano()),
+ MtimeNsec: timeNsec,
Hash: proto.String(fmt.Sprintf("%08x", v.CRC32)),
}
ret = append(ret, pci)
diff --git a/cmd/release_config/release_config_lib/release_configs.go b/cmd/release_config/release_config_lib/release_configs.go
index b0f8cb7..dd98bca 100644
--- a/cmd/release_config/release_config_lib/release_configs.go
+++ b/cmd/release_config/release_config_lib/release_configs.go
@@ -314,6 +314,9 @@
}
}
}
+ if flagDeclaration.Namespace == nil {
+ return fmt.Errorf("Flag declaration %s has no namespace.", path)
+ }
m.FlagDeclarations = append(m.FlagDeclarations, *flagDeclaration)
name := *flagDeclaration.Name
diff --git a/cmd/soong_ui/main.go b/cmd/soong_ui/main.go
index 4f6de82..584cc04 100644
--- a/cmd/soong_ui/main.go
+++ b/cmd/soong_ui/main.go
@@ -333,7 +333,7 @@
varName := flags.Arg(0)
if varName == "report_config" {
- varData, err := build.DumpMakeVars(ctx, config, nil, build.BannerVars)
+ varData, err := build.DumpMakeVars(ctx, config, nil, append(build.BannerVars, "PRODUCT_SOONG_ONLY"))
if err != nil {
ctx.Fatal(err)
}
@@ -400,7 +400,7 @@
if i := indexList("report_config", allVars); i != -1 {
allVars = append(allVars[:i], allVars[i+1:]...)
- allVars = append(allVars, build.BannerVars...)
+ allVars = append(allVars, append(build.BannerVars, "PRODUCT_SOONG_ONLY")...)
}
if len(allVars) == 0 {
diff --git a/dexpreopt/config.go b/dexpreopt/config.go
index 9cec9db..af09dbc 100644
--- a/dexpreopt/config.go
+++ b/dexpreopt/config.go
@@ -139,6 +139,11 @@
// Returns all jars that system_server loads.
func (g *GlobalConfig) AllSystemServerJars(ctx android.PathContext) *android.ConfiguredJarList {
+ // dexpreopt does not initialize the soong config.
+ // Initialize the OncePer here.
+ if ctx.Config().OncePer == nil {
+ ctx.Config().OncePer = &android.OncePer{}
+ }
return ctx.Config().Once(allSystemServerJarsKey, func() interface{} {
res := g.AllPlatformSystemServerJars(ctx).AppendList(g.AllApexSystemServerJars(ctx))
return &res
@@ -464,7 +469,7 @@
func (d dex2oatDependencyTag) AllowDisabledModuleDependencyProxy(
ctx android.OtherModuleProviderContext, target android.ModuleProxy) bool {
- return android.OtherModuleProviderOrDefault(
+ return android.OtherModulePointerProviderOrDefault(
ctx, target, android.CommonModuleInfoProvider).ReplacedByPrebuilt
}
diff --git a/etc/prebuilt_etc.go b/etc/prebuilt_etc.go
index 3b0c032..7820047 100644
--- a/etc/prebuilt_etc.go
+++ b/etc/prebuilt_etc.go
@@ -78,6 +78,7 @@
ctx.RegisterModuleType("prebuilt_rfs", PrebuiltRfsFactory)
ctx.RegisterModuleType("prebuilt_framework", PrebuiltFrameworkFactory)
ctx.RegisterModuleType("prebuilt_res", PrebuiltResFactory)
+ ctx.RegisterModuleType("prebuilt_tee", PrebuiltTeeFactory)
ctx.RegisterModuleType("prebuilt_wlc_upt", PrebuiltWlcUptFactory)
ctx.RegisterModuleType("prebuilt_odm", PrebuiltOdmFactory)
ctx.RegisterModuleType("prebuilt_vendor_dlkm", PrebuiltVendorDlkmFactory)
@@ -910,6 +911,16 @@
return module
}
+// prebuilt_tee installs files in <partition>/tee directory.
+func PrebuiltTeeFactory() android.Module {
+ module := &PrebuiltEtc{}
+ InitPrebuiltEtcModule(module, "tee")
+ // This module is device-only
+ android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibCommon)
+ android.InitDefaultableModule(module)
+ return module
+}
+
// prebuilt_media installs media files in <partition>/media directory.
func PrebuiltMediaFactory() android.Module {
module := &PrebuiltEtc{}
diff --git a/filesystem/android_device.go b/filesystem/android_device.go
index 56a681f..8b6ea49 100644
--- a/filesystem/android_device.go
+++ b/filesystem/android_device.go
@@ -1127,6 +1127,7 @@
}
apkCerts := []string{}
+ var apkCertsFiles android.Paths
for _, installedModule := range allInstalledModules {
partition := ""
if commonInfo, ok := android.OtherModuleProvider(ctx, installedModule, android.CommonModuleInfoProvider); ok {
@@ -1135,7 +1136,11 @@
ctx.ModuleErrorf("%s does not set CommonModuleInfoKey", installedModule.Name())
}
if info, ok := android.OtherModuleProvider(ctx, installedModule, java.AppInfoProvider); ok {
- apkCerts = append(apkCerts, formatLine(info.Certificate, info.InstallApkName+".apk", partition))
+ if info.AppSet {
+ apkCertsFiles = append(apkCertsFiles, info.ApkCertsFile)
+ } else {
+ apkCerts = append(apkCerts, formatLine(info.Certificate, info.InstallApkName+".apk", partition))
+ }
} else if info, ok := android.OtherModuleProvider(ctx, installedModule, java.AppInfosProvider); ok {
for _, certInfo := range info {
// Partition information of apk-in-apex is not exported to the legacy Make packaging system.
@@ -1156,7 +1161,14 @@
}
}
+ apkCertsInfoWithoutAppSets := android.PathForModuleOut(ctx, "apkcerts_without_app_sets.txt")
+ android.WriteFileRuleVerbatim(ctx, apkCertsInfoWithoutAppSets, strings.Join(apkCerts, "\n")+"\n")
apkCertsInfo := android.PathForModuleOut(ctx, "apkcerts.txt")
- android.WriteFileRuleVerbatim(ctx, apkCertsInfo, strings.Join(apkCerts, "\n")+"\n")
+ ctx.Build(pctx, android.BuildParams{
+ Rule: android.Cat,
+ Description: "combine apkcerts.txt",
+ Output: apkCertsInfo,
+ Inputs: append(apkCertsFiles, apkCertsInfoWithoutAppSets),
+ })
return apkCertsInfo
}
diff --git a/filesystem/android_device_product_out.go b/filesystem/android_device_product_out.go
index 7d37f1e..aa06337 100644
--- a/filesystem/android_device_product_out.go
+++ b/filesystem/android_device_product_out.go
@@ -167,7 +167,7 @@
}
if proptools.String(a.deviceProps.Android_info) != "" {
- installPath := android.PathForModuleInPartitionInstall(ctx, "", "android_info.txt")
+ installPath := android.PathForModuleInPartitionInstall(ctx, "", "android-info.txt")
ctx.Build(pctx, android.BuildParams{
Rule: android.Cp,
Input: android.PathForModuleSrc(ctx, *a.deviceProps.Android_info),
diff --git a/filesystem/avb_add_hash_footer.go b/filesystem/avb_add_hash_footer.go
index 327a41f..c776012 100644
--- a/filesystem/avb_add_hash_footer.go
+++ b/filesystem/avb_add_hash_footer.go
@@ -70,7 +70,7 @@
Props []avbProp
// The index used to prevent rollback of the image on device.
- Rollback_index *int64
+ Rollback_index proptools.Configurable[int64] `android:"replace_instead_of_append"`
// Include descriptors from images
Include_descriptors_from_images []string `android:"path,arch_variant"`
@@ -134,8 +134,9 @@
addAvbProp(ctx, cmd, prop)
}
- if a.properties.Rollback_index != nil {
- rollbackIndex := proptools.Int(a.properties.Rollback_index)
+ rollbackIndex := a.properties.Rollback_index.Get(ctx)
+ if rollbackIndex.IsPresent() {
+ rollbackIndex := rollbackIndex.Get()
if rollbackIndex < 0 {
ctx.PropertyErrorf("rollback_index", "Rollback index must be non-negative")
}
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index 0b17025..c3c3835 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -1589,7 +1589,7 @@
deps := f.gatherFilteredPackagingSpecs(ctx)
ctx.WalkDepsProxy(func(child, parent android.ModuleProxy) bool {
- if !android.OtherModuleProviderOrDefault(ctx, child, android.CommonModuleInfoProvider).Enabled {
+ if !android.OtherModulePointerProviderOrDefault(ctx, child, android.CommonModuleInfoProvider).Enabled {
return false
}
for _, ps := range android.OtherModuleProviderOrDefault(
@@ -1610,7 +1610,7 @@
var requireModules []android.ModuleProxy
ctx.WalkDepsProxy(func(child, parent android.ModuleProxy) bool {
- if !android.OtherModuleProviderOrDefault(ctx, child, android.CommonModuleInfoProvider).Enabled {
+ if !android.OtherModulePointerProviderOrDefault(ctx, child, android.CommonModuleInfoProvider).Enabled {
return false
}
_, parentInPackage := modulesInPackageByModule[parent]
diff --git a/filesystem/filesystem_test.go b/filesystem/filesystem_test.go
index 6d0b490..e57e45c 100644
--- a/filesystem/filesystem_test.go
+++ b/filesystem/filesystem_test.go
@@ -723,26 +723,60 @@
// override_android_* modules implicitly override their base module.
// If both of these are listed in `deps`, the base module should not be installed.
+// Also, required deps should be updated too.
func TestOverrideModulesInDeps(t *testing.T) {
result := fixture.RunTestWithBp(t, `
- android_filesystem {
- name: "myfilesystem",
- deps: ["myapp", "myoverrideapp"],
+ cc_library_shared {
+ name: "libfoo",
+ stl: "none",
+ system_shared_libs: [],
}
-
+ cc_library_shared {
+ name: "libbar",
+ stl: "none",
+ system_shared_libs: [],
+ }
+ phony {
+ name: "myapp_phony",
+ required: ["myapp"],
+ }
+ phony {
+ name: "myoverrideapp_phony",
+ required: ["myoverrideapp"],
+ }
android_app {
name: "myapp",
platform_apis: true,
+ required: ["libfoo"],
}
override_android_app {
name: "myoverrideapp",
base: "myapp",
+ required: ["libbar"],
+ }
+ android_filesystem {
+ name: "myfilesystem",
+ deps: ["myapp"],
+ }
+ android_filesystem {
+ name: "myfilesystem_overridden",
+ deps: ["myapp", "myoverrideapp"],
+ }
+ android_filesystem {
+ name: "myfilesystem_overridden_indirect",
+ deps: ["myapp_phony", "myoverrideapp_phony"],
}
`)
partition := result.ModuleForTests(t, "myfilesystem", "android_common")
fileList := android.ContentFromFileRuleForTests(t, result.TestContext, partition.Output("fileList"))
- android.AssertStringEquals(t, "filesystem with override app", "app/myoverrideapp/myoverrideapp.apk\n", fileList)
+ android.AssertStringEquals(t, "filesystem without override app", "app/myapp/myapp.apk\nlib64/libfoo.so\n", fileList)
+
+ for _, overridden := range []string{"myfilesystem_overridden", "myfilesystem_overridden_indirect"} {
+ overriddenPartition := result.ModuleForTests(t, overridden, "android_common")
+ overriddenFileList := android.ContentFromFileRuleForTests(t, result.TestContext, overriddenPartition.Output("fileList"))
+ android.AssertStringEquals(t, "filesystem with "+overridden, "app/myoverrideapp/myoverrideapp.apk\nlib64/libbar.so\n", overriddenFileList)
+ }
}
func TestRamdiskPartitionSetsDevNodes(t *testing.T) {
diff --git a/filesystem/system_other.go b/filesystem/system_other.go
index 348c010..32a6cc7 100644
--- a/filesystem/system_other.go
+++ b/filesystem/system_other.go
@@ -120,8 +120,11 @@
// TOOD: CopySpecsToDir only exists on PackagingBase, but doesn't use any fields from it. Clean this up.
(&android.PackagingBase{}).CopySpecsToDir(ctx, builder, specs, stagingDir)
+ fullInstallPaths := []string{}
if len(m.properties.Preinstall_dexpreopt_files_from) > 0 {
builder.Command().Textf("touch %s", filepath.Join(stagingDir.String(), "system-other-odex-marker"))
+ installPath := android.PathForModuleInPartitionInstall(ctx, "system_other", "system-other-odex-marker")
+ fullInstallPaths = append(fullInstallPaths, installPath.String())
}
builder.Command().Textf("touch").Output(stagingDirTimestamp)
builder.Build("assemble_filesystem_staging_dir", "Assemble filesystem staging dir")
@@ -186,6 +189,10 @@
ctx.SetOutputFiles(android.Paths{output}, "")
ctx.CheckbuildFile(output)
+
+ // Dump compliance metadata
+ complianceMetadataInfo := ctx.ComplianceMetadataInfo()
+ complianceMetadataInfo.SetFilesContained(fullInstallPaths)
}
func (s *systemOtherImage) generateFilesystemConfig(ctx android.ModuleContext, stagingDir, stagingDirTimestamp android.Path) android.Path {
diff --git a/fsgen/filesystem_creator_test.go b/fsgen/filesystem_creator_test.go
index 81236a0..2c4d3c8 100644
--- a/fsgen/filesystem_creator_test.go
+++ b/fsgen/filesystem_creator_test.go
@@ -289,6 +289,10 @@
"device/sample/etc/apns-full-conf.xml:product/etc/apns-conf-2.xml",
"device/sample/etc/apns-full-conf.xml:system/foo/file.txt",
"device/sample/etc/apns-full-conf.xml:system/foo/apns-full-conf.xml",
+ "device/sample/firmware/firmware.bin:recovery/root/firmware.bin",
+ "device/sample/firmware/firmware.bin:recovery/root/firmware-2.bin",
+ "device/sample/firmware/firmware.bin:recovery/root/lib/firmware/firmware.bin",
+ "device/sample/firmware/firmware.bin:recovery/root/lib/firmware/firmware-2.bin",
}
config.TestProductVariables.PartitionVarsForSoongMigrationOnlyDoNotUse.PartitionQualifiedVariables =
map[string]android.PartitionQualifiedVariablesType{
@@ -309,22 +313,23 @@
"frameworks/base/data/keyboards/Vendor_0079_Product_0011.kl": nil,
"frameworks/base/data/keyboards/Vendor_0079_Product_18d4.kl": nil,
"device/sample/etc/apns-full-conf.xml": nil,
+ "device/sample/firmware/firmware.bin": nil,
}),
).RunTest(t)
- checkModuleProp := func(m android.Module, matcher func(actual interface{}) bool) bool {
+ getModuleProp := func(m android.Module, matcher func(actual interface{}) string) string {
for _, prop := range m.GetProperties() {
- if matcher(prop) {
- return true
+ if str := matcher(prop); str != "" {
+ return str
}
}
- return false
+ return ""
}
// check generated prebuilt_* module type install path and install partition
generatedModule := result.ModuleForTests(t, "system-frameworks_base_config-etc-0", "android_arm64_armv8-a").Module()
- etcModule, _ := generatedModule.(*etc.PrebuiltEtc)
+ etcModule := generatedModule.(*etc.PrebuiltEtc)
android.AssertStringEquals(
t,
"module expected to have etc install path",
@@ -342,7 +347,7 @@
// check generated prebuilt_* module specifies correct relative_install_path property
generatedModule = result.ModuleForTests(t, "system-frameworks_base_data_keyboards-usr_keylayout_subdir-0", "android_arm64_armv8-a").Module()
- etcModule, _ = generatedModule.(*etc.PrebuiltEtc)
+ etcModule = generatedModule.(*etc.PrebuiltEtc)
android.AssertStringEquals(
t,
"module expected to set correct relative_install_path properties",
@@ -350,6 +355,37 @@
etcModule.SubDir(),
)
+ // check that generated prebuilt_* module sets correct srcs
+ eval := generatedModule.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext))
+ android.AssertStringEquals(
+ t,
+ "module expected to set correct srcs property",
+ "Vendor_0079_Product_0011.kl",
+ getModuleProp(generatedModule, func(actual interface{}) string {
+ if p, ok := actual.(*etc.PrebuiltEtcProperties); ok {
+ srcs := p.Srcs.GetOrDefault(eval, nil)
+ if len(srcs) == 2 {
+ return srcs[0]
+ }
+ }
+ return ""
+ }),
+ )
+ android.AssertStringEquals(
+ t,
+ "module expected to set correct srcs property",
+ "Vendor_0079_Product_18d4.kl",
+ getModuleProp(generatedModule, func(actual interface{}) string {
+ if p, ok := actual.(*etc.PrebuiltEtcProperties); ok {
+ srcs := p.Srcs.GetOrDefault(eval, nil)
+ if len(srcs) == 2 {
+ return srcs[1]
+ }
+ }
+ return ""
+ }),
+ )
+
// check that prebuilt_* module is not generated for non existing source file
android.AssertStringEquals(
t,
@@ -363,60 +399,264 @@
generatedModule1 := result.ModuleForTests(t, "product-device_sample_etc-etc-1", "android_arm64_armv8-a").Module()
// check that generated prebuilt_* module sets correct srcs and dsts property
- eval := generatedModule0.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext))
- android.AssertBoolEquals(
+ eval = generatedModule0.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext))
+ android.AssertStringEquals(
t,
"module expected to set correct srcs property",
- true,
- checkModuleProp(generatedModule0, func(actual interface{}) bool {
+ "apns-full-conf.xml",
+ getModuleProp(generatedModule0, func(actual interface{}) string {
if p, ok := actual.(*etc.PrebuiltEtcProperties); ok {
srcs := p.Srcs.GetOrDefault(eval, nil)
- return len(srcs) == 1 &&
- srcs[0] == "apns-full-conf.xml"
+ if len(srcs) == 1 {
+ return srcs[0]
+ }
}
- return false
+ return ""
}),
)
- android.AssertBoolEquals(
+ android.AssertStringEquals(
t,
"module expected to set correct dsts property",
- true,
- checkModuleProp(generatedModule0, func(actual interface{}) bool {
+ "apns-conf.xml",
+ getModuleProp(generatedModule0, func(actual interface{}) string {
if p, ok := actual.(*etc.PrebuiltDstsProperties); ok {
dsts := p.Dsts.GetOrDefault(eval, nil)
- return len(dsts) == 1 &&
- dsts[0] == "apns-conf.xml"
+ if len(dsts) == 1 {
+ return dsts[0]
+ }
}
- return false
+ return ""
}),
)
// check that generated prebuilt_* module sets correct srcs and dsts property
eval = generatedModule1.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext))
- android.AssertBoolEquals(
+ android.AssertStringEquals(
t,
"module expected to set correct srcs property",
- true,
- checkModuleProp(generatedModule1, func(actual interface{}) bool {
+ "apns-full-conf.xml",
+ getModuleProp(generatedModule1, func(actual interface{}) string {
if p, ok := actual.(*etc.PrebuiltEtcProperties); ok {
srcs := p.Srcs.GetOrDefault(eval, nil)
- return len(srcs) == 1 &&
- srcs[0] == "apns-full-conf.xml"
+ if len(srcs) == 1 {
+ return srcs[0]
+ }
}
- return false
+ return ""
}),
)
- android.AssertBoolEquals(
+ android.AssertStringEquals(
t,
"module expected to set correct dsts property",
- true,
- checkModuleProp(generatedModule1, func(actual interface{}) bool {
+ "apns-conf-2.xml",
+ getModuleProp(generatedModule1, func(actual interface{}) string {
if p, ok := actual.(*etc.PrebuiltDstsProperties); ok {
dsts := p.Dsts.GetOrDefault(eval, nil)
- return len(dsts) == 1 &&
- dsts[0] == "apns-conf-2.xml"
+ if len(dsts) == 1 {
+ return dsts[0]
+ }
}
- return false
+ return ""
+ }),
+ )
+
+ generatedModule0 = result.ModuleForTests(t, "system-device_sample_etc-foo-0", "android_common").Module()
+ generatedModule1 = result.ModuleForTests(t, "system-device_sample_etc-foo-1", "android_common").Module()
+
+ // check that generated prebuilt_* module sets correct srcs and dsts property
+ eval = generatedModule0.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext))
+ android.AssertStringEquals(
+ t,
+ "module expected to set correct srcs property",
+ "apns-full-conf.xml",
+ getModuleProp(generatedModule0, func(actual interface{}) string {
+ if p, ok := actual.(*etc.PrebuiltEtcProperties); ok {
+ srcs := p.Srcs.GetOrDefault(eval, nil)
+ if len(srcs) == 1 {
+ return srcs[0]
+ }
+ }
+ return ""
+ }),
+ )
+ android.AssertStringEquals(
+ t,
+ "module expected to set correct dsts property",
+ "foo/file.txt",
+ getModuleProp(generatedModule0, func(actual interface{}) string {
+ if p, ok := actual.(*etc.PrebuiltDstsProperties); ok {
+ dsts := p.Dsts.GetOrDefault(eval, nil)
+ if len(dsts) == 1 {
+ return dsts[0]
+ }
+ }
+ return ""
+ }),
+ )
+
+ // check generated prebuilt_* module specifies correct install path and relative install path
+ etcModule = generatedModule1.(*etc.PrebuiltEtc)
+ android.AssertStringEquals(
+ t,
+ "module expected to have . install path",
+ ".",
+ etcModule.BaseDir(),
+ )
+ android.AssertStringEquals(
+ t,
+ "module expected to set correct relative_install_path properties",
+ "foo",
+ etcModule.SubDir(),
+ )
+
+ // check that generated prebuilt_* module sets correct srcs
+ eval = generatedModule1.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext))
+ android.AssertStringEquals(
+ t,
+ "module expected to set correct srcs property",
+ "apns-full-conf.xml",
+ getModuleProp(generatedModule1, func(actual interface{}) string {
+ if p, ok := actual.(*etc.PrebuiltEtcProperties); ok {
+ srcs := p.Srcs.GetOrDefault(eval, nil)
+ if len(srcs) == 1 {
+ return srcs[0]
+ }
+ }
+ return ""
+ }),
+ )
+
+ generatedModule0 = result.ModuleForTests(t, "recovery-device_sample_firmware-0", "android_recovery_arm64_armv8-a").Module()
+ generatedModule1 = result.ModuleForTests(t, "recovery-device_sample_firmware-1", "android_recovery_common").Module()
+
+ // check generated prebuilt_* module specifies correct install path and relative install path
+ etcModule = generatedModule0.(*etc.PrebuiltEtc)
+ android.AssertStringEquals(
+ t,
+ "module expected to have . install path",
+ ".",
+ etcModule.BaseDir(),
+ )
+ android.AssertStringEquals(
+ t,
+ "module expected to set empty relative_install_path properties",
+ "",
+ etcModule.SubDir(),
+ )
+
+ // check that generated prebuilt_* module don't set dsts
+ eval = generatedModule0.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext))
+ android.AssertStringEquals(
+ t,
+ "module expected to not set dsts property",
+ "",
+ getModuleProp(generatedModule0, func(actual interface{}) string {
+ if p, ok := actual.(*etc.PrebuiltDstsProperties); ok {
+ dsts := p.Dsts.GetOrDefault(eval, nil)
+ if len(dsts) != 0 {
+ return dsts[0]
+ }
+ }
+ return ""
+ }),
+ )
+
+ // check generated prebuilt_* module specifies correct install path and relative install path
+ etcModule = generatedModule1.(*etc.PrebuiltEtc)
+ android.AssertStringEquals(
+ t,
+ "module expected to have . install path",
+ ".",
+ etcModule.BaseDir(),
+ )
+ android.AssertStringEquals(
+ t,
+ "module expected to set empty relative_install_path properties",
+ "",
+ etcModule.SubDir(),
+ )
+
+ // check that generated prebuilt_* module sets correct dsts
+ eval = generatedModule1.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext))
+ android.AssertStringEquals(
+ t,
+ "module expected to set correct dsts property",
+ "firmware-2.bin",
+ getModuleProp(generatedModule1, func(actual interface{}) string {
+ if p, ok := actual.(*etc.PrebuiltDstsProperties); ok {
+ dsts := p.Dsts.GetOrDefault(eval, nil)
+ if len(dsts) == 1 {
+ return dsts[0]
+ }
+ }
+ return ""
+ }),
+ )
+
+ generatedModule0 = result.ModuleForTests(t, "recovery-device_sample_firmware-lib_firmware-0", "android_recovery_common").Module()
+ generatedModule1 = result.ModuleForTests(t, "recovery-device_sample_firmware-lib_firmware-1", "android_recovery_common").Module()
+
+ // check generated prebuilt_* module specifies correct install path and relative install path
+ etcModule = generatedModule0.(*etc.PrebuiltEtc)
+ android.AssertStringEquals(
+ t,
+ "module expected to have . install path",
+ ".",
+ etcModule.BaseDir(),
+ )
+ android.AssertStringEquals(
+ t,
+ "module expected to set correct relative_install_path properties",
+ "lib/firmware",
+ etcModule.SubDir(),
+ )
+
+ // check that generated prebuilt_* module sets correct srcs
+ eval = generatedModule0.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext))
+ android.AssertStringEquals(
+ t,
+ "module expected to not set dsts property",
+ "",
+ getModuleProp(generatedModule0, func(actual interface{}) string {
+ if p, ok := actual.(*etc.PrebuiltDstsProperties); ok {
+ dsts := p.Dsts.GetOrDefault(eval, nil)
+ if len(dsts) != 0 {
+ return dsts[0]
+ }
+ }
+ return ""
+ }),
+ )
+
+ // check generated prebuilt_* module specifies correct install path and relative install path
+ etcModule = generatedModule1.(*etc.PrebuiltEtc)
+ android.AssertStringEquals(
+ t,
+ "module expected to have . install path",
+ ".",
+ etcModule.BaseDir(),
+ )
+ android.AssertStringEquals(
+ t,
+ "module expected to set empty relative_install_path properties",
+ "",
+ etcModule.SubDir(),
+ )
+
+ // check that generated prebuilt_* module sets correct srcs
+ eval = generatedModule1.ConfigurableEvaluator(android.PanickingConfigAndErrorContext(result.TestContext))
+ android.AssertStringEquals(
+ t,
+ "module expected to set correct dsts property",
+ "lib/firmware/firmware-2.bin",
+ getModuleProp(generatedModule1, func(actual interface{}) string {
+ if p, ok := actual.(*etc.PrebuiltDstsProperties); ok {
+ dsts := p.Dsts.GetOrDefault(eval, nil)
+ if len(dsts) == 1 {
+ return dsts[0]
+ }
+ }
+ return ""
}),
)
}
diff --git a/fsgen/prebuilt_etc_modules_gen.go b/fsgen/prebuilt_etc_modules_gen.go
index df36197..c0f114c 100644
--- a/fsgen/prebuilt_etc_modules_gen.go
+++ b/fsgen/prebuilt_etc_modules_gen.go
@@ -215,6 +215,7 @@
"system": etc.PrebuiltSystemFactory,
"res": etc.PrebuiltResFactory,
"rfs": etc.PrebuiltRfsFactory,
+ "tee": etc.PrebuiltTeeFactory,
"tts": etc.PrebuiltVoicepackFactory,
"tvconfig": etc.PrebuiltTvConfigFactory,
"tvservice": etc.PrebuiltTvServiceFactory,
@@ -336,32 +337,43 @@
propsList = append(propsList, &prebuiltInstallInRootProperties{
Install_in_root: proptools.BoolPtr(true),
})
+ // Discard any previously picked module and force it to prebuilt_{root,any} as
+ // they are the only modules allowed to specify the `install_in_root` property.
+ etcInstallPathKey = ""
+ relDestDirFromInstallDirBase = destDir
}
// Set appropriate srcs, dsts, and releative_install_path based on
// the source and install file names
- if allCopyFileNamesUnchanged {
- modulePropsPtr.Srcs = srcBaseFiles
+ modulePropsPtr.Srcs = srcBaseFiles
- // Specify relative_install_path if it is not installed in the root directory of the
- // partition
+ // prebuilt_root should only be used in very limited cases in prebuilt_etc moddule gen, where:
+ // - all source file names are identical to the installed file names, and
+ // - all source files are installed in root, not the subdirectories of root
+ // prebuilt_root currently does not have a good way to specify the names of the multiple
+ // installed files, and prebuilt_root does not allow installing files at a subdirectory
+ // of the root.
+ // Use prebuilt_any instead of prebuilt_root if either of the conditions are not met as
+ // a fallback behavior.
+ if etcInstallPathKey == "" {
+ if !(allCopyFileNamesUnchanged && android.InList(relDestDirFromInstallDirBase, []string{"", "."})) {
+ moduleFactory = etc.PrebuiltAnyFactory
+ }
+ }
+
+ if allCopyFileNamesUnchanged {
+ // Specify relative_install_path if it is not installed in the base directory of the module.
+ // In case of prebuilt_{root,any} this is equivalent to the root of the partition.
if !android.InList(relDestDirFromInstallDirBase, []string{"", "."}) {
propsList = append(propsList, &prebuiltSubdirProperties{
Relative_install_path: proptools.StringPtr(relDestDirFromInstallDirBase),
})
}
} else {
- // If dsts property has to be set and the selected module type is prebuilt_root,
- // use prebuilt_any instead.
- if etcInstallPathKey == "" {
- moduleFactory = etc.PrebuiltAnyFactory
- }
- modulePropsPtr.Srcs = srcBaseFiles
dsts := proptools.NewConfigurable[[]string](nil, nil)
for _, installBaseFile := range installBaseFiles {
dsts.AppendSimpleValue([]string{filepath.Join(relDestDirFromInstallDirBase, installBaseFile)})
}
-
propsList = append(propsList, &etc.PrebuiltDstsProperties{
Dsts: dsts,
})
diff --git a/genrule/Android.bp b/genrule/Android.bp
index 49df480..b82f2a9 100644
--- a/genrule/Android.bp
+++ b/genrule/Android.bp
@@ -14,7 +14,6 @@
"soong-shared",
],
srcs: [
- "allowlists.go",
"genrule.go",
"locations.go",
],
diff --git a/genrule/allowlists.go b/genrule/allowlists.go
deleted file mode 100644
index 45a7f72..0000000
--- a/genrule/allowlists.go
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2023 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 genrule
-
-var (
- SandboxingDenyModuleList = []string{
- // go/keep-sorted start
- // go/keep-sorted end
- }
-)
diff --git a/genrule/genrule.go b/genrule/genrule.go
index e976e6b..a7c09e7 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -112,7 +112,7 @@
func (t hostToolDependencyTag) AllowDisabledModuleDependencyProxy(
ctx android.OtherModuleProviderContext, target android.ModuleProxy) bool {
- return android.OtherModuleProviderOrDefault(
+ return android.OtherModulePointerProviderOrDefault(
ctx, target, android.CommonModuleInfoProvider).ReplacedByPrebuilt
}
@@ -353,7 +353,7 @@
if h, ok := android.OtherModuleProvider(ctx, module, android.HostToolProviderInfoProvider); ok {
// A HostToolProvider provides the path to a tool, which will be copied
// into the sandbox.
- if !android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
+ if !android.OtherModulePointerProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
if ctx.Config().AllowMissingDependencies() {
ctx.AddMissingDependencies([]string{tool})
} else {
@@ -969,30 +969,9 @@
return module
}
-var sandboxingAllowlistKey = android.NewOnceKey("genruleSandboxingAllowlistKey")
-
-type sandboxingAllowlistSets struct {
- sandboxingDenyModuleSet map[string]bool
-}
-
-func getSandboxingAllowlistSets(ctx android.PathContext) *sandboxingAllowlistSets {
- return ctx.Config().Once(sandboxingAllowlistKey, func() interface{} {
- sandboxingDenyModuleSet := map[string]bool{}
-
- android.AddToStringSet(sandboxingDenyModuleSet, SandboxingDenyModuleList)
- return &sandboxingAllowlistSets{
- sandboxingDenyModuleSet: sandboxingDenyModuleSet,
- }
- }).(*sandboxingAllowlistSets)
-}
-
func getSandboxedRuleBuilder(ctx android.ModuleContext, r *android.RuleBuilder) *android.RuleBuilder {
if !ctx.DeviceConfig().GenruleSandboxing() {
return r.SandboxTools()
}
- sandboxingAllowlistSets := getSandboxingAllowlistSets(ctx)
- if sandboxingAllowlistSets.sandboxingDenyModuleSet[ctx.ModuleName()] {
- return r.SandboxTools()
- }
return r.SandboxInputs()
}
diff --git a/java/app.go b/java/app.go
index 560129b..05b4a96 100644
--- a/java/app.go
+++ b/java/app.go
@@ -82,6 +82,7 @@
Certificate Certificate
PrivAppAllowlist android.OptionalPath
OverriddenManifestPackageName *string
+ ApkCertsFile android.Path
}
var AppInfoProvider = blueprint.NewProvider[*AppInfo]()
@@ -691,7 +692,7 @@
}
// Use non final ids if we are doing optimized shrinking and are using R8.
- nonFinalIds := a.dexProperties.optimizedResourceShrinkingEnabled(ctx) && a.dexer.effectiveOptimizeEnabled()
+ nonFinalIds := a.dexProperties.optimizedResourceShrinkingEnabled(ctx) && a.dexer.effectiveOptimizeEnabled(ctx)
aconfigTextFilePaths := getAconfigFilePaths(ctx)
@@ -1233,7 +1234,7 @@
seenModulePaths := make(map[string]bool)
ctx.WalkDepsProxy(func(module, parent android.ModuleProxy) bool {
- if !android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
+ if !android.OtherModulePointerProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
return false
}
otherName := ctx.OtherModuleName(module)
@@ -1253,7 +1254,7 @@
}
seenModulePaths[path.String()] = true
- commonInfo := android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoProvider)
+ commonInfo := android.OtherModulePointerProviderOrDefault(ctx, module, android.CommonModuleInfoProvider)
if checkNativeSdkVersion && commonInfo.SdkVersion == "" {
ctx.PropertyErrorf("jni_libs", "JNI dependency %q uses platform APIs, but this module does not",
otherName)
@@ -1316,7 +1317,7 @@
// Skip dependencies that are only available to APEXes; they are developed with updatability
// in mind and don't need manual approval.
- if android.OtherModuleProviderOrDefault(ctx, to, android.CommonModuleInfoProvider).NotAvailableForPlatform {
+ if android.OtherModulePointerProviderOrDefault(ctx, to, android.CommonModuleInfoProvider).NotAvailableForPlatform {
return true
}
diff --git a/java/app_import.go b/java/app_import.go
index c0e8171..9fb13ba 100644
--- a/java/app_import.go
+++ b/java/app_import.go
@@ -338,7 +338,7 @@
for _, target := range ctx.MultiTargets() {
supported_abis := target.Arch.Abi
for _, arch := range supported_abis {
- wantedJniLibSlice = append(wantedJniLibSlice, " -X lib/"+arch+"/*.so")
+ wantedJniLibSlice = append(wantedJniLibSlice, " -X 'lib/"+arch+"/*.so'")
}
}
wantedJniLibString := strings.Join(wantedJniLibSlice, " ")
diff --git a/java/app_set.go b/java/app_set.go
index 2e9d314..6a2c678 100644
--- a/java/app_set.go
+++ b/java/app_set.go
@@ -193,9 +193,10 @@
)
android.SetProvider(ctx, AppInfoProvider, &AppInfo{
- AppSet: true,
- Privileged: as.Privileged(),
- OutputFile: as.OutputFile(),
+ AppSet: true,
+ Privileged: as.Privileged(),
+ OutputFile: as.OutputFile(),
+ ApkCertsFile: as.apkcertsFile,
})
}
diff --git a/java/base.go b/java/base.go
index 8453a68..8aa0109 100644
--- a/java/base.go
+++ b/java/base.go
@@ -629,7 +629,7 @@
return nil
}
if info.SdkVersion.Kind == android.SdkCorePlatform {
- if useLegacyCorePlatformApi(ctx, android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).BaseModuleName) {
+ if useLegacyCorePlatformApi(ctx, android.OtherModulePointerProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).BaseModuleName) {
return fmt.Errorf("non stable SDK %v - uses legacy core platform", info.SdkVersion)
} else {
// Treat stable core platform as stable.
@@ -1816,7 +1816,7 @@
classesJar: outputFile,
jarName: jarName,
}
- if j.GetProfileGuided(ctx) && j.optimizeOrObfuscateEnabled() && !j.EnableProfileRewriting(ctx) {
+ if j.GetProfileGuided(ctx) && j.optimizeOrObfuscateEnabled(ctx) && !j.EnableProfileRewriting(ctx) {
ctx.PropertyErrorf("enable_profile_rewriting",
"Enable_profile_rewriting must be true when profile_guided dexpreopt and R8 optimization/obfuscation is turned on. The attached profile should be sourced from an unoptimized/unobfuscated APK.",
)
diff --git a/java/dex.go b/java/dex.go
index ed9c82b..dd64675 100644
--- a/java/dex.go
+++ b/java/dex.go
@@ -161,8 +161,8 @@
providesTransitiveHeaderJarsForR8
}
-func (d *dexer) effectiveOptimizeEnabled() bool {
- return BoolDefault(d.dexProperties.Optimize.Enabled, d.dexProperties.Optimize.EnabledByDefault)
+func (d *dexer) effectiveOptimizeEnabled(ctx android.EarlyModuleContext) bool {
+ return BoolDefault(d.dexProperties.Optimize.Enabled, d.dexProperties.Optimize.EnabledByDefault && !ctx.Config().Eng())
}
func (d *DexProperties) resourceShrinkingEnabled(ctx android.ModuleContext) bool {
@@ -173,8 +173,8 @@
return d.resourceShrinkingEnabled(ctx) && BoolDefault(d.Optimize.Optimized_shrink_resources, ctx.Config().UseOptimizedResourceShrinkingByDefault())
}
-func (d *dexer) optimizeOrObfuscateEnabled() bool {
- return d.effectiveOptimizeEnabled() && (proptools.Bool(d.dexProperties.Optimize.Optimize) || proptools.Bool(d.dexProperties.Optimize.Obfuscate))
+func (d *dexer) optimizeOrObfuscateEnabled(ctx android.EarlyModuleContext) bool {
+ return d.effectiveOptimizeEnabled(ctx) && (proptools.Bool(d.dexProperties.Optimize.Optimize) || proptools.Bool(d.dexProperties.Optimize.Obfuscate))
}
var d8, d8RE = pctx.MultiCommandRemoteStaticRules("d8",
@@ -353,7 +353,7 @@
flags = append(flags, "--release")
} else if ctx.Config().Eng() {
flags = append(flags, "--debug")
- } else if !d.effectiveOptimizeEnabled() && d.dexProperties.Optimize.EnabledByDefault {
+ } else if !d.effectiveOptimizeEnabled(ctx) && d.dexProperties.Optimize.EnabledByDefault {
// D8 uses --debug by default, whereas R8 uses --release by default.
// For targets that default to R8 usage (e.g., apps), but override this default, we still
// want D8 to run in release mode, preserving semantics as much as possible between the two.
@@ -627,7 +627,7 @@
mergeZipsFlags = "-stripFile META-INF/*.kotlin_module -stripFile **/*.kotlin_builtins"
}
- useR8 := d.effectiveOptimizeEnabled()
+ useR8 := d.effectiveOptimizeEnabled(ctx)
useD8 := !useR8 || ctx.Config().PartialCompileFlags().Use_d8
rbeR8 := ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_R8")
rbeD8 := ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_D8")
diff --git a/java/dex_test.go b/java/dex_test.go
index e94864b..8c1e5f7 100644
--- a/java/dex_test.go
+++ b/java/dex_test.go
@@ -797,12 +797,14 @@
},
{
name: "app_eng",
+ useD8: true,
isEng: true,
expectedFlags: "--debug",
},
{
name: "app_release_eng",
isEng: true,
+ useD8: true,
dxFlags: "--release",
// Eng mode does *not* override explicit dxflags.
expectedFlags: "--release",
diff --git a/java/java.go b/java/java.go
index 7f897a0..07e38a1 100644
--- a/java/java.go
+++ b/java/java.go
@@ -670,12 +670,12 @@
ctx.AddVariationDependencies(nil, bootClasspathTag, sdkDep.bootclasspath...)
ctx.AddVariationDependencies(nil, java9LibTag, sdkDep.java9Classpath...)
ctx.AddVariationDependencies(nil, sdkLibTag, sdkDep.classpath...)
- if d.effectiveOptimizeEnabled() && sdkDep.hasStandardLibs() {
+ if d.effectiveOptimizeEnabled(ctx) && sdkDep.hasStandardLibs() {
ctx.AddVariationDependencies(nil, proguardRaiseTag,
config.LegacyCorePlatformBootclasspathLibraries...,
)
}
- if d.effectiveOptimizeEnabled() && sdkDep.hasFrameworkLibs() {
+ if d.effectiveOptimizeEnabled(ctx) && sdkDep.hasFrameworkLibs() {
ctx.AddVariationDependencies(nil, proguardRaiseTag, config.FrameworkLibraries...)
}
}
@@ -2235,7 +2235,7 @@
// install these alongside the java binary.
ctx.VisitDirectDepsProxyWithTag(jniInstallTag, func(jni android.ModuleProxy) {
// Use the BaseModuleName of the dependency (without any prebuilt_ prefix)
- commonInfo, _ := android.OtherModuleProvider(ctx, jni, android.CommonModuleInfoProvider)
+ commonInfo := android.OtherModulePointerProviderOrDefault(ctx, jni, android.CommonModuleInfoProvider)
j.androidMkNamesOfJniLibs = append(j.androidMkNamesOfJniLibs, commonInfo.BaseModuleName+":"+commonInfo.Target.Arch.ArchType.Bitness())
})
// Check that native libraries are not listed in `required`. Prompt users to use `jni_libs` instead.
diff --git a/java/jdeps.go b/java/jdeps.go
index 7ef6c89..56142c8 100644
--- a/java/jdeps.go
+++ b/java/jdeps.go
@@ -46,7 +46,7 @@
moduleInfos := make(map[string]android.IdeInfo)
ctx.VisitAllModuleProxies(func(module android.ModuleProxy) {
- if !android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
+ if !android.OtherModulePointerProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
return
}
diff --git a/java/lint.go b/java/lint.go
index 61b50dc..dc1e51f 100644
--- a/java/lint.go
+++ b/java/lint.go
@@ -659,7 +659,7 @@
var outputs []*LintInfo
var dirs []string
ctx.VisitAllModuleProxies(func(m android.ModuleProxy) {
- commonInfo, _ := android.OtherModuleProvider(ctx, m, android.CommonModuleInfoProvider)
+ commonInfo := android.OtherModulePointerProviderOrDefault(ctx, m, android.CommonModuleInfoProvider)
if ctx.Config().KatiEnabled() && !commonInfo.ExportedToMake {
return
}
diff --git a/java/platform_compat_config.go b/java/platform_compat_config.go
index b2d6ca1..d2ec8bd 100644
--- a/java/platform_compat_config.go
+++ b/java/platform_compat_config.go
@@ -277,7 +277,7 @@
var compatConfigMetadata android.Paths
ctx.VisitAllModuleProxies(func(module android.ModuleProxy) {
- if !android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
+ if !android.OtherModulePointerProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
return
}
if c, ok := android.OtherModuleProvider(ctx, module, PlatformCompatConfigMetadataInfoProvider); ok {
diff --git a/linkerconfig/linkerconfig.go b/linkerconfig/linkerconfig.go
index d117c52..925d7b1 100644
--- a/linkerconfig/linkerconfig.go
+++ b/linkerconfig/linkerconfig.go
@@ -127,7 +127,7 @@
for _, m := range requireModules {
if _, ok := android.OtherModuleProvider(ctx, m, cc.CcInfoProvider); ok {
if android.OtherModuleProviderOrDefault(ctx, m, cc.LinkableInfoProvider).HasStubsVariants &&
- !android.OtherModuleProviderOrDefault(ctx, m, android.CommonModuleInfoProvider).Host {
+ !android.OtherModulePointerProviderOrDefault(ctx, m, android.CommonModuleInfoProvider).Host {
name := ctx.OtherModuleName(m)
if ccInfo, ok := android.OtherModuleProvider(ctx, m, cc.CcInfoProvider); ok && ccInfo.LinkerInfo != nil && ccInfo.LinkerInfo.ImplementationModuleName != nil {
name = *ccInfo.LinkerInfo.ImplementationModuleName
diff --git a/python/python.go b/python/python.go
index e2786b8..de21e39 100644
--- a/python/python.go
+++ b/python/python.go
@@ -768,7 +768,7 @@
Rule: zip,
Description: "bundle shared libraries for python binary",
Output: srcsZip,
- Implicits: paths,
+ Implicits: paths,
Args: map[string]string{
"args": strings.Join(parArgs, " "),
},
@@ -776,7 +776,6 @@
return srcsZip
}
-
// chckForDuplicateOutputPath checks whether outputPath has already been included in map m, which
// would result in two files being placed in the same location.
// If there is a duplicate path, an error is thrown and true is returned
diff --git a/rust/config/arm64_device.go b/rust/config/arm64_device.go
index 94a4457..efcd56a 100644
--- a/rust/config/arm64_device.go
+++ b/rust/config/arm64_device.go
@@ -45,6 +45,14 @@
"-Z branch-protection=bti,pac-ret",
"-Z stack-protector=none",
},
+ "armv9-3a": []string{
+ "-Z branch-protection=bti,pac-ret",
+ "-Z stack-protector=none",
+ },
+ "armv9-4a": []string{
+ "-Z branch-protection=bti,pac-ret",
+ "-Z stack-protector=none",
+ },
}
)
diff --git a/rust/doc.go b/rust/doc.go
index cf2f8b3..3616c8e 100644
--- a/rust/doc.go
+++ b/rust/doc.go
@@ -38,7 +38,7 @@
FlagWithArg("-D ", docDir.String())
ctx.VisitAllModuleProxies(func(module android.ModuleProxy) {
- if !android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
+ if !android.OtherModulePointerProviderOrDefault(ctx, module, android.CommonModuleInfoProvider).Enabled {
return
}
diff --git a/rust/fuzz_test.go b/rust/fuzz_test.go
index bdcfbbb..f462795 100644
--- a/rust/fuzz_test.go
+++ b/rust/fuzz_test.go
@@ -134,17 +134,24 @@
}
`)
- fuzz_shared_libtest := ctx.ModuleForTests(t, "fuzz_shared_libtest", "android_arm64_armv8-a_fuzzer").Module().(cc.LinkableInterface)
- fuzz_static_libtest := ctx.ModuleForTests(t, "fuzz_static_libtest", "android_arm64_armv8-a_fuzzer").Module().(cc.LinkableInterface)
- fuzz_staticffi_libtest := ctx.ModuleForTests(t, "fuzz_staticffi_libtest", "android_arm64_armv8-a_fuzzer").Module().(cc.LinkableInterface)
+ fuzz_shared_libtest := ctx.ModuleForTests(t, "fuzz_shared_libtest", "android_arm64_armv8-a_fuzzer").Module()
+ fuzz_static_libtest := ctx.ModuleForTests(t, "fuzz_static_libtest", "android_arm64_armv8-a_fuzzer").Module()
+ fuzz_staticffi_libtest := ctx.ModuleForTests(t, "fuzz_staticffi_libtest", "android_arm64_armv8-a_fuzzer").Module()
- if !strings.Contains(fuzz_shared_libtest.FuzzSharedLibraries().String(), ":libcc_transitive_dep.so") {
- t.Errorf("cc_fuzz does not contain the expected bundled transitive shared libs from rust_ffi_shared ('libcc_transitive_dep'): %#v", fuzz_shared_libtest.FuzzSharedLibraries().String())
+ fuzzSharedLibraries := func(module android.Module) string {
+ if info, ok := android.OtherModuleProvider(ctx, module, cc.LinkableInfoProvider); ok {
+ return info.FuzzSharedLibraries.String()
+ }
+ return ""
}
- if !strings.Contains(fuzz_static_libtest.FuzzSharedLibraries().String(), ":libcc_transitive_dep.so") {
- t.Errorf("cc_fuzz does not contain the expected bundled transitive shared libs from rust_ffi_static ('libcc_transitive_dep'): %#v", fuzz_static_libtest.FuzzSharedLibraries().String())
+
+ if libs := fuzzSharedLibraries(fuzz_shared_libtest); !strings.Contains(libs, ":libcc_transitive_dep.so") {
+ t.Errorf("cc_fuzz does not contain the expected bundled transitive shared libs from rust_ffi_shared ('libcc_transitive_dep'): %#v", libs)
}
- if !strings.Contains(fuzz_staticffi_libtest.FuzzSharedLibraries().String(), ":libcc_transitive_dep.so") {
- t.Errorf("cc_fuzz does not contain the expected bundled transitive shared libs from rust_ffi_static ('libcc_transitive_dep'): %#v", fuzz_staticffi_libtest.FuzzSharedLibraries().String())
+ if libs := fuzzSharedLibraries(fuzz_static_libtest); !strings.Contains(libs, ":libcc_transitive_dep.so") {
+ t.Errorf("cc_fuzz does not contain the expected bundled transitive shared libs from rust_ffi_static ('libcc_transitive_dep'): %#v", libs)
+ }
+ if libs := fuzzSharedLibraries(fuzz_staticffi_libtest); !strings.Contains(libs, ":libcc_transitive_dep.so") {
+ t.Errorf("cc_fuzz does not contain the expected bundled transitive shared libs from rust_ffi_static ('libcc_transitive_dep'): %#v", libs)
}
}
diff --git a/rust/image.go b/rust/image.go
index 51b8289..aa10a6d 100644
--- a/rust/image.go
+++ b/rust/image.go
@@ -137,7 +137,7 @@
// Additionally check if this module is inVendor() that means it is a "vendor" variant of a
// module. As well as SoC specific modules, vendor variants must be installed to /vendor
// unless they have "odm_available: true".
- return mod.InVendor() && !mod.VendorVariantToOdm()
+ return mod.HasVendorVariant() && mod.InVendor() && !mod.VendorVariantToOdm()
}
func (mod *Module) InstallInOdm() bool {
diff --git a/rust/rust.go b/rust/rust.go
index 5f3d7a9..54b5d92 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -1480,10 +1480,10 @@
rustInfo, hasRustInfo := android.OtherModuleProvider(ctx, dep, RustInfoProvider)
ccInfo, _ := android.OtherModuleProvider(ctx, dep, cc.CcInfoProvider)
linkableInfo, hasLinkableInfo := android.OtherModuleProvider(ctx, dep, cc.LinkableInfoProvider)
- commonInfo := android.OtherModuleProviderOrDefault(ctx, dep, android.CommonModuleInfoProvider)
+ commonInfo := android.OtherModulePointerProviderOrDefault(ctx, dep, android.CommonModuleInfoProvider)
if hasRustInfo && !linkableInfo.Static && !linkableInfo.Shared {
//Handle Rust Modules
- makeLibName := rustMakeLibName(rustInfo, linkableInfo, &commonInfo, depName+rustInfo.RustSubName)
+ makeLibName := rustMakeLibName(rustInfo, linkableInfo, commonInfo, depName+rustInfo.RustSubName)
switch {
case depTag == dylibDepTag:
@@ -1628,7 +1628,7 @@
}
} else if hasLinkableInfo {
//Handle C dependencies
- makeLibName := cc.MakeLibName(ccInfo, linkableInfo, &commonInfo, depName)
+ makeLibName := cc.MakeLibName(ccInfo, linkableInfo, commonInfo, depName)
if !hasRustInfo {
if commonInfo.Target.Os != ctx.Os() {
ctx.ModuleErrorf("OS mismatch between %q and %q", ctx.ModuleName(), depName)
diff --git a/rust/test.go b/rust/test.go
index 2fed0d6..cedced2 100644
--- a/rust/test.go
+++ b/rust/test.go
@@ -165,7 +165,7 @@
if linkableDep.OutputFile.Valid() {
// Copy the output in "lib[64]" so that it's compatible with
// the default rpath values.
- commonInfo := android.OtherModuleProviderOrDefault(ctx, dep, android.CommonModuleInfoProvider)
+ commonInfo := android.OtherModulePointerProviderOrDefault(ctx, dep, android.CommonModuleInfoProvider)
libDir := "lib"
if commonInfo.Target.Arch.ArchType.Multilib == "lib64" {
libDir = "lib64"
diff --git a/scripts/Android.bp b/scripts/Android.bp
index c0e13d5..b6cac32 100644
--- a/scripts/Android.bp
+++ b/scripts/Android.bp
@@ -254,11 +254,6 @@
],
}
-sh_binary_host {
- name: "list_image",
- src: "list_image.sh",
-}
-
filegroup {
name: "rustfmt.toml",
srcs: ["rustfmt.toml"],
diff --git a/scripts/list_image.sh b/scripts/list_image.sh
deleted file mode 100755
index 0542fa6..0000000
--- a/scripts/list_image.sh
+++ /dev/null
@@ -1,51 +0,0 @@
-#! /bin/bash
-
-# Recursively list Android image directory.
-set -eu
-set -o pipefail
-
-function die() { format=$1; shift; printf "$format\n" "$@"; exit 1; }
-
-# Figure out the filer utility.
-declare filer=
-[[ -z "${ANDROID_HOST_OUT:-}" ]] || filer=${ANDROID_HOST_OUT}/bin/debugfs_static
-if [[ "${1:-}" =~ --debugfs_path=(.*) ]]; then
- filer=${BASH_REMATCH[1]}
- shift
-fi
-if [[ -z "${filer:-}" ]]; then
- maybefiler="$(dirname $0)/debugfs_static"
- [[ ! -x "$maybefiler" ]] || filer="$maybefiler"
-fi
-
-(( $# >0 )) || die "%s [--debugfs_path=<path>] IMAGE" "$0"
-
-[[ -n "${filer:-}" ]] || die "cannot locate 'debugfs' executable: \
---debugfs_path= is missing, ANDROID_HOST_OUT is not set, \
-and 'debugfs_static' is not colocated with this script"
-declare -r image="$1"
-
-function dolevel() {
- printf "%s/\n" "$1"
- # Each line of the file output consists of 6 fields separated with '/'.
- # The second one contains the file's attributes, and the fifth its name.
- $filer -R "ls -l -p $1" "$image" 2>/dev/null |\
- sed -nr 's|^/.*/(.*)/.*/.*/(.+)/.*/$|\2 \1|p' | LANG=C sort | \
- while read name attr; do
- [[ "$name" != '.' && "$name" != '..' ]] || continue
- path="$1/$name"
- # If the second char of the attributes is '4', it is a directory.
- if [[ $attr =~ ^.4 ]]; then
- dolevel "$path"
- else
- printf "%s\n" "$path"
- fi
- done
-}
-
-# The filer always prints its version on stderr, so we are going
-# to redirect it to the bit bucket. On the other hand, the filer's
-# return code on error is still 0. Let's run it once to without
-# redirecting stderr to see that there is at least one entry.
-$filer -R "ls -l -p" "$image" | grep -q -m1 -P '^/.*/.*/.*/.*/.+/.*/$'
-dolevel .
diff --git a/sh/sh_binary.go b/sh/sh_binary.go
index 7041642..57f5ad1 100644
--- a/sh/sh_binary.go
+++ b/sh/sh_binary.go
@@ -510,7 +510,7 @@
// so that it's compatible with the default rpath values.
var relPath string
linkableInfo := android.OtherModuleProviderOrDefault(ctx, dep, cc.LinkableInfoProvider)
- commonInfo := android.OtherModuleProviderOrDefault(ctx, dep, android.CommonModuleInfoProvider)
+ commonInfo := android.OtherModulePointerProviderOrDefault(ctx, dep, android.CommonModuleInfoProvider)
if commonInfo.Target.Arch.ArchType.Multilib == "lib64" {
relPath = filepath.Join("lib64", linkableInfo.OutputFile.Path().Base())
@@ -613,6 +613,8 @@
entries.AddStrings("LOCAL_EXTRA_FULL_TEST_CONFIGS", s.extraTestConfigs.Strings()...)
}
+ entries.SetBoolIfTrue("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", !proptools.BoolDefault(s.testProperties.Auto_gen_config, true))
+
s.testProperties.Test_options.SetAndroidMkEntries(entries)
},
},
diff --git a/tradefed_modules/Android.bp b/tradefed_modules/Android.bp
index a765a05..37bae39 100644
--- a/tradefed_modules/Android.bp
+++ b/tradefed_modules/Android.bp
@@ -14,11 +14,9 @@
],
srcs: [
"test_module_config.go",
- "test_suite.go",
],
testSrcs: [
"test_module_config_test.go",
- "test_suite_test.go",
],
pluginFor: ["soong_build"],
}
diff --git a/tradefed_modules/test_module_config.go b/tradefed_modules/test_module_config.go
index 2b34128..e833df2 100644
--- a/tradefed_modules/test_module_config.go
+++ b/tradefed_modules/test_module_config.go
@@ -1,14 +1,15 @@
package tradefed_modules
import (
- "android/soong/android"
- "android/soong/tradefed"
"encoding/json"
"fmt"
"io"
"slices"
"strings"
+ "android/soong/android"
+ "android/soong/tradefed"
+
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
)
@@ -178,6 +179,10 @@
moduleInfoJSON.TestConfig = []string{m.testConfig.String()}
moduleInfoJSON.AutoTestConfig = []string{"true"}
moduleInfoJSON.TestModuleConfigBase = proptools.String(m.Base)
+
+ android.SetProvider(ctx, android.SupportFilesInfoProvider, android.SupportFilesInfo{
+ SupportFiles: m.supportFiles,
+ })
}
// Ensure at least one test_suite is listed. Ideally it should be general-tests
@@ -327,6 +332,9 @@
func (m *testModuleConfigHostModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
m.validateBase(ctx, &testModuleConfigHostTag, "java_test_host", true)
m.generateManifestAndConfig(ctx)
+ android.SetProvider(ctx, android.SupportFilesInfoProvider, android.SupportFilesInfo{
+ SupportFiles: m.supportFiles,
+ })
}
// Ensure the base listed is the right type by checking that we get the expected provider data.
diff --git a/tradefed_modules/test_suite.go b/tradefed_modules/test_suite.go
deleted file mode 100644
index 8b7babf..0000000
--- a/tradefed_modules/test_suite.go
+++ /dev/null
@@ -1,173 +0,0 @@
-// Copyright 2024 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 tradefed_modules
-
-import (
- "encoding/json"
- "path"
- "path/filepath"
-
- "android/soong/android"
- "android/soong/tradefed"
- "github.com/google/blueprint"
-)
-
-const testSuiteModuleType = "test_suite"
-
-type testSuiteTag struct {
- blueprint.BaseDependencyTag
-}
-
-type testSuiteManifest struct {
- Name string `json:"name"`
- Files []string `json:"files"`
-}
-
-func init() {
- RegisterTestSuiteBuildComponents(android.InitRegistrationContext)
-}
-
-func RegisterTestSuiteBuildComponents(ctx android.RegistrationContext) {
- ctx.RegisterModuleType(testSuiteModuleType, TestSuiteFactory)
-}
-
-var PrepareForTestWithTestSuiteBuildComponents = android.GroupFixturePreparers(
- android.FixtureRegisterWithContext(RegisterTestSuiteBuildComponents),
-)
-
-type testSuiteProperties struct {
- Description string
- Tests []string `android:"path,arch_variant"`
-}
-
-type testSuiteModule struct {
- android.ModuleBase
- android.DefaultableModuleBase
- testSuiteProperties
-}
-
-func (t *testSuiteModule) DepsMutator(ctx android.BottomUpMutatorContext) {
- for _, test := range t.Tests {
- if ctx.OtherModuleDependencyVariantExists(ctx.Config().BuildOSCommonTarget.Variations(), test) {
- // Host tests.
- ctx.AddVariationDependencies(ctx.Config().BuildOSCommonTarget.Variations(), testSuiteTag{}, test)
- } else {
- // Target tests.
- ctx.AddDependency(ctx.Module(), testSuiteTag{}, test)
- }
- }
-}
-
-func (t *testSuiteModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
- suiteName := ctx.ModuleName()
- modulesByName := make(map[string]android.Module)
- ctx.WalkDeps(func(child, parent android.Module) bool {
- // Recurse into test_suite dependencies.
- if ctx.OtherModuleType(child) == testSuiteModuleType {
- ctx.Phony(suiteName, android.PathForPhony(ctx, child.Name()))
- return true
- }
-
- // Only write out top level test suite dependencies here.
- if _, ok := ctx.OtherModuleDependencyTag(child).(testSuiteTag); !ok {
- return false
- }
-
- if !child.InstallInTestcases() {
- ctx.ModuleErrorf("test_suite only supports modules installed in testcases. %q is not installed in testcases.", child.Name())
- return false
- }
-
- modulesByName[child.Name()] = child
- return false
- })
-
- var files []string
- for name, module := range modulesByName {
- // Get the test provider data from the child.
- tp, ok := android.OtherModuleProvider(ctx, module, tradefed.BaseTestProviderKey)
- if !ok {
- // TODO: Consider printing out a list of all module types.
- ctx.ModuleErrorf("%q is not a test module.", name)
- continue
- }
-
- files = append(files, packageModuleFiles(ctx, suiteName, module, tp)...)
- ctx.Phony(suiteName, android.PathForPhony(ctx, name))
- }
-
- manifestPath := android.PathForSuiteInstall(ctx, suiteName, suiteName+".json")
- b, err := json.Marshal(testSuiteManifest{Name: suiteName, Files: android.SortedUniqueStrings(files)})
- if err != nil {
- ctx.ModuleErrorf("Failed to marshal manifest: %v", err)
- return
- }
- android.WriteFileRule(ctx, manifestPath, string(b))
-
- ctx.Phony(suiteName, manifestPath)
-}
-
-func TestSuiteFactory() android.Module {
- module := &testSuiteModule{}
- module.AddProperties(&module.testSuiteProperties)
-
- android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon)
- android.InitDefaultableModule(module)
-
- return module
-}
-
-func packageModuleFiles(ctx android.ModuleContext, suiteName string, module android.Module, tp tradefed.BaseTestProviderData) []string {
-
- hostOrTarget := "target"
- if tp.IsHost {
- hostOrTarget = "host"
- }
-
- // suiteRoot at out/soong/packaging/<suiteName>.
- suiteRoot := android.PathForSuiteInstall(ctx, suiteName)
-
- var installed android.InstallPaths
- // Install links to installed files from the module.
- if installFilesInfo, ok := android.OtherModuleProvider(ctx, module, android.InstallFilesProvider); ok {
- for _, f := range installFilesInfo.InstallFiles {
- // rel is anything under .../<partition>, normally under .../testcases.
- rel := android.Rel(ctx, f.PartitionDir(), f.String())
-
- // Install the file under <suiteRoot>/<host|target>/<partition>.
- installDir := suiteRoot.Join(ctx, hostOrTarget, f.Partition(), path.Dir(rel))
- linkTo, err := filepath.Rel(installDir.String(), f.String())
- if err != nil {
- ctx.ModuleErrorf("Failed to get relative path from %s to %s: %v", installDir.String(), f.String(), err)
- continue
- }
- installed = append(installed, ctx.InstallAbsoluteSymlink(installDir, path.Base(rel), linkTo))
- }
- }
-
- // Install config file.
- if tp.TestConfig != nil {
- moduleRoot := suiteRoot.Join(ctx, hostOrTarget, "testcases", module.Name())
- installed = append(installed, ctx.InstallFile(moduleRoot, module.Name()+".config", tp.TestConfig))
- }
-
- // Add to phony and manifest, manifestpaths are relative to suiteRoot.
- var manifestEntries []string
- for _, f := range installed {
- manifestEntries = append(manifestEntries, android.Rel(ctx, suiteRoot.String(), f.String()))
- ctx.Phony(suiteName, f)
- }
- return manifestEntries
-}
diff --git a/tradefed_modules/test_suite_test.go b/tradefed_modules/test_suite_test.go
deleted file mode 100644
index 3e1472c..0000000
--- a/tradefed_modules/test_suite_test.go
+++ /dev/null
@@ -1,151 +0,0 @@
-// Copyright 2024 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 tradefed_modules
-
-import (
- "android/soong/android"
- "android/soong/java"
- "encoding/json"
- "slices"
- "testing"
-)
-
-func TestTestSuites(t *testing.T) {
- t.Parallel()
- ctx := android.GroupFixturePreparers(
- java.PrepareForTestWithJavaDefaultModules,
- android.FixtureRegisterWithContext(RegisterTestSuiteBuildComponents),
- ).RunTestWithBp(t, `
- android_test {
- name: "TestModule1",
- sdk_version: "current",
- }
-
- android_test {
- name: "TestModule2",
- sdk_version: "current",
- }
-
- test_suite {
- name: "my-suite",
- description: "a test suite",
- tests: [
- "TestModule1",
- "TestModule2",
- ]
- }
- `)
- manifestPath := ctx.ModuleForTests(t, "my-suite", "android_common").Output("out/soong/test_suites/my-suite/my-suite.json")
- var actual testSuiteManifest
- if err := json.Unmarshal([]byte(android.ContentFromFileRuleForTests(t, ctx.TestContext, manifestPath)), &actual); err != nil {
- t.Errorf("failed to unmarshal manifest: %v", err)
- }
- slices.Sort(actual.Files)
-
- expected := testSuiteManifest{
- Name: "my-suite",
- Files: []string{
- "target/testcases/TestModule1/TestModule1.config",
- "target/testcases/TestModule1/arm64/TestModule1.apk",
- "target/testcases/TestModule2/TestModule2.config",
- "target/testcases/TestModule2/arm64/TestModule2.apk",
- },
- }
-
- android.AssertDeepEquals(t, "manifests differ", expected, actual)
-}
-
-func TestTestSuitesWithNested(t *testing.T) {
- t.Parallel()
- ctx := android.GroupFixturePreparers(
- java.PrepareForTestWithJavaDefaultModules,
- android.FixtureRegisterWithContext(RegisterTestSuiteBuildComponents),
- ).RunTestWithBp(t, `
- android_test {
- name: "TestModule1",
- sdk_version: "current",
- }
-
- android_test {
- name: "TestModule2",
- sdk_version: "current",
- }
-
- android_test {
- name: "TestModule3",
- sdk_version: "current",
- }
-
- test_suite {
- name: "my-child-suite",
- description: "a child test suite",
- tests: [
- "TestModule1",
- "TestModule2",
- ]
- }
-
- test_suite {
- name: "my-all-tests-suite",
- description: "a parent test suite",
- tests: [
- "TestModule1",
- "TestModule3",
- "my-child-suite",
- ]
- }
- `)
- manifestPath := ctx.ModuleForTests(t, "my-all-tests-suite", "android_common").Output("out/soong/test_suites/my-all-tests-suite/my-all-tests-suite.json")
- var actual testSuiteManifest
- if err := json.Unmarshal([]byte(android.ContentFromFileRuleForTests(t, ctx.TestContext, manifestPath)), &actual); err != nil {
- t.Errorf("failed to unmarshal manifest: %v", err)
- }
- slices.Sort(actual.Files)
-
- expected := testSuiteManifest{
- Name: "my-all-tests-suite",
- Files: []string{
- "target/testcases/TestModule1/TestModule1.config",
- "target/testcases/TestModule1/arm64/TestModule1.apk",
- "target/testcases/TestModule2/TestModule2.config",
- "target/testcases/TestModule2/arm64/TestModule2.apk",
- "target/testcases/TestModule3/TestModule3.config",
- "target/testcases/TestModule3/arm64/TestModule3.apk",
- },
- }
-
- android.AssertDeepEquals(t, "manifests differ", expected, actual)
-}
-
-func TestTestSuitesNotInstalledInTestcases(t *testing.T) {
- t.Parallel()
- android.GroupFixturePreparers(
- java.PrepareForTestWithJavaDefaultModules,
- android.FixtureRegisterWithContext(RegisterTestSuiteBuildComponents),
- ).ExtendWithErrorHandler(android.FixtureExpectsAllErrorsToMatchAPattern([]string{
- `"SomeHostTest" is not installed in testcases`,
- })).RunTestWithBp(t, `
- java_test_host {
- name: "SomeHostTest",
- srcs: ["a.java"],
- }
- test_suite {
- name: "my-suite",
- description: "a test suite",
- tests: [
- "SomeHostTest",
- ]
- }
- `)
-}
diff --git a/ui/build/androidmk_denylist.go b/ui/build/androidmk_denylist.go
index cd49ec8..8266654 100644
--- a/ui/build/androidmk_denylist.go
+++ b/ui/build/androidmk_denylist.go
@@ -15,20 +15,29 @@
package build
import (
+ "os"
+ "slices"
"strings"
)
var androidmk_denylist []string = []string{
+ "art/",
"bionic/",
- "chained_build_config/",
+ "bootable/",
+ "build/",
"cts/",
"dalvik/",
"developers/",
"development/",
"device/common/",
+ "device/generic/",
+ "device/google/",
"device/google_car/",
"device/sample/",
+ "external/",
"frameworks/",
+ "hardware/google/",
+ "hardware/interfaces/",
"hardware/libhardware/",
"hardware/libhardware_legacy/",
"hardware/ril/",
@@ -45,24 +54,48 @@
"sdk/",
"system/",
"test/",
+ "tools/",
"trusty/",
- // Add back toolchain/ once defensive Android.mk files are removed
- //"toolchain/",
- "vendor/google_contexthub/",
- "vendor/google_data/",
- "vendor/google_elmyra/",
- "vendor/google_mhl/",
- "vendor/google_pdk/",
- "vendor/google_testing/",
- "vendor/partner_testing/",
- "vendor/partner_tools/",
- "vendor/pdk/",
+ "toolchain/",
+}
+
+var androidmk_allowlist []string = []string{
+ "art/Android.mk",
+ "bootable/deprecated-ota/updater/Android.mk",
+ "tools/vendor/google_prebuilts/arc/Android.mk",
+}
+
+func getAllLines(ctx Context, filename string) []string {
+ bytes, err := os.ReadFile(filename)
+ if err != nil {
+ if os.IsNotExist(err) {
+ return []string{}
+ } else {
+ ctx.Fatalf("Could not read %s: %v", filename, err)
+ }
+ }
+ return strings.Split(strings.Trim(string(bytes), " \n"), "\n")
}
func blockAndroidMks(ctx Context, androidMks []string) {
+ allowlist_files := []string{
+ "vendor/google/build/androidmk/allowlist.txt",
+ "device/google/clockwork/build/androidmk/allowlist.txt",
+ "device/google/sdv/androidmk/allowlist.txt",
+ }
+ for _, allowlist_file := range allowlist_files {
+ allowlist := getAllLines(ctx, allowlist_file)
+ androidmk_allowlist = append(androidmk_allowlist, allowlist...)
+ }
+ slices.Sort(androidmk_allowlist)
+ androidmk_allowlist = slices.Compact(androidmk_allowlist)
+
+ denylist := getAllLines(ctx, "vendor/google/build/androidmk/denylist.txt")
+ androidmk_denylist = append(androidmk_denylist, denylist...)
+
for _, mkFile := range androidMks {
for _, d := range androidmk_denylist {
- if strings.HasPrefix(mkFile, d) {
+ if strings.HasPrefix(mkFile, d) && !slices.Contains(androidmk_allowlist, mkFile) {
ctx.Fatalf("Found blocked Android.mk file: %s. "+
"Please see androidmk_denylist.go for the blocked directories and contact build system team if the file should not be blocked.", mkFile)
}
@@ -86,6 +119,12 @@
// These directories hold the published Android SDK, used in Unbundled Gradle builds.
"prebuilts/fullsdk-darwin",
"prebuilts/fullsdk-linux",
+ // wpa_supplicant_8 has been converted to Android.bp and Android.mk files are kept for troubleshooting.
+ "external/wpa_supplicant_8/",
+ // Empty Android.mk in package's top directory
+ "external/proguard/",
+ "external/swig/",
+ "toolchain/",
}
var art_androidmks = []string{
diff --git a/ui/build/dumpvars.go b/ui/build/dumpvars.go
index 16a3db8..710be84 100644
--- a/ui/build/dumpvars.go
+++ b/ui/build/dumpvars.go
@@ -181,7 +181,12 @@
fmt.Fprintf(b, "%s=%s\n", name, make_vars[name])
}
}
- fmt.Fprintf(b, "SOONG_ONLY=%t\n", config.soongOnlyRequested)
+ if config.skipKatiControlledByFlags {
+ fmt.Fprintf(b, "SOONG_ONLY=%t\n", config.soongOnlyRequested)
+ } else { // default for this product
+ fmt.Fprintf(b, "SOONG_ONLY=%t\n", make_vars["PRODUCT_SOONG_ONLY"] == "true")
+ }
+
fmt.Fprint(b, "============================================")
return b.String()
diff --git a/ui/build/finder.go b/ui/build/finder.go
index 783b488..ff8908b 100644
--- a/ui/build/finder.go
+++ b/ui/build/finder.go
@@ -84,8 +84,14 @@
// METADATA file of packages
"METADATA",
},
- // .mk files for product/board configuration.
- IncludeSuffixes: []string{".mk"},
+ IncludeSuffixes: []string{
+ // .mk files for product/board configuration.
+ ".mk",
+ // otatools cert files
+ ".pk8",
+ ".pem",
+ ".avbpubkey",
+ },
}
dumpDir := config.FileListDir()
f, err = finder.New(cacheParams, filesystem, logger.New(ioutil.Discard),
@@ -118,6 +124,18 @@
return entries.DirNames, matches
}
+func findOtaToolsCertFiles(entries finder.DirEntries) (dirNames []string, fileNames []string) {
+ matches := []string{}
+ for _, foundName := range entries.FileNames {
+ if strings.HasSuffix(foundName, ".pk8") ||
+ strings.HasSuffix(foundName, ".pem") ||
+ strings.HasSuffix(foundName, ".avbpubkey") {
+ matches = append(matches, foundName)
+ }
+ }
+ return entries.DirNames, matches
+}
+
// FindSources searches for source files known to <f> and writes them to the filesystem for
// use later.
func FindSources(ctx Context, config Config, f *finder.Finder) {
@@ -184,6 +202,17 @@
ctx.Fatalf("Could not find TEST_MAPPING: %v", err)
}
+ // Recursively look for all otatools cert files.
+ otatools_cert_files := f.FindMatching("build/make/target/product/security", findOtaToolsCertFiles)
+ otatools_cert_files = append(otatools_cert_files, f.FindMatching("device", findOtaToolsCertFiles)...)
+ otatools_cert_files = append(otatools_cert_files, f.FindMatching("external/avb/test/data", findOtaToolsCertFiles)...)
+ otatools_cert_files = append(otatools_cert_files, f.FindMatching("packages/modules", findOtaToolsCertFiles)...)
+ otatools_cert_files = append(otatools_cert_files, f.FindMatching("vendor", findOtaToolsCertFiles)...)
+ err = dumpListToFile(ctx, config, otatools_cert_files, filepath.Join(dumpDir, "OtaToolsCertFiles.list"))
+ if err != nil {
+ ctx.Fatalf("Could not find otatools cert files: %v", err)
+ }
+
// Recursively look for all Android.bp files
androidBps := f.FindNamedAt(".", "Android.bp")
if len(androidBps) == 0 {