Merge "Remove ?= assignements to product variables" into main am: cbe61221b6
am: 07829d80db
am: 0ed4cb5708
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2779549 Change-Id: I9f9cd87bc7c75df651168804c86cc72a995c852e Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
0e0fe0e511
3 changed files with 20 additions and 20 deletions
|
@ -635,6 +635,13 @@ func (ctx *parseContext) handleAssignment(a *mkparser.Assignment) []starlarkNode
|
||||||
case "+=":
|
case "+=":
|
||||||
asgn.flavor = asgnAppend
|
asgn.flavor = asgnAppend
|
||||||
case "?=":
|
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
|
asgn.flavor = asgnMaybeSet
|
||||||
default:
|
default:
|
||||||
panic(fmt.Errorf("unexpected assignment type %s", a.Type))
|
panic(fmt.Errorf("unexpected assignment type %s", a.Type))
|
||||||
|
|
|
@ -923,8 +923,6 @@ def init(g, handle):
|
||||||
cfg["PRODUCT_LIST2"] += ["a"]
|
cfg["PRODUCT_LIST2"] += ["a"]
|
||||||
cfg["PRODUCT_LIST1"] += ["b"]
|
cfg["PRODUCT_LIST1"] += ["b"]
|
||||||
cfg["PRODUCT_LIST2"] += ["b"]
|
cfg["PRODUCT_LIST2"] += ["b"]
|
||||||
if cfg.get("PRODUCT_LIST3") == None:
|
|
||||||
cfg["PRODUCT_LIST3"] = ["a"]
|
|
||||||
cfg["PRODUCT_LIST1"] = ["c"]
|
cfg["PRODUCT_LIST1"] = ["c"]
|
||||||
g.setdefault("PLATFORM_LIST", [])
|
g.setdefault("PLATFORM_LIST", [])
|
||||||
g["PLATFORM_LIST"] += ["x"]
|
g["PLATFORM_LIST"] += ["x"]
|
||||||
|
@ -966,9 +964,10 @@ PRODUCT_LIST1 = a $(PRODUCT_LIST1)
|
||||||
PRODUCT_LIST2 ?= a $(PRODUCT_LIST2)
|
PRODUCT_LIST2 ?= a $(PRODUCT_LIST2)
|
||||||
PRODUCT_LIST3 += a
|
PRODUCT_LIST3 += a
|
||||||
|
|
||||||
# Now doing them again should not have a setdefault because they've already been set
|
# Now doing them again should not have a setdefault because they've already been set, except 2
|
||||||
|
# which did not emit an assignment before
|
||||||
PRODUCT_LIST1 = a $(PRODUCT_LIST1)
|
PRODUCT_LIST1 = a $(PRODUCT_LIST1)
|
||||||
PRODUCT_LIST2 ?= a $(PRODUCT_LIST2)
|
PRODUCT_LIST2 = a $(PRODUCT_LIST2)
|
||||||
PRODUCT_LIST3 += a
|
PRODUCT_LIST3 += a
|
||||||
`,
|
`,
|
||||||
expected: `# All of these should have a setdefault because they're self-referential and not defined before
|
expected: `# All of these should have a setdefault because they're self-referential and not defined before
|
||||||
|
@ -979,18 +978,15 @@ def init(g, handle):
|
||||||
rblf.setdefault(handle, "PRODUCT_LIST1")
|
rblf.setdefault(handle, "PRODUCT_LIST1")
|
||||||
cfg["PRODUCT_LIST1"] = (["a"] +
|
cfg["PRODUCT_LIST1"] = (["a"] +
|
||||||
cfg.get("PRODUCT_LIST1", []))
|
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")
|
rblf.setdefault(handle, "PRODUCT_LIST3")
|
||||||
cfg["PRODUCT_LIST3"] += ["a"]
|
cfg["PRODUCT_LIST3"] += ["a"]
|
||||||
# Now doing them again should not have a setdefault because they've already been set
|
# Now doing them again should not have a setdefault because they've already been set, except 2
|
||||||
|
# which did not emit an assignment before
|
||||||
cfg["PRODUCT_LIST1"] = (["a"] +
|
cfg["PRODUCT_LIST1"] = (["a"] +
|
||||||
cfg["PRODUCT_LIST1"])
|
cfg["PRODUCT_LIST1"])
|
||||||
if cfg.get("PRODUCT_LIST2") == None:
|
rblf.setdefault(handle, "PRODUCT_LIST2")
|
||||||
cfg["PRODUCT_LIST2"] = (["a"] +
|
cfg["PRODUCT_LIST2"] = (["a"] +
|
||||||
cfg["PRODUCT_LIST2"])
|
cfg.get("PRODUCT_LIST2", []))
|
||||||
cfg["PRODUCT_LIST3"] += ["a"]
|
cfg["PRODUCT_LIST3"] += ["a"]
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
|
|
|
@ -109,14 +109,11 @@ func (pcv productConfigVariable) emitSet(gctx *generationContext, asgn *assignme
|
||||||
}
|
}
|
||||||
emitAppend()
|
emitAppend()
|
||||||
case asgnMaybeSet:
|
case asgnMaybeSet:
|
||||||
gctx.writef("if cfg.get(%q) == None:", pcv.nam)
|
// In mk2rbc.go we never emit a maybeSet assignment for product config variables, because
|
||||||
gctx.indentLevel++
|
// they are set to empty strings before running product config.
|
||||||
gctx.newLine()
|
panic("Should never get here")
|
||||||
if needsSetDefault {
|
default:
|
||||||
emitSetDefault()
|
panic("Unknown assignment flavor")
|
||||||
}
|
|
||||||
emitAssignment()
|
|
||||||
gctx.indentLevel--
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gctx.setHasBeenAssigned(&pcv)
|
gctx.setHasBeenAssigned(&pcv)
|
||||||
|
|
Loading…
Reference in a new issue