Allow non-constant from/to arguments in subst and patsubst
Fixes: 198502623 Test: internal Change-Id: Ia41a5a2e9315fcce351691749ac15de5df6916a4
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(),
|
||||
}
|
||||
}
|
||||
|
@@ -697,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)))
|
||||
@@ -720,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])
|
||||
|
Reference in New Issue
Block a user