Support complicated variable references

Bug: 226974242
Test: go test
Change-Id: Iaec16f5c498e7c75c9ee5d53d3499efadfba16bc
This commit is contained in:
Cole Faust
2022-04-28 14:29:57 -07:00
parent 85f8fa2c20
commit 1323877b7e
4 changed files with 55 additions and 3 deletions

View File

@@ -1597,6 +1597,27 @@ MY_VAR := foo
def init(g, handle):
cfg = rblf.cfg(handle)
g["MY_VAR"] = "foo"
`,
},
{
desc: "Complicated variable references",
mkname: "product.mk",
in: `
MY_VAR := foo
MY_VAR_2 := MY_VAR
MY_VAR_3 := $($(MY_VAR_2))
MY_VAR_4 := $(foo bar)
MY_VAR_5 := $($(MY_VAR_2) bar)
`,
expected: `load("//build/make/core:product_config.rbc", "rblf")
def init(g, handle):
cfg = rblf.cfg(handle)
g["MY_VAR"] = "foo"
g["MY_VAR_2"] = "MY_VAR"
g["MY_VAR_3"] = (cfg).get(g["MY_VAR_2"], (g).get(g["MY_VAR_2"], ""))
g["MY_VAR_4"] = rblf.mk2rbc_error("product.mk:5", "cannot handle invoking foo")
g["MY_VAR_5"] = rblf.mk2rbc_error("product.mk:6", "reference is too complex: $(MY_VAR_2) bar")
`,
},
}