diff options
Diffstat (limited to 'android/module.go')
-rw-r--r-- | android/module.go | 121 |
1 files changed, 35 insertions, 86 deletions
diff --git a/android/module.go b/android/module.go index 7173c0d3c..450dba997 100644 --- a/android/module.go +++ b/android/module.go @@ -35,10 +35,6 @@ import ( var ( DeviceSharedLibrary = "shared_library" DeviceStaticLibrary = "static_library" - DeviceExecutable = "executable" - HostSharedLibrary = "host_shared_library" - HostStaticLibrary = "host_static_library" - HostExecutable = "host_executable" ) type BuildParams struct { @@ -515,7 +511,6 @@ type Module interface { ExportedToMake() bool InitRc() Paths VintfFragments() Paths - NoticeFiles() Paths EffectiveLicenseFiles() Paths AddProperties(props ...interface{}) @@ -831,9 +826,6 @@ type commonProperties struct { // names of other modules to install on target if this module is installed Target_required []string `android:"arch_variant"` - // relative path to a file to include in the list of notices for the device - Notice *string `android:"path"` - // The OsType of artifacts that this module variant is responsible for creating. // // Set by osMutator @@ -913,17 +905,8 @@ type commonProperties struct { // constants in image.go, but can also be set to a custom value by individual module types. ImageVariation string `blueprint:"mutated"` - // Information about _all_ bp2build targets generated by this module. Multiple targets are - // supported as Soong handles some things within a single target that we may choose to split into - // multiple targets, e.g. renderscript, protos, yacc within a cc module. - Bp2buildInfo []bp2buildInfo `blueprint:"mutated"` - - // UnconvertedBp2buildDep stores the module names of direct dependency that were not converted to - // Bazel - UnconvertedBp2buildDeps []string `blueprint:"mutated"` - - // MissingBp2buildDep stores the module names of direct dependency that were not found - MissingBp2buildDeps []string `blueprint:"mutated"` + // Bazel conversion status + BazelConversionStatus BazelConversionStatus `blueprint:"mutated"` } // CommonAttributes represents the common Bazel attributes from which properties @@ -993,8 +976,8 @@ func (t TaggedDistFiles) merge(other TaggedDistFiles) TaggedDistFiles { } func MakeDefaultDistFiles(paths ...Path) TaggedDistFiles { - for _, path := range paths { - if path == nil { + for _, p := range paths { + if p == nil { panic("The path to a dist file cannot be nil.") } } @@ -1018,7 +1001,6 @@ const ( MultilibFirst Multilib = "first" MultilibCommon Multilib = "common" MultilibCommonFirst Multilib = "common_first" - MultilibDefault Multilib = "" ) type HostOrDeviceSupported int @@ -1162,23 +1144,17 @@ func InitCommonOSAndroidMultiTargetsArchModule(m Module, hod HostOrDeviceSupport func (attrs *CommonAttributes) fillCommonBp2BuildModuleAttrs(ctx *topDownMutatorContext, enabledPropertyOverrides bazel.BoolAttribute) constraintAttributes { + + mod := ctx.Module().base() // Assert passed-in attributes include Name - name := attrs.Name - if len(name) == 0 { + if len(attrs.Name) == 0 { ctx.ModuleErrorf("CommonAttributes in fillCommonBp2BuildModuleAttrs expects a `.Name`!") } - mod := ctx.Module().base() - props := &mod.commonProperties - depsToLabelList := func(deps []string) bazel.LabelListAttribute { return bazel.MakeLabelListAttribute(BazelLabelForModuleDeps(ctx, deps)) } - data := &attrs.Data - - archVariantProps := mod.GetArchVariantProperties(ctx, &commonProperties{}) - var enabledProperty bazel.BoolAttribute onlyAndroid := false @@ -1206,11 +1182,11 @@ func (attrs *CommonAttributes) fillCommonBp2BuildModuleAttrs(ctx *topDownMutator neitherHostNorDevice = true } - for _, os := range OsTypeList() { - if os.Class == Host { - osSupport[os.Name] = moduleSupportsHost - } else if os.Class == Device { - osSupport[os.Name] = moduleSupportsDevice + for _, osType := range OsTypeList() { + if osType.Class == Host { + osSupport[osType.Name] = moduleSupportsHost + } else if osType.Class == Device { + osSupport[osType.Name] = moduleSupportsDevice } } } @@ -1218,25 +1194,26 @@ func (attrs *CommonAttributes) fillCommonBp2BuildModuleAttrs(ctx *topDownMutator if neitherHostNorDevice { // we can't build this, disable enabledProperty.Value = proptools.BoolPtr(false) - } else if props.Enabled != nil { - enabledProperty.SetValue(props.Enabled) - if !*props.Enabled { - for os, enabled := range osSupport { - if val := enabledProperty.SelectValue(bazel.OsConfigurationAxis, os); enabled && val != nil && *val { + } else if mod.commonProperties.Enabled != nil { + enabledProperty.SetValue(mod.commonProperties.Enabled) + if !*mod.commonProperties.Enabled { + for oss, enabled := range osSupport { + if val := enabledProperty.SelectValue(bazel.OsConfigurationAxis, oss); enabled && val != nil && *val { // if this should be disabled by default, clear out any enabling we've done - enabledProperty.SetSelectValue(bazel.OsConfigurationAxis, os, nil) + enabledProperty.SetSelectValue(bazel.OsConfigurationAxis, oss, nil) } } } } - required := depsToLabelList(props.Required) + required := depsToLabelList(mod.commonProperties.Required) + archVariantProps := mod.GetArchVariantProperties(ctx, &commonProperties{}) for axis, configToProps := range archVariantProps { for config, _props := range configToProps { if archProps, ok := _props.(*commonProperties); ok { // TODO(b/234748998) Remove this requiredFiltered workaround when aapt2 converts successfully requiredFiltered := archProps.Required - if name == "apexer" { + if attrs.Name == "apexer" { requiredFiltered = make([]string, 0, len(archProps.Required)) for _, req := range archProps.Required { if req != "aapt2" && req != "apexer" { @@ -1291,7 +1268,7 @@ func (attrs *CommonAttributes) fillCommonBp2BuildModuleAttrs(ctx *topDownMutator }) platformEnabledAttribute, err := enabledProperty.ToLabelListAttribute( - bazel.LabelList{[]bazel.Label{bazel.Label{Label: "@platforms//:incompatible"}}, nil}, + bazel.LabelList{[]bazel.Label{{Label: "@platforms//:incompatible"}}, nil}, bazel.LabelList{[]bazel.Label{}, nil}) if err != nil { ctx.ModuleErrorf("Error processing platform enabled attribute: %s", err) @@ -1304,15 +1281,13 @@ func (attrs *CommonAttributes) fillCommonBp2BuildModuleAttrs(ctx *topDownMutator platformEnabledAttribute.Add(&l) } - data.Append(required) + attrs.Data.Append(required) - constraints := constraintAttributes{} moduleEnableConstraints := bazel.LabelListAttribute{} moduleEnableConstraints.Append(platformEnabledAttribute) moduleEnableConstraints.Append(productConfigEnabledAttribute) - constraints.Target_compatible_with = moduleEnableConstraints - return constraints + return constraintAttributes{Target_compatible_with: moduleEnableConstraints} } // Check product variables for `enabled: true` flag override. @@ -1423,7 +1398,6 @@ type ModuleBase struct { checkbuildFiles Paths packagingSpecs []PackagingSpec packagingSpecsDepSet *packagingSpecsDepSet - noticeFiles Paths // katiInstalls tracks the install rules that were created by Soong but are being exported // to Make to convert to ninja rules so that Make can add additional dependencies. katiInstalls katiInstalls @@ -1494,40 +1468,40 @@ func (b bp2buildInfo) BazelAttributes() []interface{} { } func (m *ModuleBase) addBp2buildInfo(info bp2buildInfo) { - m.commonProperties.Bp2buildInfo = append(m.commonProperties.Bp2buildInfo, info) + m.commonProperties.BazelConversionStatus.Bp2buildInfo = append(m.commonProperties.BazelConversionStatus.Bp2buildInfo, info) } // IsConvertedByBp2build returns whether this module was converted via bp2build. func (m *ModuleBase) IsConvertedByBp2build() bool { - return len(m.commonProperties.Bp2buildInfo) > 0 + return len(m.commonProperties.BazelConversionStatus.Bp2buildInfo) > 0 } // Bp2buildTargets returns the Bazel targets bp2build generated for this module. func (m *ModuleBase) Bp2buildTargets() []bp2buildInfo { - return m.commonProperties.Bp2buildInfo + return m.commonProperties.BazelConversionStatus.Bp2buildInfo } // AddUnconvertedBp2buildDep stores module name of a dependency that was not converted to Bazel. func (b *baseModuleContext) AddUnconvertedBp2buildDep(dep string) { - unconvertedDeps := &b.Module().base().commonProperties.UnconvertedBp2buildDeps + unconvertedDeps := &b.Module().base().commonProperties.BazelConversionStatus.UnconvertedDeps *unconvertedDeps = append(*unconvertedDeps, dep) } // AddMissingBp2buildDep stores module name of a dependency that was not found in a Android.bp file. func (b *baseModuleContext) AddMissingBp2buildDep(dep string) { - missingDeps := &b.Module().base().commonProperties.MissingBp2buildDeps + missingDeps := &b.Module().base().commonProperties.BazelConversionStatus.MissingDeps *missingDeps = append(*missingDeps, dep) } // GetUnconvertedBp2buildDeps returns the list of module names of this module's direct dependencies that // were not converted to Bazel. func (m *ModuleBase) GetUnconvertedBp2buildDeps() []string { - return FirstUniqueStrings(m.commonProperties.UnconvertedBp2buildDeps) + return FirstUniqueStrings(m.commonProperties.BazelConversionStatus.UnconvertedDeps) } // GetMissingBp2buildDeps eturns the list of module names that were not found in Android.bp files. func (m *ModuleBase) GetMissingBp2buildDeps() []string { - return FirstUniqueStrings(m.commonProperties.MissingBp2buildDeps) + return FirstUniqueStrings(m.commonProperties.BazelConversionStatus.MissingDeps) } func (m *ModuleBase) AddJSONData(d *map[string]interface{}) { @@ -1656,7 +1630,7 @@ func (m *ModuleBase) BuildParamsForTests() []BuildParams { // transformSourceToObj, and should only affects unit tests. vars := m.VariablesForTests() buildParams := append([]BuildParams(nil), m.buildParams...) - for i, _ := range buildParams { + for i := range buildParams { newArgs := make(map[string]string) for k, v := range buildParams[i].Args { newArgs[k] = v @@ -2054,10 +2028,6 @@ func (m *ModuleBase) Owner() string { return String(m.commonProperties.Owner) } -func (m *ModuleBase) NoticeFiles() Paths { - return m.noticeFiles -} - func (m *ModuleBase) setImageVariation(variant string) { m.commonProperties.ImageVariation = variant } @@ -2305,7 +2275,7 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) // Some common property checks for properties that will be used later in androidmk.go checkDistProperties(ctx, "dist", &m.distProperties.Dist) - for i, _ := range m.distProperties.Dists { + for i := range m.distProperties.Dists { checkDistProperties(ctx, fmt.Sprintf("dists[%d]", i), &m.distProperties.Dists[i]) } @@ -2317,19 +2287,6 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext) } }) - m.noticeFiles = make([]Path, 0) - optPath := OptionalPath{} - notice := proptools.StringDefault(m.commonProperties.Notice, "") - if module := SrcIsModule(notice); module != "" { - optPath = ctx.ExpandOptionalSource(¬ice, "notice") - } else if notice != "" { - noticePath := filepath.Join(ctx.ModuleDir(), notice) - optPath = ExistentPathForSource(ctx, noticePath) - } - if optPath.Valid() { - m.noticeFiles = append(m.noticeFiles, optPath.Path()) - } - licensesPropertyFlattener(ctx) if ctx.Failed() { return @@ -3496,14 +3453,6 @@ func sourceOrOutputDepTag(moduleName, tag string) blueprint.DependencyTag { return sourceOrOutputDependencyTag{moduleName: moduleName, tag: tag} } -// IsSourceDepTag returns true if the supplied blueprint.DependencyTag is one that was used to add -// dependencies by either ExtractSourceDeps, ExtractSourcesDeps or automatically for properties -// tagged with `android:"path"`. -func IsSourceDepTag(depTag blueprint.DependencyTag) bool { - _, ok := depTag.(sourceOrOutputDependencyTag) - return ok -} - // IsSourceDepTagWithOutputTag returns true if the supplied blueprint.DependencyTag is one that was // used to add dependencies by either ExtractSourceDeps, ExtractSourcesDeps or automatically for // properties tagged with `android:"path"` AND it was added using a module reference of @@ -3630,14 +3579,14 @@ func (m *moduleContext) ExpandSources(srcFiles, excludes []string) Paths { // be tagged with `android:"path" to support automatic source module dependency resolution. // // Deprecated: use PathForModuleSrc instead. -func (m *moduleContext) ExpandSource(srcFile, prop string) Path { +func (m *moduleContext) ExpandSource(srcFile, _ string) Path { return PathForModuleSrc(m, srcFile) } // Returns an optional single path expanded from globs and modules referenced using ":module" syntax if // the srcFile is non-nil. The property must be tagged with `android:"path" to support automatic source module // dependency resolution. -func (m *moduleContext) ExpandOptionalSource(srcFile *string, prop string) OptionalPath { +func (m *moduleContext) ExpandOptionalSource(srcFile *string, _ string) OptionalPath { if srcFile != nil { return OptionalPathForPath(PathForModuleSrc(m, *srcFile)) } |