Switch Effective_license_text from []string to Paths

Effective_license_text contains paths to files that are copied from
one module to another and so need to be converted to Paths within the
context of the owning module as the paths are relative to the owning
module's directory.

The previous code did convert the license_text property to paths but
converted it back to strings again which was confusing and does not
follow the normal pattern.

Bug: 181569894
Test: m nothing
Change-Id: Iea09ee7f3de1187a2c3e41455ca83b0233d904b2
This commit is contained in:
Paul Duffin
2021-05-10 22:53:30 +01:00
parent df5a90502d
commit ec0836af3a
5 changed files with 20 additions and 21 deletions

View File

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