summaryrefslogtreecommitdiff
path: root/mk2rbc/mk2rbc_test.go
diff options
context:
space:
mode:
author Cole Faust <colefaust@google.com> 2022-03-09 16:00:17 -0800
committer Cole Faust <colefaust@google.com> 2022-03-10 15:00:57 -0800
commite2a37988ffa9577b3b60d2612d07d10421b31eb7 (patch)
tree8dcfc782050947fcea0a4b89afa18cd43154c7ae /mk2rbc/mk2rbc_test.go
parentce73506a856e53859b00c92179a3c5909365eb76 (diff)
Simplify and correct variable assignments
- Remove asgnMaybeAppend, it was only used to indicate that the asignment needs a setDefault. But really, all types of variable assignments need setDefault if they're self-referential. - Remove local_append/local_set_default because there was no implementation for them written in product_config.rbc anyways. - Correct productConfigVariable.emitDefined using the global variables instead of the product config variables. - Emit setDefaults for all types of assignments if they're self referential. Bug: 222737841 Test: go test Change-Id: I06a0f90f16d5900049d473281e6d5ef5e93e67da
Diffstat (limited to 'mk2rbc/mk2rbc_test.go')
-rw-r--r--mk2rbc/mk2rbc_test.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/mk2rbc/mk2rbc_test.go b/mk2rbc/mk2rbc_test.go
index 556dcaa0c..35c54d268 100644
--- a/mk2rbc/mk2rbc_test.go
+++ b/mk2rbc/mk2rbc_test.go
@@ -901,6 +901,43 @@ def init(g, handle):
`,
},
{
+ desc: "assigment setdefaults",
+ mkname: "product.mk",
+ in: `
+# All of these should have a setdefault because they're self-referential and not defined before
+PRODUCT_LIST1 = a $(PRODUCT_LIST1)
+PRODUCT_LIST2 ?= a $(PRODUCT_LIST2)
+PRODUCT_LIST3 += a
+
+# Now doing them again should not have a setdefault because they've already been set
+PRODUCT_LIST1 = a $(PRODUCT_LIST1)
+PRODUCT_LIST2 ?= a $(PRODUCT_LIST2)
+PRODUCT_LIST3 += a
+`,
+ expected: `# All of these should have a setdefault because they're self-referential and not defined before
+load("//build/make/core:product_config.rbc", "rblf")
+
+def init(g, handle):
+ cfg = rblf.cfg(handle)
+ rblf.setdefault(handle, "PRODUCT_LIST1")
+ cfg["PRODUCT_LIST1"] = (["a"] +
+ cfg.get("PRODUCT_LIST1", []))
+ if cfg.get("PRODUCT_LIST2") == None:
+ rblf.setdefault(handle, "PRODUCT_LIST2")
+ cfg["PRODUCT_LIST2"] = (["a"] +
+ cfg.get("PRODUCT_LIST2", []))
+ rblf.setdefault(handle, "PRODUCT_LIST3")
+ cfg["PRODUCT_LIST3"] += ["a"]
+ # Now doing them again should not have a setdefault because they've already been set
+ cfg["PRODUCT_LIST1"] = (["a"] +
+ cfg["PRODUCT_LIST1"])
+ if cfg.get("PRODUCT_LIST2") == None:
+ cfg["PRODUCT_LIST2"] = (["a"] +
+ cfg["PRODUCT_LIST2"])
+ cfg["PRODUCT_LIST3"] += ["a"]
+`,
+ },
+ {
desc: "soong namespace assignments",
mkname: "product.mk",
in: `