diff options
Diffstat (limited to 'android/module.go')
| -rw-r--r-- | android/module.go | 99 |
1 files changed, 76 insertions, 23 deletions
diff --git a/android/module.go b/android/module.go index c4a83777a..622399bb6 100644 --- a/android/module.go +++ b/android/module.go @@ -15,6 +15,7 @@ package android import ( + "errors" "fmt" "net/url" "path/filepath" @@ -613,17 +614,6 @@ func (t TaggedDistFiles) merge(other TaggedDistFiles) TaggedDistFiles { return t } -func MakeDefaultDistFiles(paths ...Path) TaggedDistFiles { - for _, p := range paths { - if p == nil { - panic("The path to a dist file cannot be nil.") - } - } - - // The default OutputFile tag is the empty "" string. - return TaggedDistFiles{DefaultDistTag: paths} -} - type hostAndDeviceProperties struct { // If set to true, build a variant of the module for the host. Defaults to false. Host_supported *bool @@ -1230,6 +1220,13 @@ func (m *ModuleBase) GenerateTaggedDistFiles(ctx BaseModuleContext) TaggedDistFi tag := proptools.StringDefault(dist.Tag, DefaultDistTag) distFileForTagFromProvider, err := outputFilesForModuleFromProvider(ctx, m.module, tag) + + // If the module doesn't define output files for the DefaultDistTag, try the files under + // the "" tag. + if tag == DefaultDistTag && errors.Is(err, ErrUnsupportedOutputTag) { + distFileForTagFromProvider, err = outputFilesForModuleFromProvider(ctx, m.module, "") + } + if err != OutputFilesProviderNotSet { if err != nil && tag != DefaultDistTag { ctx.PropertyErrorf("dist.tag", "%s", err.Error()) @@ -1919,6 +1916,28 @@ type CommonModuleInfo struct { IsStubsModule bool Host bool IsApexModule bool + // The primary licenses property, may be nil, records license metadata for the module. + PrimaryLicensesProperty applicableLicensesProperty + Owner string + Vendor bool + Proprietary bool + SocSpecific bool + ProductSpecific bool + SystemExtSpecific bool + DeviceSpecific bool + // 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. + NoFullInstall bool + InVendorRamdisk bool + ExemptFromRequiredApplicableLicensesProperty bool + RequiredModuleNames []string + HostRequiredModuleNames []string + TargetRequiredModuleNames []string + VintfFragmentModuleNames []string + Dists []Dist + ExportedToMake bool + Team string } type ApiLevelOrPlatform struct { @@ -2254,6 +2273,7 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) buildComplianceMetadataProvider(ctx, m) commonData := CommonModuleInfo{ + Enabled: m.Enabled(ctx), ReplacedByPrebuilt: m.commonProperties.ReplacedByPrebuilt, Target: m.commonProperties.CompileTarget, SkipAndroidMkProcessing: shouldSkipAndroidMkProcessing(ctx, m), @@ -2261,6 +2281,24 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) HideFromMake: m.commonProperties.HideFromMake, SkipInstall: m.commonProperties.SkipInstall, Host: m.Host(), + PrimaryLicensesProperty: m.primaryLicensesProperty, + Owner: m.module.Owner(), + SocSpecific: Bool(m.commonProperties.Soc_specific), + Vendor: Bool(m.commonProperties.Vendor), + Proprietary: Bool(m.commonProperties.Proprietary), + ProductSpecific: Bool(m.commonProperties.Product_specific), + SystemExtSpecific: Bool(m.commonProperties.System_ext_specific), + DeviceSpecific: Bool(m.commonProperties.Device_specific), + NoFullInstall: proptools.Bool(m.commonProperties.No_full_install), + InVendorRamdisk: m.InVendorRamdisk(), + ExemptFromRequiredApplicableLicensesProperty: exemptFromRequiredApplicableLicensesProperty(m.module), + RequiredModuleNames: m.module.RequiredModuleNames(ctx), + HostRequiredModuleNames: m.module.HostRequiredModuleNames(), + TargetRequiredModuleNames: m.module.TargetRequiredModuleNames(), + VintfFragmentModuleNames: m.module.VintfFragmentModuleNames(ctx), + Dists: m.Dists(), + ExportedToMake: m.ExportedToMake(), + Team: m.Team(), } if mm, ok := m.module.(interface { MinSdkVersion(ctx EarlyModuleContext) ApiLevel @@ -2289,11 +2327,6 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) commonData.SdkVersion = mm.SdkVersion() } - if m.commonProperties.ForcedDisabled { - commonData.Enabled = false - } else { - commonData.Enabled = m.commonProperties.Enabled.GetOrDefault(m.ConfigurableEvaluator(ctx), !m.Os().DefaultDisabled) - } if am, ok := m.module.(ApexModule); ok { commonData.CanHaveApexVariants = am.CanHaveApexVariants() commonData.NotAvailableForPlatform = am.NotAvailableForPlatform() @@ -2336,6 +2369,10 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) GeneratedDeps: s.GeneratedDeps(), }) } + + if v, ok := m.module.(ModuleMakeVarsProvider); m.Enabled(ctx) && ok { + SetProvider(ctx, ModuleMakeVarsInfoProvider, v.MakeVars(ctx)) + } } func SetJarJarPrefixHandler(handler func(ModuleContext)) { @@ -2852,6 +2889,8 @@ func OutputFilesForModule(ctx PathContext, module Module, tag string) Paths { // OutputFileForModule returns the output file paths with the given tag. On error, including if the // module produced zero or multiple paths, it reports errors to the ctx and returns nil. +// TODO(b/397766191): Change the signature to take ModuleProxy +// Please only access the module's internal data through providers. func OutputFileForModule(ctx PathContext, module Module, tag string) Path { paths, err := outputFilesForModule(ctx, module, tag) if err != nil { @@ -2892,6 +2931,8 @@ type OutputFilesProviderModuleContext interface { EqualModules(m1, m2 Module) bool } +// TODO(b/397766191): Change the signature to take ModuleProxy +// Please only access the module's internal data through providers. func outputFilesForModule(ctx PathContext, module Module, tag string) (Paths, error) { outputFilesFromProvider, err := outputFilesForModuleFromProvider(ctx, module, tag) if outputFilesFromProvider != nil || err != OutputFilesProviderNotSet { @@ -2924,14 +2965,12 @@ func outputFilesForModule(ctx PathContext, module Module, tag string) (Paths, er // If a module doesn't have the OutputFilesProvider, nil is returned. func outputFilesForModuleFromProvider(ctx PathContext, module Module, tag string) (Paths, error) { var outputFiles OutputFilesInfo - fromProperty := false if mctx, isMctx := ctx.(OutputFilesProviderModuleContext); isMctx { if !mctx.EqualModules(mctx.Module(), module) { outputFiles, _ = OtherModuleProvider(mctx, module, OutputFilesProvider) } else { outputFiles = mctx.GetOutputFiles() - fromProperty = true } } else if cta, isCta := ctx.(*singletonContextAdaptor); isCta { outputFiles, _ = OtherModuleProvider(cta, module, OutputFilesProvider) @@ -2948,10 +2987,8 @@ func outputFilesForModuleFromProvider(ctx PathContext, module Module, tag string } else if taggedOutputFiles, hasTag := outputFiles.TaggedOutputFiles[tag]; hasTag { return taggedOutputFiles, nil } else { - if fromProperty { - return nil, fmt.Errorf("unsupported tag %q for module getting its own output files", tag) - } else { - return nil, fmt.Errorf("unsupported module reference tag %q", tag) + return nil, UnsupportedOutputTagError{ + tag: tag, } } } @@ -2970,8 +3007,24 @@ type OutputFilesInfo struct { var OutputFilesProvider = blueprint.NewProvider[OutputFilesInfo]() +type UnsupportedOutputTagError struct { + tag string +} + +func (u UnsupportedOutputTagError) Error() string { + return fmt.Sprintf("unsupported output tag %q", u.tag) +} + +func (u UnsupportedOutputTagError) Is(e error) bool { + _, ok := e.(UnsupportedOutputTagError) + return ok +} + +var _ error = UnsupportedOutputTagError{} + // This is used to mark the case where OutputFilesProvider is not set on some modules. var OutputFilesProviderNotSet = fmt.Errorf("No output files from provider") +var ErrUnsupportedOutputTag = UnsupportedOutputTagError{} // Modules can implement HostToolProvider and return a valid OptionalPath from HostToolPath() to // specify that they can be used as a tool by a genrule module. @@ -3037,7 +3090,7 @@ func (c *buildTargetSingleton) GenerateBuildActions(ctx SingletonContext) { modulesInDir := make(map[string]Paths) - ctx.VisitAllModules(func(module Module) { + ctx.VisitAllModuleProxies(func(module ModuleProxy) { info := OtherModuleProviderOrDefault(ctx, module, FinalModuleBuildTargetsProvider) if info.CheckbuildTarget != nil { |