Add androidmk error for multiple assignments
Identify variables that are cleared or reassigned, add an error and prevent reassignment which caused a parser error. Test: go test androidmk_test Bug: 112653593 Change-Id: I0db3372b60812ff4cdaebb38a56ed0af0dbdb27e
This commit is contained in:
parent
29abfb7fd1
commit
5e4070cb6b
2 changed files with 32 additions and 0 deletions
|
@ -458,6 +458,9 @@ func setVariable(file *bpFile, plusequals bool, prefix, name string, value bppar
|
|||
}
|
||||
file.defs = append(file.defs, a)
|
||||
} else {
|
||||
if _, ok := file.globalAssignments[name]; ok {
|
||||
return fmt.Errorf("cannot assign a variable multiple times: \"%s\"", name)
|
||||
}
|
||||
a := &bpparser.Assignment{
|
||||
Name: name,
|
||||
NamePos: pos,
|
||||
|
|
|
@ -1386,6 +1386,35 @@ cc_binary {
|
|||
name: "test",
|
||||
srcs: dashed_dash_variable,
|
||||
}
|
||||
`,
|
||||
},
|
||||
{
|
||||
desc: "variableReassigned",
|
||||
in: `
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
src_files:= a.cpp
|
||||
|
||||
LOCAL_SRC_FILES:= $(src_files)
|
||||
LOCAL_MODULE:= test
|
||||
include $(BUILD_EXECUTABLE)
|
||||
|
||||
# clear locally used variable
|
||||
src_files:=
|
||||
`,
|
||||
expected: `
|
||||
|
||||
|
||||
src_files = ["a.cpp"]
|
||||
cc_binary {
|
||||
name: "test",
|
||||
|
||||
srcs: src_files,
|
||||
}
|
||||
|
||||
// clear locally used variable
|
||||
// ANDROIDMK TRANSLATION ERROR: cannot assign a variable multiple times: "src_files"
|
||||
// src_files :=
|
||||
`,
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue