Merge changes from topics "dist_for_goals", "mk2star"
* changes:
Generate runtime conversion diagnostics
Convert dist-for-goals.
diff --git a/android/neverallow.go b/android/neverallow.go
index b36bf04..04366d3 100644
--- a/android/neverallow.go
+++ b/android/neverallow.go
@@ -214,11 +214,8 @@
return []Rule{
NeverAllow().
ModuleType("makefile_goal").
- // TODO(b/33691272): remove this after migrating seapp to Soong
- Without("product_out_path", "obj/ETC/plat_seapp_contexts_intermediates/plat_seapp_contexts").
- Without("product_out_path", "obj/ETC/plat_seapp_neverallows_intermediates/plat_seapp_neverallows").
WithoutMatcher("product_out_path", Regexp("^boot[0-9a-zA-Z.-]*[.]img$")).
- Because("Only boot images and seapp contexts may be imported as a makefile goal."),
+ Because("Only boot images may be imported as a makefile goal."),
}
}
diff --git a/android/neverallow_test.go b/android/neverallow_test.go
index edda244..35aadd8 100644
--- a/android/neverallow_test.go
+++ b/android/neverallow_test.go
@@ -293,7 +293,7 @@
`),
},
expectedErrors: []string{
- "Only boot images and seapp contexts may be imported as a makefile goal.",
+ "Only boot images may be imported as a makefile goal.",
},
},
}
diff --git a/mk2rbc/expr.go b/mk2rbc/expr.go
index 65fd6f7..ec0b279 100644
--- a/mk2rbc/expr.go
+++ b/mk2rbc/expr.go
@@ -222,9 +222,9 @@
s.expr.emit(ctx)
ctx.write("))")
case starlarkTypeBool:
- ctx.write("((")
+ ctx.write(`("true" if (`)
s.expr.emit(ctx)
- ctx.write(`) ? "true" : "")`)
+ ctx.write(`) else "")`)
case starlarkTypeVoid:
ctx.write(`""`)
default:
@@ -283,20 +283,33 @@
}
func (eq *eqExpr) emit(gctx *generationContext) {
- emitSimple := func(expr starlarkExpr) {
- if eq.isEq {
- gctx.write("not ")
- }
- expr.emit(gctx)
+ var stringOperand string
+ var otherOperand starlarkExpr
+ if s, ok := maybeString(eq.left); ok {
+ stringOperand = s
+ otherOperand = eq.right
+ } else if s, ok := maybeString(eq.right); ok {
+ stringOperand = s
+ otherOperand = eq.left
}
- // Are we checking that a variable is empty?
- if isEmptyString(eq.left) {
- emitSimple(eq.right)
- return
- } else if isEmptyString(eq.right) {
- emitSimple(eq.left)
- return
+ // If we've identified one of the operands as being a string literal, check
+ // for some special cases we can do to simplify the resulting expression.
+ if otherOperand != nil {
+ if stringOperand == "" {
+ if eq.isEq {
+ gctx.write("not ")
+ }
+ otherOperand.emit(gctx)
+ return
+ }
+ if stringOperand == "true" && otherOperand.typ() == starlarkTypeBool {
+ if !eq.isEq {
+ gctx.write("not ")
+ }
+ otherOperand.emit(gctx)
+ return
+ }
}
if eq.left.typ() != eq.right.typ() {
diff --git a/mk2rbc/mk2rbc_test.go b/mk2rbc/mk2rbc_test.go
index 22490a2..dfdf274 100644
--- a/mk2rbc/mk2rbc_test.go
+++ b/mk2rbc/mk2rbc_test.go
@@ -359,6 +359,21 @@
`,
},
{
+ desc: "ifeq with $(NATIVE_COVERAGE)",
+ mkname: "product.mk",
+ in: `
+ifeq ($(NATIVE_COVERAGE),true)
+endif
+`,
+ expected: `load("//build/make/core:product_config.rbc", "rblf")
+
+def init(g, handle):
+ cfg = rblf.cfg(handle)
+ if g.get("NATIVE_COVERAGE", False):
+ pass
+`,
+ },
+ {
desc: "Check filter result",
mkname: "product.mk",
in: `
@@ -1079,6 +1094,7 @@
class varClass
starlarkType
}{
+ {"NATIVE_COVERAGE", VarClassSoong, starlarkTypeBool},
{"PRODUCT_NAME", VarClassConfig, starlarkTypeString},
{"PRODUCT_MODEL", VarClassConfig, starlarkTypeString},
{"PRODUCT_PACKAGES", VarClassConfig, starlarkTypeList},