diff options
Diffstat (limited to 'android/module.go')
-rw-r--r-- | android/module.go | 56 |
1 files changed, 22 insertions, 34 deletions
diff --git a/android/module.go b/android/module.go index 9f7cb377d..91f2056d4 100644 --- a/android/module.go +++ b/android/module.go @@ -603,6 +603,11 @@ type hostAndDeviceProperties struct { Device_supported *bool } +type hostCrossProperties struct { + // If set to true, build a variant of the module for the host cross. Defaults to true. + Host_cross_supported *bool +} + type Multilib string const ( @@ -718,6 +723,10 @@ func InitAndroidArchModule(m Module, hod HostOrDeviceSupported, defaultMultilib m.AddProperties(&base.hostAndDeviceProperties) } + if hod&hostCrossSupported != 0 { + m.AddProperties(&base.hostCrossProperties) + } + initArchModule(m) } @@ -803,6 +812,7 @@ type ModuleBase struct { distProperties distProperties variableProperties interface{} hostAndDeviceProperties hostAndDeviceProperties + hostCrossProperties hostCrossProperties // Arch specific versions of structs in GetProperties() prior to // initialization in InitAndroidArchModule, lets call it `generalProperties`. @@ -1207,29 +1217,7 @@ func (m *ModuleBase) GenerateTaggedDistFiles(ctx BaseModuleContext) TaggedDistFi continue } } - - // if the tagged dist file cannot be obtained from OutputFilesProvider, - // fall back to use OutputFileProducer - // TODO: remove this part after OutputFilesProvider fully replaces OutputFileProducer - if outputFileProducer, ok := m.module.(OutputFileProducer); ok { - // Call the OutputFiles(tag) method to get the paths associated with the tag. - distFilesForTag, err := outputFileProducer.OutputFiles(tag) - // If the tag was not supported and is not DefaultDistTag then it is an error. - // Failing to find paths for DefaultDistTag is not an error. It just means - // that the module type requires the legacy behavior. - if err != nil && tag != DefaultDistTag { - ctx.PropertyErrorf("dist.tag", "%s", err.Error()) - } - distFiles = distFiles.addPathsForTag(tag, distFilesForTag...) - } else if tag != DefaultDistTag { - // If the tag was specified then it is an error if the module does not - // implement OutputFileProducer because there is no other way of accessing - // the paths for the specified tag. - ctx.PropertyErrorf("dist.tag", - "tag %s not supported because the module does not implement OutputFileProducer", tag) - } } - return distFiles } @@ -1321,7 +1309,11 @@ func (m *ModuleBase) HostCrossSupported() bool { // hostEnabled is true if the host_supported property is true or the HostOrDeviceSupported // value has the hostDefault bit set. hostEnabled := proptools.BoolDefault(m.hostAndDeviceProperties.Host_supported, hod&hostDefault != 0) - return hod&hostCrossSupported != 0 && hostEnabled + + // Default true for the Host_cross_supported property + hostCrossEnabled := proptools.BoolDefault(m.hostCrossProperties.Host_cross_supported, true) + + return hod&hostCrossSupported != 0 && hostEnabled && hostCrossEnabled } func (m *ModuleBase) Platform() bool { @@ -1779,6 +1771,8 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) variables: make(map[string]string), } + setContainerInfo(ctx) + m.licenseMetadataFile = PathForModuleOut(ctx, "meta_lic") dependencyInstallFiles, dependencyPackagingSpecs := m.computeInstallDeps(ctx) @@ -2383,7 +2377,7 @@ type sourceOrOutputDependencyTag struct { // The name of the module. moduleName string - // The tag that will be passed to the module's OutputFileProducer.OutputFiles(tag) method. + // The tag that will be used to get the specific output file(s). tag string } @@ -2437,14 +2431,7 @@ type SourceFileProducer interface { Srcs() Paths } -// A module that implements OutputFileProducer can be referenced from any property that is tagged with `android:"path"` -// using the ":module" syntax or ":module{.tag}" syntax and provides a list of output files to be used as if they were -// listed in the property. -type OutputFileProducer interface { - OutputFiles(tag string) (Paths, error) -} - -// OutputFilesForModule returns the paths from an OutputFileProducer with the given tag. On error, including if the +// OutputFilesForModule returns the output file paths with the given tag. On error, including if the // module produced zero paths, it reports errors to the ctx and returns nil. func OutputFilesForModule(ctx PathContext, module blueprint.Module, tag string) Paths { paths, err := outputFilesForModule(ctx, module, tag) @@ -2455,7 +2442,7 @@ func OutputFilesForModule(ctx PathContext, module blueprint.Module, tag string) return paths } -// OutputFileForModule returns the path from an OutputFileProducer with the given tag. On error, including if the +// 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. func OutputFileForModule(ctx PathContext, module blueprint.Module, tag string) Path { paths, err := outputFilesForModule(ctx, module, tag) @@ -2531,8 +2518,9 @@ func outputFilesForModuleFromProvider(ctx PathContext, module blueprint.Module, } else if cta, isCta := ctx.(*singletonContextAdaptor); isCta { providerData, _ := cta.moduleProvider(module, OutputFilesProvider) outputFiles, _ = providerData.(OutputFilesInfo) + } else { + return nil, fmt.Errorf("unsupported context %q in method outputFilesForModuleFromProvider", reflect.TypeOf(ctx)) } - // TODO: Add a check for skipped context if outputFiles.isEmpty() { return nil, OutputFilesProviderNotSet |