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
This commit is contained in:
Cole Faust
2022-03-09 16:00:17 -08:00
parent ce73506a85
commit e2a37988ff
4 changed files with 88 additions and 45 deletions

View File

@@ -50,15 +50,12 @@ const (
soongNsPrefix = "SOONG_CONFIG_"
// And here are the functions and variables:
cfnGetCfg = baseName + ".cfg"
cfnMain = baseName + ".product_configuration"
cfnBoardMain = baseName + ".board_configuration"
cfnPrintVars = baseName + ".printvars"
cfnWarning = baseName + ".warning"
cfnLocalAppend = baseName + ".local_append"
cfnLocalSetDefault = baseName + ".local_set_default"
cfnInherit = baseName + ".inherit"
cfnSetListDefault = baseName + ".setdefault"
cfnGetCfg = baseName + ".cfg"
cfnMain = baseName + ".product_configuration"
cfnBoardMain = baseName + ".board_configuration"
cfnPrintVars = baseName + ".printvars"
cfnInherit = baseName + ".inherit"
cfnSetListDefault = baseName + ".setdefault"
)
const (
@@ -571,11 +568,7 @@ func (ctx *parseContext) handleAssignment(a *mkparser.Assignment) []starlarkNode
case "=", ":=":
asgn.flavor = asgnSet
case "+=":
if asgn.previous == nil && !asgn.lhs.isPreset() {
asgn.flavor = asgnMaybeAppend
} else {
asgn.flavor = asgnAppend
}
asgn.flavor = asgnAppend
case "?=":
asgn.flavor = asgnMaybeSet
default: