Ignore variable assignments that come after a rule definition
These private variables sometimes have references to make variables like $< or $@. When converted to starlark, they become invalid local variables like _< and _@, preventing the file from being loaded even if it's never executed. Bug: 226974242 Test: go test Change-Id: Iafd4c6939731f3b7c051c9e41464134d5b672f23
This commit is contained in:
@@ -531,7 +531,7 @@ func (ctx *parseContext) backNode() {
|
||||
|
||||
func (ctx *parseContext) handleAssignment(a *mkparser.Assignment) []starlarkNode {
|
||||
// Handle only simple variables
|
||||
if !a.Name.Const() {
|
||||
if !a.Name.Const() || a.Target != nil {
|
||||
return []starlarkNode{ctx.newBadNode(a, "Only simple variables are handled")}
|
||||
}
|
||||
name := a.Name.Strings[0]
|
||||
|
@@ -1242,13 +1242,15 @@ def init(g, handle):
|
||||
desc: "Ignore make rules",
|
||||
mkname: "product.mk",
|
||||
in: `
|
||||
foo: PRIVATE_VARIABLE = some_tool $< $@
|
||||
foo: foo.c
|
||||
gcc -o $@ $*`,
|
||||
expected: `load("//build/make/core:product_config.rbc", "rblf")
|
||||
|
||||
def init(g, handle):
|
||||
cfg = rblf.cfg(handle)
|
||||
rblf.mk2rbc_error("product.mk:2", "unsupported line rule: foo: foo.c\n#gcc -o $@ $*")
|
||||
rblf.mk2rbc_error("product.mk:2", "Only simple variables are handled")
|
||||
rblf.mk2rbc_error("product.mk:3", "unsupported line rule: foo: foo.c\n#gcc -o $@ $*")
|
||||
`,
|
||||
},
|
||||
{
|
||||
|
Reference in New Issue
Block a user