Allow generic $(findstring) calls
Previously they were only allowed in if statements.
Also update the if statement condition to allow comparisons
to the search term.
Bug: 201700692
Test: go test
Change-Id: I8bee8f716819d383423c0de233ab970e49890543
diff --git a/mk2rbc/mk2rbc_test.go b/mk2rbc/mk2rbc_test.go
index 78444c9..a1731a2 100644
--- a/mk2rbc/mk2rbc_test.go
+++ b/mk2rbc/mk2rbc_test.go
@@ -633,15 +633,42 @@
desc: "findstring call",
mkname: "product.mk",
in: `
+result := $(findstring a,a b c)
+result := $(findstring b,x y z)
+`,
+ expected: `load("//build/make/core:product_config.rbc", "rblf")
+
+def init(g, handle):
+ cfg = rblf.cfg(handle)
+ _result = rblf.findstring("a", "a b c")
+ _result = rblf.findstring("b", "x y z")
+`,
+ },
+ {
+ desc: "findstring in if statement",
+ mkname: "product.mk",
+ in: `
+ifeq ($(findstring foo,$(PRODUCT_PACKAGES)),)
+endif
ifneq ($(findstring foo,$(PRODUCT_PACKAGES)),)
endif
+ifeq ($(findstring foo,$(PRODUCT_PACKAGES)),foo)
+endif
+ifneq ($(findstring foo,$(PRODUCT_PACKAGES)),foo)
+endif
`,
expected: `load("//build/make/core:product_config.rbc", "rblf")
def init(g, handle):
cfg = rblf.cfg(handle)
+ if (cfg.get("PRODUCT_PACKAGES", [])).find("foo") == -1:
+ pass
if (cfg.get("PRODUCT_PACKAGES", [])).find("foo") != -1:
pass
+ if (cfg.get("PRODUCT_PACKAGES", [])).find("foo") != -1:
+ pass
+ if (cfg.get("PRODUCT_PACKAGES", [])).find("foo") == -1:
+ pass
`,
},
{