Fix wildcard ('%') handling in the filter pattern.

Fixes: 200094780
Test: internal
Change-Id: I5f6a46679cdfa965ad98b9c0c22ef396a13a0bf6
This commit is contained in:
Sasha Smundak 2021-09-15 18:43:36 -07:00
parent ba26bdc316
commit 5f463be4a9
2 changed files with 16 additions and 5 deletions

View file

@ -1162,17 +1162,21 @@ func (ctx *parseContext) parseCompareFilterFuncResult(cond *mkparser.Directive,
}
// Either pattern or text should be const, and the
// non-const one should be varRefExpr
if xInList, ok = xPattern.(*stringLiteralExpr); ok {
if xInList, ok = xPattern.(*stringLiteralExpr); ok && !strings.ContainsRune(xInList.literal, '%') && xText.typ() == starlarkTypeList {
expr = xText
} else if xInList, ok = xText.(*stringLiteralExpr); ok {
expr = xPattern
} else {
return &callExpr{
expr = &callExpr{
object: nil,
name: filterFuncCall.name,
args: filterFuncCall.args,
returnType: starlarkTypeBool,
}
if negate {
expr = &notExpr{expr: expr}
}
return expr
}
case *variableRefExpr:
if v, ok := xPattern.(*variableRefExpr); ok {

View file

@ -360,20 +360,27 @@ ifeq ($(TARGET_BUILD_VARIANT), $(filter $(TARGET_BUILD_VARIANT), userdebug eng))
endif
ifneq (,$(filter true, $(v1)$(v2)))
endif
ifeq (,$(filter barbet coral%,$(TARGET_PRODUCT)))
else ifneq (,$(filter barbet%,$(TARGET_PRODUCT)))
endif
`,
expected: `load("//build/make/core:product_config.rbc", "rblf")
def init(g, handle):
cfg = rblf.cfg(handle)
if g["TARGET_BUILD_VARIANT"] not in ["userdebug", "eng"]:
if not rblf.filter("userdebug eng", g["TARGET_BUILD_VARIANT"]):
pass
if g["TARGET_BUILD_VARIANT"] == "userdebug":
if rblf.filter("userdebug", g["TARGET_BUILD_VARIANT"]):
pass
if "plaf" in g.get("PLATFORM_LIST", []):
pass
if g["TARGET_BUILD_VARIANT"] in ["userdebug", "eng"]:
pass
if "%s%s" % (_v1, _v2) == "true":
if rblf.filter("true", "%s%s" % (_v1, _v2)):
pass
if not rblf.filter("barbet coral%", g["TARGET_PRODUCT"]):
pass
elif rblf.filter("barbet%", g["TARGET_PRODUCT"]):
pass
`,
},