Prevent duplicated license_kinds
Bazel fails when there are duplicate license_kinds.
Bug: 260148018
Test: go test
Change-Id: I47a27d37d66be947e4a744cd04a3cdcc0b000de4
diff --git a/android/license.go b/android/license.go
index cde5e6e..ab8431a 100644
--- a/android/license.go
+++ b/android/license.go
@@ -15,10 +15,12 @@
package android
import (
- "android/soong/bazel"
"fmt"
- "github.com/google/blueprint"
"os"
+
+ "github.com/google/blueprint"
+
+ "android/soong/bazel"
)
type licenseKindDependencyTag struct {
@@ -101,6 +103,14 @@
}
func (m *licenseModule) DepsMutator(ctx BottomUpMutatorContext) {
+ for i, license := range m.properties.License_kinds {
+ for j := i + 1; j < len(m.properties.License_kinds); j++ {
+ if license == m.properties.License_kinds[j] {
+ ctx.ModuleErrorf("Duplicated license kind: %q", license)
+ break
+ }
+ }
+ }
ctx.AddVariationDependencies(nil, licenseKindTag, m.properties.License_kinds...)
}