diff options
Diffstat (limited to 'android/module.go')
-rw-r--r-- | android/module.go | 55 |
1 files changed, 50 insertions, 5 deletions
diff --git a/android/module.go b/android/module.go index 334e5b722..1538861d3 100644 --- a/android/module.go +++ b/android/module.go @@ -22,6 +22,7 @@ import ( "reflect" "slices" "sort" + "strconv" "strings" "github.com/google/blueprint" @@ -44,6 +45,14 @@ type Module interface { // For more information, see Module.GenerateBuildActions within Blueprint's module_ctx.go GenerateAndroidBuildActions(ModuleContext) + // CleanupAfterBuildActions is called after ModuleBase.GenerateBuildActions is finished. + // If all interactions with this module are handled via providers instead of direct access + // to the module then it can free memory attached to the module. + // This is a temporary measure to reduce memory usage, eventually blueprint's reference + // to the Module should be dropped after GenerateAndroidBuildActions once all accesses + // can be done through providers. + CleanupAfterBuildActions() + // Add dependencies to the components of a module, i.e. modules that are created // by the module and which are considered to be part of the creating module. // @@ -128,6 +137,9 @@ type Module interface { // WARNING: This should not be used outside build/soong/fsgen // Overrides returns the list of modules which should not be installed if this module is installed. Overrides() []string + + // If this is true, the module must not read product-specific configurations. + UseGenericConfig() bool } // Qualified id for a module @@ -196,6 +208,12 @@ type Dist struct { // 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 @@ type commonProperties struct { // List of module names that are prevented from being installed when this module gets // installed. Overrides []string + + // Set to true if this module must be generic and does not require product-specific information. + // To be included in the system image, this property must be set to true. + Use_generic_config *bool } // Properties common to all modules inheriting from ModuleBase. Unlike commonProperties, these @@ -1002,11 +1024,19 @@ func (m *ModuleBase) baseDepsMutator(ctx BottomUpMutatorContext) { pv := ctx.Config().productVariables fullManifest := pv.DeviceArch != nil && pv.DeviceName != nil if fullManifest { - addRequiredDeps(ctx) addVintfFragmentDeps(ctx) } } +// required property can be overridden too; handle it separately +func (m *ModuleBase) baseOverridablePropertiesDepsMutator(ctx BottomUpMutatorContext) { + pv := ctx.Config().productVariables + fullManifest := pv.DeviceArch != nil && pv.DeviceName != nil + if fullManifest { + addRequiredDeps(ctx) + } +} + // addRequiredDeps adds required, target_required, and host_required as dependencies. func addRequiredDeps(ctx BottomUpMutatorContext) { addDep := func(target Target, depName string) { @@ -1488,7 +1518,7 @@ func (m *ModuleBase) computeInstallDeps(ctx ModuleContext) ([]depset.DepSet[Inst // Installation is still handled by Make, so anything hidden from Make is not // installable. info := OtherModuleProviderOrDefault(ctx, dep, InstallFilesProvider) - commonInfo := OtherModuleProviderOrDefault(ctx, dep, CommonModuleInfoProvider) + commonInfo := OtherModulePointerProviderOrDefault(ctx, dep, CommonModuleInfoProvider) if !commonInfo.HideFromMake && !commonInfo.SkipInstall { installDeps = append(installDeps, info.TransitiveInstallFiles) } @@ -1505,7 +1535,7 @@ func (m *ModuleBase) computeInstallDeps(ctx ModuleContext) ([]depset.DepSet[Inst // should also install the output files of the given dependency and dependency tag. func isInstallDepNeeded(ctx ModuleContext, dep ModuleProxy) bool { // Don't add a dependency from the platform to a library provided by an apex. - if OtherModuleProviderOrDefault(ctx, dep, CommonModuleInfoProvider).UninstallableApexPlatformVariant { + if OtherModulePointerProviderOrDefault(ctx, dep, CommonModuleInfoProvider).UninstallableApexPlatformVariant { return false } // Only install modules if the dependency tag is an InstallDepNeeded tag. @@ -1928,7 +1958,7 @@ type ApiLevelOrPlatform struct { IsPlatform bool } -var CommonModuleInfoProvider = blueprint.NewProvider[CommonModuleInfo]() +var CommonModuleInfoProvider = blueprint.NewProvider[*CommonModuleInfo]() type PrebuiltModuleInfo struct { SourceExists bool @@ -2336,7 +2366,7 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) if mm, ok := m.module.(interface{ BaseModuleName() string }); ok { commonData.BaseModuleName = mm.BaseModuleName() } - SetProvider(ctx, CommonModuleInfoProvider, commonData) + SetProvider(ctx, CommonModuleInfoProvider, &commonData) if p, ok := m.module.(PrebuiltInterface); ok && p.Prebuilt() != nil { SetProvider(ctx, PrebuiltModuleInfoProvider, PrebuiltModuleInfo{ SourceExists: p.Prebuilt().SourceExists(), @@ -2371,8 +2401,12 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) }) } } + + m.module.CleanupAfterBuildActions() } +func (m *ModuleBase) CleanupAfterBuildActions() {} + func SetJarJarPrefixHandler(handler func(ModuleContext)) { if jarJarPrefixHandler != nil { panic("jarJarPrefixHandler already set") @@ -2580,6 +2614,10 @@ func (m *ModuleBase) Overrides() []string { return m.commonProperties.Overrides } +func (m *ModuleBase) UseGenericConfig() bool { + return proptools.Bool(m.commonProperties.Use_generic_config) +} + type ConfigContext interface { Config() Config } @@ -2680,6 +2718,13 @@ func (e configurationEvalutor) EvaluateConfiguration(condition proptools.Configu return proptools.ConfigurableValueString(v) case "bool": return proptools.ConfigurableValueBool(v == "true") + case "int": + i, err := strconv.ParseInt(v, 10, 64) + if err != nil { + ctx.OtherModulePropertyErrorf(m, property, "integer soong_config_variable was not an int: %q", v) + return proptools.ConfigurableValueUndefined() + } + return proptools.ConfigurableValueInt(i) case "string_list": return proptools.ConfigurableValueStringList(strings.Split(v, " ")) default: |