Merge "Switch Effective_license_text from []string to Paths" am: fffd98fd16

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1702369

Change-Id: I26fc1c416cad8025f236cc49dbd4c001f4a1862a
This commit is contained in:
Paul Duffin
2021-05-12 14:42:49 +00:00
committed by Automerger Merge Worker
5 changed files with 20 additions and 21 deletions

View File

@@ -501,7 +501,7 @@ func (a *AndroidMkEntries) fillInEntries(ctx fillInEntriesContext, mod blueprint
a.SetString("LOCAL_MODULE", name+a.SubName) a.SetString("LOCAL_MODULE", name+a.SubName)
a.AddStrings("LOCAL_LICENSE_KINDS", amod.commonProperties.Effective_license_kinds...) a.AddStrings("LOCAL_LICENSE_KINDS", amod.commonProperties.Effective_license_kinds...)
a.AddStrings("LOCAL_LICENSE_CONDITIONS", amod.commonProperties.Effective_license_conditions...) a.AddStrings("LOCAL_LICENSE_CONDITIONS", amod.commonProperties.Effective_license_conditions...)
a.AddStrings("LOCAL_NOTICE_FILE", amod.commonProperties.Effective_license_text...) a.AddStrings("LOCAL_NOTICE_FILE", amod.commonProperties.Effective_license_text.Strings()...)
// TODO(b/151177513): Does this code need to set LOCAL_MODULE_IS_CONTAINER ? // TODO(b/151177513): Does this code need to set LOCAL_MODULE_IS_CONTAINER ?
if amod.commonProperties.Effective_package_name != nil { if amod.commonProperties.Effective_package_name != nil {
a.SetString("LOCAL_LICENSE_PACKAGE_NAME", *amod.commonProperties.Effective_package_name) a.SetString("LOCAL_LICENSE_PACKAGE_NAME", *amod.commonProperties.Effective_package_name)

View File

@@ -62,12 +62,12 @@ func (m *licenseModule) DepsMutator(ctx BottomUpMutatorContext) {
func (m *licenseModule) GenerateAndroidBuildActions(ctx ModuleContext) { func (m *licenseModule) GenerateAndroidBuildActions(ctx ModuleContext) {
// license modules have no licenses, but license_kinds must refer to license_kind modules // license modules have no licenses, but license_kinds must refer to license_kind modules
mergeProps(&m.base().commonProperties.Effective_licenses, ctx.ModuleName()) mergeStringProps(&m.base().commonProperties.Effective_licenses, ctx.ModuleName())
mergeProps(&m.base().commonProperties.Effective_license_text, PathsForModuleSrc(ctx, m.properties.License_text).Strings()...) mergePathProps(&m.base().commonProperties.Effective_license_text, PathsForModuleSrc(ctx, m.properties.License_text)...)
for _, module := range ctx.GetDirectDepsWithTag(licenseKindTag) { for _, module := range ctx.GetDirectDepsWithTag(licenseKindTag) {
if lk, ok := module.(*licenseKindModule); ok { if lk, ok := module.(*licenseKindModule); ok {
mergeProps(&m.base().commonProperties.Effective_license_conditions, lk.properties.Conditions...) mergeStringProps(&m.base().commonProperties.Effective_license_conditions, lk.properties.Conditions...)
mergeProps(&m.base().commonProperties.Effective_license_kinds, ctx.OtherModuleName(module)) mergeStringProps(&m.base().commonProperties.Effective_license_kinds, ctx.OtherModuleName(module))
} else { } else {
ctx.ModuleErrorf("license_kinds property %q is not a license_kind module", ctx.OtherModuleName(module)) ctx.ModuleErrorf("license_kinds property %q is not a license_kind module", ctx.OtherModuleName(module))
} }

View File

@@ -196,10 +196,10 @@ func licensesPropertyFlattener(ctx ModuleContext) {
if m.base().commonProperties.Effective_package_name == nil && l.properties.Package_name != nil { if m.base().commonProperties.Effective_package_name == nil && l.properties.Package_name != nil {
m.base().commonProperties.Effective_package_name = l.properties.Package_name m.base().commonProperties.Effective_package_name = l.properties.Package_name
} }
mergeProps(&m.base().commonProperties.Effective_licenses, module.base().commonProperties.Effective_licenses...) mergeStringProps(&m.base().commonProperties.Effective_licenses, module.base().commonProperties.Effective_licenses...)
mergeProps(&m.base().commonProperties.Effective_license_text, module.base().commonProperties.Effective_license_text...) mergePathProps(&m.base().commonProperties.Effective_license_text, module.base().commonProperties.Effective_license_text...)
mergeProps(&m.base().commonProperties.Effective_license_kinds, module.base().commonProperties.Effective_license_kinds...) mergeStringProps(&m.base().commonProperties.Effective_license_kinds, module.base().commonProperties.Effective_license_kinds...)
mergeProps(&m.base().commonProperties.Effective_license_conditions, module.base().commonProperties.Effective_license_conditions...) mergeStringProps(&m.base().commonProperties.Effective_license_conditions, module.base().commonProperties.Effective_license_conditions...)
} else { } else {
propertyName := "licenses" propertyName := "licenses"
primaryProperty := m.base().primaryLicensesProperty primaryProperty := m.base().primaryLicensesProperty
@@ -212,16 +212,15 @@ func licensesPropertyFlattener(ctx ModuleContext) {
} }
// Update a property string array with a distinct union of its values and a list of new values. // Update a property string array with a distinct union of its values and a list of new values.
func mergeProps(prop *[]string, values ...string) { func mergeStringProps(prop *[]string, values ...string) {
s := make(map[string]bool) *prop = append(*prop, values...)
for _, v := range *prop { *prop = SortedUniqueStrings(*prop)
s[v] = true }
}
for _, v := range values { // Update a property Path array with a distinct union of its values and a list of new values.
s[v] = true func mergePathProps(prop *Paths, values ...Path) {
} *prop = append(*prop, values...)
*prop = []string{} *prop = SortedUniquePaths(*prop)
*prop = append(*prop, SortedStringKeys(s)...)
} }
// Get the licenses property falling back to the package default. // Get the licenses property falling back to the package default.

View File

@@ -658,7 +658,7 @@ func checkEffectiveNotices(t *testing.T, result *TestResult, effectiveNotices ma
if base == nil { if base == nil {
return return
} }
actualNotices[m.Name()] = base.commonProperties.Effective_license_text actualNotices[m.Name()] = base.commonProperties.Effective_license_text.Strings()
}) })
for moduleName, expectedNotices := range effectiveNotices { for moduleName, expectedNotices := range effectiveNotices {

View File

@@ -688,7 +688,7 @@ type commonProperties struct {
// Override of module name when reporting licenses // Override of module name when reporting licenses
Effective_package_name *string `blueprint:"mutated"` Effective_package_name *string `blueprint:"mutated"`
// Notice files // Notice files
Effective_license_text []string `blueprint:"mutated"` Effective_license_text Paths `blueprint:"mutated"`
// License names // License names
Effective_license_kinds []string `blueprint:"mutated"` Effective_license_kinds []string `blueprint:"mutated"`
// License conditions // License conditions