Merge changes Ia41a5a2e,Ib29654e7
* changes: Allow non-constant from/to arguments in subst and patsubst Handle ifdef for local variables.
This commit is contained in:
@@ -1388,11 +1388,14 @@ func (ctx *parseContext) parseSubstFunc(node mkparser.Node, fname string, args *
|
||||
if len(words) != 3 {
|
||||
return ctx.newBadExpr(node, "%s function should have 3 arguments", fname)
|
||||
}
|
||||
if !words[0].Const() || !words[1].Const() {
|
||||
return ctx.newBadExpr(node, "%s function's from and to arguments should be constant", fname)
|
||||
from := ctx.parseMakeString(node, words[0])
|
||||
if xBad, ok := from.(*badExpr); ok {
|
||||
return xBad
|
||||
}
|
||||
to := ctx.parseMakeString(node, words[1])
|
||||
if xBad, ok := to.(*badExpr); ok {
|
||||
return xBad
|
||||
}
|
||||
from := words[0].Strings[0]
|
||||
to := words[1].Strings[0]
|
||||
words[2].TrimLeftSpaces()
|
||||
words[2].TrimRightSpaces()
|
||||
obj := ctx.parseMakeString(node, words[2])
|
||||
@@ -1402,13 +1405,13 @@ func (ctx *parseContext) parseSubstFunc(node mkparser.Node, fname string, args *
|
||||
return &callExpr{
|
||||
object: obj,
|
||||
name: "replace",
|
||||
args: []starlarkExpr{&stringLiteralExpr{from}, &stringLiteralExpr{to}},
|
||||
args: []starlarkExpr{from, to},
|
||||
returnType: typ,
|
||||
}
|
||||
}
|
||||
return &callExpr{
|
||||
name: fname,
|
||||
args: []starlarkExpr{&stringLiteralExpr{from}, &stringLiteralExpr{to}, obj},
|
||||
args: []starlarkExpr{from, to, obj},
|
||||
returnType: obj.typ(),
|
||||
}
|
||||
}
|
||||
|
@@ -226,6 +226,9 @@ ifdef PRODUCT_NAME
|
||||
PRODUCT_NAME = gizmo
|
||||
else
|
||||
endif
|
||||
local_var :=
|
||||
ifdef local_var
|
||||
endif
|
||||
`,
|
||||
expected: `load("//build/make/core:product_config.rbc", "rblf")
|
||||
|
||||
@@ -235,6 +238,9 @@ def init(g, handle):
|
||||
cfg["PRODUCT_NAME"] = "gizmo"
|
||||
else:
|
||||
pass
|
||||
_local_var = ""
|
||||
if _local_var:
|
||||
pass
|
||||
`,
|
||||
},
|
||||
{
|
||||
@@ -691,7 +697,7 @@ def init(g, handle):
|
||||
PRODUCT_COPY_FILES := $(addprefix pfx-,a b c)
|
||||
PRODUCT_COPY_FILES := $(addsuffix .sff, a b c)
|
||||
PRODUCT_NAME := $(word 1, $(subst ., ,$(TARGET_BOARD_PLATFORM)))
|
||||
$(info $(patsubst %.pub,%,$(PRODUCT_ADB_KEYS)))
|
||||
$(info $(patsubst %.pub,$(PRODUCT_NAME)%,$(PRODUCT_ADB_KEYS)))
|
||||
$(info $(dir foo/bar))
|
||||
$(info $(firstword $(PRODUCT_COPY_FILES)))
|
||||
$(info $(lastword $(PRODUCT_COPY_FILES)))
|
||||
@@ -714,7 +720,7 @@ def init(g, handle):
|
||||
cfg["PRODUCT_COPY_FILES"] = rblf.addprefix("pfx-", "a b c")
|
||||
cfg["PRODUCT_COPY_FILES"] = rblf.addsuffix(".sff", "a b c")
|
||||
cfg["PRODUCT_NAME"] = ((g.get("TARGET_BOARD_PLATFORM", "")).replace(".", " ")).split()[0]
|
||||
rblf.mkinfo("product.mk", rblf.mkpatsubst("%.pub", "%", g.get("PRODUCT_ADB_KEYS", "")))
|
||||
rblf.mkinfo("product.mk", rblf.mkpatsubst("%.pub", "%s%%" % cfg["PRODUCT_NAME"], g.get("PRODUCT_ADB_KEYS", "")))
|
||||
rblf.mkinfo("product.mk", rblf.dir("foo/bar"))
|
||||
rblf.mkinfo("product.mk", cfg["PRODUCT_COPY_FILES"][0])
|
||||
rblf.mkinfo("product.mk", cfg["PRODUCT_COPY_FILES"][-1])
|
||||
|
@@ -177,8 +177,8 @@ type localVariable struct {
|
||||
baseVariable
|
||||
}
|
||||
|
||||
func (lv localVariable) emitDefined(_ *generationContext) {
|
||||
panic("implement me")
|
||||
func (lv localVariable) emitDefined(gctx *generationContext) {
|
||||
gctx.writef(lv.String())
|
||||
}
|
||||
|
||||
func (lv localVariable) String() string {
|
||||
|
Reference in New Issue
Block a user