diff options
Diffstat (limited to 'android/module.go')
| -rw-r--r-- | android/module.go | 55 |
1 files changed, 45 insertions, 10 deletions
diff --git a/android/module.go b/android/module.go index 47fdc238b..d6c129ac8 100644 --- a/android/module.go +++ b/android/module.go @@ -381,7 +381,7 @@ type commonProperties struct { Native_bridge_supported *bool `android:"arch_variant"` // init.rc files to be installed if this module is installed - Init_rc []string `android:"arch_variant,path"` + Init_rc proptools.Configurable[[]string] `android:"arch_variant,path"` // VINTF manifest fragments to be installed if this module is installed Vintf_fragments proptools.Configurable[[]string] `android:"path"` @@ -443,12 +443,6 @@ type commonProperties struct { // Set at module initialization time by calling InitCommonOSAndroidMultiTargetsArchModule CreateCommonOSVariant bool `blueprint:"mutated"` - // If set to true then this variant is the CommonOS variant that has dependencies on its - // OsType specific variants. - // - // Set by osMutator. - CommonOSVariant bool `blueprint:"mutated"` - // When set to true, this module is not installed to the full install path (ex: under // out/target/product/<name>/<partition>). It can be installed only to the packaging // modules like android_filesystem. @@ -1063,8 +1057,29 @@ var vintfDepTag = struct { }{} func addVintfFragmentDeps(ctx BottomUpMutatorContext) { + // Vintf manifests in the recovery partition will be ignored. + if !ctx.Device() || ctx.Module().InstallInRecovery() { + return + } + + deviceConfig := ctx.DeviceConfig() + mod := ctx.Module() - ctx.AddDependency(mod, vintfDepTag, mod.VintfFragmentModuleNames(ctx)...) + vintfModules := ctx.AddDependency(mod, vintfDepTag, mod.VintfFragmentModuleNames(ctx)...) + + modPartition := mod.PartitionTag(deviceConfig) + for _, vintf := range vintfModules { + if vintfModule, ok := vintf.(*vintfFragmentModule); ok { + vintfPartition := vintfModule.PartitionTag(deviceConfig) + if modPartition != vintfPartition { + ctx.ModuleErrorf("Module %q(%q) and Vintf_fragment %q(%q) are installed to different partitions.", + mod.Name(), modPartition, + vintfModule.Name(), vintfPartition) + } + } else { + ctx.ModuleErrorf("Only vintf_fragment type module should be listed in vintf_fragment_modules : %q", vintf.Name()) + } + } } // AddProperties "registers" the provided props @@ -1221,7 +1236,7 @@ func (m *ModuleBase) ArchSpecific() bool { // True if the current variant is a CommonOS variant, false otherwise. func (m *ModuleBase) IsCommonOSVariant() bool { - return m.commonProperties.CommonOSVariant + return m.commonProperties.CompileOS == CommonOS } // supportsTarget returns true if the given Target is supported by the current module. @@ -1346,6 +1361,14 @@ func (m *ModuleBase) Enabled(ctx ConfigurableEvaluatorContext) bool { return m.commonProperties.Enabled.GetOrDefault(m.ConfigurableEvaluator(ctx), !m.Os().DefaultDisabled) } +// Returns a copy of the enabled property, useful for passing it on to sub-modules +func (m *ModuleBase) EnabledProperty() proptools.Configurable[bool] { + if m.commonProperties.ForcedDisabled { + return proptools.NewSimpleConfigurable(false) + } + return m.commonProperties.Enabled.Clone() +} + func (m *ModuleBase) Disable() { m.commonProperties.ForcedDisabled = true } @@ -1853,7 +1876,7 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) // so only a single rule is created for each init.rc or vintf fragment file. if !m.InVendorRamdisk() { - ctx.initRcPaths = PathsForModuleSrc(ctx, m.commonProperties.Init_rc) + ctx.initRcPaths = PathsForModuleSrc(ctx, m.commonProperties.Init_rc.GetOrDefault(ctx, nil)) rcDir := PathForModuleInstall(ctx, "etc", "init") for _, src := range ctx.initRcPaths { installedInitRc := rcDir.Join(ctx, src.Base()) @@ -2204,9 +2227,15 @@ func (m *ModuleBase) IsNativeBridgeSupported() bool { return proptools.Bool(m.commonProperties.Native_bridge_supported) } +type ConfigContext interface { + Config() Config +} + type ConfigurableEvaluatorContext interface { + OtherModuleProviderContext Config() Config OtherModulePropertyErrorf(module Module, property string, fmt string, args ...interface{}) + HasMutatorFinished(mutatorName string) bool } type configurationEvalutor struct { @@ -2228,6 +2257,12 @@ func (e configurationEvalutor) PropertyErrorf(property string, fmt string, args func (e configurationEvalutor) EvaluateConfiguration(condition proptools.ConfigurableCondition, property string) proptools.ConfigurableValue { ctx := e.ctx m := e.m + + if !ctx.HasMutatorFinished("defaults") { + ctx.OtherModulePropertyErrorf(m, property, "Cannot evaluate configurable property before the defaults mutator has run") + return proptools.ConfigurableValueUndefined() + } + switch condition.FunctionName() { case "release_flag": if condition.NumArgs() != 1 { |