Loading tools/compliance/noticeindex.go +2 −1 Original line number Diff line number Diff line Loading @@ -360,7 +360,8 @@ func (ni *NoticeIndex) getLibName(noticeFor *TargetNode, h hash) string { continue } } for r, prefix := range SafePrebuiltPrefixes { for _, r := range OrderedSafePrebuiltPrefixes { prefix := SafePrebuiltPrefixes[r] match := r.FindString(licenseText) if len(match) == 0 { continue Loading tools/compliance/policy_policy.go +43 −17 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package compliance import ( "regexp" "sort" "strings" ) var ( Loading @@ -41,6 +43,7 @@ var ( "development/": false, "frameworks/": false, "packages/": true, "prebuilts/module_sdk/": true, "prebuilts/": false, "sdk/": false, "system/": false, Loading @@ -53,6 +56,10 @@ var ( // containing the path of a safe prefix to the safe prefix. SafePrebuiltPrefixes = make(map[*regexp.Regexp]string) // OrderedSafePrebuiltPrefixes lists the SafePrebuiltPrefixes ordered by // increasing length. OrderedSafePrebuiltPrefixes = make([]*regexp.Regexp, 0, 0) // ImpliesUnencumbered lists the condition names representing an author attempt to disclaim copyright. ImpliesUnencumbered = LicenseConditionSet(UnencumberedCondition) Loading Loading @@ -89,14 +96,33 @@ var ( ccBySa = regexp.MustCompile(`^SPDX-license-identifier-CC-BY.*-SA.*`) ) // byIncreasingLength implements `sort.Interface` to order regular expressions by increasing length. type byIncreasingLength []*regexp.Regexp func (l byIncreasingLength) Len() int { return len(l) } func (l byIncreasingLength) Swap(i, j int) { l[i], l[j] = l[j], l[i] } func (l byIncreasingLength) Less(i, j int) bool { ri := l[i].String() rj := l[j].String() if len(ri) == len(rj) { return ri < rj } return len(ri) < len(rj) } func init() { for prefix := range SafePathPrefixes { if prefix == "prebuilts/" { if strings.HasPrefix(prefix, "prebuilts/") { continue } r := regexp.MustCompile("^prebuilts/[^ ]*/" + prefix) r := regexp.MustCompile("^prebuilts/(?:runtime/mainline/)?" + prefix) SafePrebuiltPrefixes[r] = prefix } OrderedSafePrebuiltPrefixes = make([]*regexp.Regexp, 0, len(SafePrebuiltPrefixes)) for r := range SafePrebuiltPrefixes { OrderedSafePrebuiltPrefixes = append(OrderedSafePrebuiltPrefixes, r) } sort.Sort(byIncreasingLength(OrderedSafePrebuiltPrefixes)) } // LicenseConditionSetFromNames returns a set containing the recognized `names` and Loading Loading
tools/compliance/noticeindex.go +2 −1 Original line number Diff line number Diff line Loading @@ -360,7 +360,8 @@ func (ni *NoticeIndex) getLibName(noticeFor *TargetNode, h hash) string { continue } } for r, prefix := range SafePrebuiltPrefixes { for _, r := range OrderedSafePrebuiltPrefixes { prefix := SafePrebuiltPrefixes[r] match := r.FindString(licenseText) if len(match) == 0 { continue Loading
tools/compliance/policy_policy.go +43 −17 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package compliance import ( "regexp" "sort" "strings" ) var ( Loading @@ -41,6 +43,7 @@ var ( "development/": false, "frameworks/": false, "packages/": true, "prebuilts/module_sdk/": true, "prebuilts/": false, "sdk/": false, "system/": false, Loading @@ -53,6 +56,10 @@ var ( // containing the path of a safe prefix to the safe prefix. SafePrebuiltPrefixes = make(map[*regexp.Regexp]string) // OrderedSafePrebuiltPrefixes lists the SafePrebuiltPrefixes ordered by // increasing length. OrderedSafePrebuiltPrefixes = make([]*regexp.Regexp, 0, 0) // ImpliesUnencumbered lists the condition names representing an author attempt to disclaim copyright. ImpliesUnencumbered = LicenseConditionSet(UnencumberedCondition) Loading Loading @@ -89,14 +96,33 @@ var ( ccBySa = regexp.MustCompile(`^SPDX-license-identifier-CC-BY.*-SA.*`) ) // byIncreasingLength implements `sort.Interface` to order regular expressions by increasing length. type byIncreasingLength []*regexp.Regexp func (l byIncreasingLength) Len() int { return len(l) } func (l byIncreasingLength) Swap(i, j int) { l[i], l[j] = l[j], l[i] } func (l byIncreasingLength) Less(i, j int) bool { ri := l[i].String() rj := l[j].String() if len(ri) == len(rj) { return ri < rj } return len(ri) < len(rj) } func init() { for prefix := range SafePathPrefixes { if prefix == "prebuilts/" { if strings.HasPrefix(prefix, "prebuilts/") { continue } r := regexp.MustCompile("^prebuilts/[^ ]*/" + prefix) r := regexp.MustCompile("^prebuilts/(?:runtime/mainline/)?" + prefix) SafePrebuiltPrefixes[r] = prefix } OrderedSafePrebuiltPrefixes = make([]*regexp.Regexp, 0, len(SafePrebuiltPrefixes)) for r := range SafePrebuiltPrefixes { OrderedSafePrebuiltPrefixes = append(OrderedSafePrebuiltPrefixes, r) } sort.Sort(byIncreasingLength(OrderedSafePrebuiltPrefixes)) } // LicenseConditionSetFromNames returns a set containing the recognized `names` and Loading