Merge changes Iac0f4ca9,I4a56efb2
* changes:
Support BUILD_HOST_static=1 for musl and linux_bionic builds
Support building python pars against static or shared musl libc
diff --git a/android/arch.go b/android/arch.go
index a7c62a9..6b81022 100644
--- a/android/arch.go
+++ b/android/arch.go
@@ -909,6 +909,7 @@
"Glibc",
"Musl",
"Linux",
+ "Host_linux",
"Not_windows",
"Arm_on_x86",
"Arm_on_x86_64",
@@ -930,6 +931,12 @@
targets = append(targets, target)
}
}
+ if os.Linux() && os.Class == Host {
+ target := "Host_linux_" + archType.Name
+ if !InList(target, targets) {
+ targets = append(targets, target)
+ }
+ }
if os.Bionic() {
target := "Bionic_" + archType.Name
if !InList(target, targets) {
@@ -1162,6 +1169,14 @@
}
}
+ if os.Linux() && os.Class == Host {
+ field := "Host_linux"
+ prefix := "target.host_linux"
+ if linuxProperties, ok := getChildPropertyStruct(ctx, targetProp, field, prefix); ok {
+ mergePropertyStruct(ctx, genProps, linuxProperties)
+ }
+ }
+
if os.Bionic() {
field := "Bionic"
prefix := "target.bionic"
@@ -2127,6 +2142,7 @@
linuxStructs := getTargetStructs(ctx, archProperties, "Linux")
bionicStructs := getTargetStructs(ctx, archProperties, "Bionic")
hostStructs := getTargetStructs(ctx, archProperties, "Host")
+ hostLinuxStructs := getTargetStructs(ctx, archProperties, "Host_linux")
hostNotWindowsStructs := getTargetStructs(ctx, archProperties, "Not_windows")
// For android, linux, ...
@@ -2147,6 +2163,9 @@
if os.Bionic() {
osStructs = append(osStructs, bionicStructs...)
}
+ if os.Linux() && os.Class == Host {
+ osStructs = append(osStructs, hostLinuxStructs...)
+ }
if os == LinuxMusl {
osStructs = append(osStructs, getTargetStructs(ctx, archProperties, "Musl")...)
diff --git a/android/arch_test.go b/android/arch_test.go
index 7caf837..68dc7f5 100644
--- a/android/arch_test.go
+++ b/android/arch_test.go
@@ -510,6 +510,7 @@
musl: { a: ["musl"] },
linux_bionic: { a: ["linux_bionic"] },
linux: { a: ["linux"] },
+ host_linux: { a: ["host_linux"] },
linux_glibc: { a: ["linux_glibc"] },
linux_musl: { a: ["linux_musl"] },
windows: { a: ["windows"], enabled: true },
@@ -566,12 +567,12 @@
{
module: "foo",
variant: "linux_glibc_x86_64",
- property: []string{"root", "host", "linux", "glibc", "linux_glibc", "not_windows", "x86_64", "lib64", "linux_x86_64", "linux_glibc_x86_64"},
+ property: []string{"root", "host", "linux", "host_linux", "glibc", "linux_glibc", "not_windows", "x86_64", "lib64", "linux_x86_64", "linux_glibc_x86_64"},
},
{
module: "foo",
variant: "linux_glibc_x86",
- property: []string{"root", "host", "linux", "glibc", "linux_glibc", "not_windows", "x86", "lib32", "linux_x86", "linux_glibc_x86"},
+ property: []string{"root", "host", "linux", "host_linux", "glibc", "linux_glibc", "not_windows", "x86", "lib32", "linux_x86", "linux_glibc_x86"},
},
},
},
@@ -605,12 +606,12 @@
{
module: "foo",
variant: "linux_musl_x86_64",
- property: []string{"root", "host", "linux", "musl", "linux_glibc", "linux_musl", "not_windows", "x86_64", "lib64", "linux_x86_64", "linux_musl_x86_64", "linux_glibc_x86_64"},
+ property: []string{"root", "host", "linux", "host_linux", "musl", "linux_glibc", "linux_musl", "not_windows", "x86_64", "lib64", "linux_x86_64", "linux_musl_x86_64", "linux_glibc_x86_64"},
},
{
module: "foo",
variant: "linux_musl_x86",
- property: []string{"root", "host", "linux", "musl", "linux_glibc", "linux_musl", "not_windows", "x86", "lib32", "linux_x86", "linux_musl_x86", "linux_glibc_x86"},
+ property: []string{"root", "host", "linux", "host_linux", "musl", "linux_glibc", "linux_musl", "not_windows", "x86", "lib32", "linux_x86", "linux_musl_x86", "linux_glibc_x86"},
},
},
},
diff --git a/java/droidstubs.go b/java/droidstubs.go
index 421737b..272cf1e 100644
--- a/java/droidstubs.go
+++ b/java/droidstubs.go
@@ -336,7 +336,9 @@
FlagWithArg("--hide ", "SuperfluousPrefix").
FlagWithArg("--hide ", "AnnotationExtraction").
// b/222738070
- FlagWithArg("--hide ", "BannedThrow")
+ FlagWithArg("--hide ", "BannedThrow").
+ // b/223382732
+ FlagWithArg("--hide ", "ChangedDefault")
}
}
diff --git a/mk2rbc/mk2rbc.go b/mk2rbc/mk2rbc.go
index 74053fe..d108a0d 100644
--- a/mk2rbc/mk2rbc.go
+++ b/mk2rbc/mk2rbc.go
@@ -465,17 +465,17 @@
return ctx
}
-func (ctx *parseContext) lastAssignment(name string) *assignmentNode {
+func (ctx *parseContext) lastAssignment(v variable) *assignmentNode {
for va := ctx.varAssignments; va != nil; va = va.outer {
- if v, ok := va.vars[name]; ok {
+ if v, ok := va.vars[v.name()]; ok {
return v
}
}
return nil
}
-func (ctx *parseContext) setLastAssignment(name string, asgn *assignmentNode) {
- ctx.varAssignments.vars[name] = asgn
+func (ctx *parseContext) setLastAssignment(v variable, asgn *assignmentNode) {
+ ctx.varAssignments.vars[v.name()] = asgn
}
func (ctx *parseContext) pushVarAssignments() {
@@ -532,7 +532,7 @@
if lhs == nil {
return []starlarkNode{ctx.newBadNode(a, "unknown variable %s", name)}
}
- _, isTraced := ctx.tracedVariables[name]
+ _, isTraced := ctx.tracedVariables[lhs.name()]
asgn := &assignmentNode{lhs: lhs, mkValue: a.Value, isTraced: isTraced, location: ctx.errorLocation(a)}
if lhs.valueType() == starlarkTypeUnknown {
// Try to divine variable type from the RHS
@@ -565,8 +565,8 @@
}
}
- asgn.previous = ctx.lastAssignment(name)
- ctx.setLastAssignment(name, asgn)
+ asgn.previous = ctx.lastAssignment(lhs)
+ ctx.setLastAssignment(lhs, asgn)
switch a.Type {
case "=", ":=":
asgn.flavor = asgnSet
@@ -1268,12 +1268,12 @@
args: []starlarkExpr{
&stringLiteralExpr{literal: substParts[0]},
&stringLiteralExpr{literal: substParts[1]},
- NewVariableRefExpr(v, ctx.lastAssignment(v.name()) != nil),
+ NewVariableRefExpr(v, ctx.lastAssignment(v) != nil),
},
}
}
if v := ctx.addVariable(refDump); v != nil {
- return NewVariableRefExpr(v, ctx.lastAssignment(v.name()) != nil)
+ return NewVariableRefExpr(v, ctx.lastAssignment(v) != nil)
}
return ctx.newBadExpr(node, "unknown variable %s", refDump)
}
diff --git a/mk2rbc/mk2rbc_test.go b/mk2rbc/mk2rbc_test.go
index 55d48ff..556dcaa 100644
--- a/mk2rbc/mk2rbc_test.go
+++ b/mk2rbc/mk2rbc_test.go
@@ -65,6 +65,10 @@
PRODUCT_NAME := Pixel 3
PRODUCT_MODEL :=
local_var = foo
+local-var-with-dashes := bar
+$(warning local-var-with-dashes: $(local-var-with-dashes))
+GLOBAL-VAR-WITH-DASHES := baz
+$(warning GLOBAL-VAR-WITH-DASHES: $(GLOBAL-VAR-WITH-DASHES))
`,
expected: `load("//build/make/core:product_config.rbc", "rblf")
@@ -73,6 +77,10 @@
cfg["PRODUCT_NAME"] = "Pixel 3"
cfg["PRODUCT_MODEL"] = ""
_local_var = "foo"
+ _local_var_with_dashes = "bar"
+ rblf.mkwarning("pixel3.mk", "local-var-with-dashes: %s" % _local_var_with_dashes)
+ g["GLOBAL-VAR-WITH-DASHES"] = "baz"
+ rblf.mkwarning("pixel3.mk", "GLOBAL-VAR-WITH-DASHES: %s" % g["GLOBAL-VAR-WITH-DASHES"])
`,
},
{
@@ -985,6 +993,7 @@
def init(g, handle):
cfg = rblf.cfg(handle)
if "hwaddress" not in cfg.get("PRODUCT_PACKAGES", []):
+ rblf.setdefault(handle, "PRODUCT_PACKAGES")
cfg["PRODUCT_PACKAGES"] = (rblf.mkstrip("%s hwaddress" % " ".join(cfg.get("PRODUCT_PACKAGES", [])))).split()
`,
},
diff --git a/mk2rbc/variable.go b/mk2rbc/variable.go
index f7adca5..6805744 100644
--- a/mk2rbc/variable.go
+++ b/mk2rbc/variable.go
@@ -88,20 +88,33 @@
}
value.emit(gctx)
}
-
- switch asgn.flavor {
- case asgnSet:
- emitAssignment()
- case asgnAppend:
- emitAppend()
- case asgnMaybeAppend:
- // If we are not sure variable has been assigned before, emit setdefault
+ emitSetDefault := func() {
if pcv.typ == starlarkTypeList {
gctx.writef("%s(handle, %q)", cfnSetListDefault, pcv.name())
} else {
gctx.writef("cfg.setdefault(%q, %s)", pcv.name(), pcv.defaultValueString())
}
gctx.newLine()
+ }
+
+ switch asgn.flavor {
+ case asgnSet:
+ isSelfReferential := false
+ asgn.value.transform(func(expr starlarkExpr) starlarkExpr {
+ if ref, ok := expr.(*variableRefExpr); ok && ref.ref.name() == pcv.name() {
+ isSelfReferential = true
+ }
+ return nil
+ })
+ if isSelfReferential {
+ emitSetDefault()
+ }
+ emitAssignment()
+ case asgnAppend:
+ emitAppend()
+ case asgnMaybeAppend:
+ // If we are not sure variable has been assigned before, emit setdefault
+ emitSetDefault()
emitAppend()
case asgnMaybeSet:
gctx.writef("if cfg.get(%q) == None:", pcv.nam)
@@ -278,6 +291,14 @@
// addVariable returns a variable with a given name. A variable is
// added if it does not exist yet.
func (ctx *parseContext) addVariable(name string) variable {
+ // Heuristics: if variable's name is all lowercase, consider it local
+ // string variable.
+ isLocalVariable := name == strings.ToLower(name)
+ // Local variables can't have special characters in them, because they
+ // will be used as starlark identifiers
+ if isLocalVariable {
+ name = strings.ReplaceAll(strings.TrimSpace(name), "-", "_")
+ }
v, found := ctx.variables[name]
if !found {
_, preset := presetVariables[name]
@@ -288,9 +309,7 @@
case VarClassSoong:
v = &otherGlobalVariable{baseVariable{nam: name, typ: vi.valueType, preset: preset}}
}
- } else if name == strings.ToLower(name) {
- // Heuristics: if variable's name is all lowercase, consider it local
- // string variable.
+ } else if isLocalVariable {
v = &localVariable{baseVariable{nam: name, typ: starlarkTypeUnknown}}
} else {
vt := starlarkTypeUnknown