Remove ?= assignements to product variables
In make, all product variables are assigned to an empty string before
including the product config makefiles. In starlark, we don't do that
just so the memory usage is smaller. This means that in make, using
?= to assign a product config variable has no effect. Replicate this
behavior in starlark by not emitting any code for ?= assignments of
product variables.
Fixes: 304324003
Test: go test
Change-Id: Id31531506ac9e372a1bea92ce9ae8e17ae0ca70c
diff --git a/mk2rbc/mk2rbc.go b/mk2rbc/mk2rbc.go
index 3a6854c..78ab771 100644
--- a/mk2rbc/mk2rbc.go
+++ b/mk2rbc/mk2rbc.go
@@ -635,6 +635,13 @@
case "+=":
asgn.flavor = asgnAppend
case "?=":
+ if _, ok := lhs.(*productConfigVariable); ok {
+ // Make sets all product configuration variables to empty strings before running product
+ // config makefiles. ?= will have no effect on a variable that has been assigned before,
+ // even if assigned to an empty string. So just skip emitting any code for this
+ // assignment.
+ return nil
+ }
asgn.flavor = asgnMaybeSet
default:
panic(fmt.Errorf("unexpected assignment type %s", a.Type))