cc_test: emit errors if there's duplicate in srcs
am: a61ff2cec3
Change-Id: Iace7509da2d9bf6cca8f5820ed4e7ac6b93f7316
This commit is contained in:
15
cc/test.go
15
cc/test.go
@@ -120,6 +120,10 @@ func testPerSrcMutator(mctx android.BottomUpMutatorContext) {
|
|||||||
if m, ok := mctx.Module().(*Module); ok {
|
if m, ok := mctx.Module().(*Module); ok {
|
||||||
if test, ok := m.linker.(testPerSrc); ok {
|
if test, ok := m.linker.(testPerSrc); ok {
|
||||||
if test.testPerSrc() && len(test.srcs()) > 0 {
|
if test.testPerSrc() && len(test.srcs()) > 0 {
|
||||||
|
if duplicate, found := checkDuplicate(test.srcs()); found {
|
||||||
|
mctx.PropertyErrorf("srcs", "found a duplicate entry %q", duplicate)
|
||||||
|
return
|
||||||
|
}
|
||||||
testNames := make([]string, len(test.srcs()))
|
testNames := make([]string, len(test.srcs()))
|
||||||
for i, src := range test.srcs() {
|
for i, src := range test.srcs() {
|
||||||
testNames[i] = strings.TrimSuffix(filepath.Base(src), filepath.Ext(src))
|
testNames[i] = strings.TrimSuffix(filepath.Base(src), filepath.Ext(src))
|
||||||
@@ -133,6 +137,17 @@ func testPerSrcMutator(mctx android.BottomUpMutatorContext) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func checkDuplicate(values []string) (duplicate string, found bool) {
|
||||||
|
seen := make(map[string]string)
|
||||||
|
for _, v := range values {
|
||||||
|
if duplicate, found = seen[v]; found {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
seen[v] = v
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
type testDecorator struct {
|
type testDecorator struct {
|
||||||
Properties TestProperties
|
Properties TestProperties
|
||||||
linker *baseLinker
|
linker *baseLinker
|
||||||
|
Reference in New Issue
Block a user