From b2e0b601266d89b6edaa0b6429d64cd303e5dbdc Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Fri, 7 Jan 2022 15:46:58 -0800 Subject: [PATCH] Consolidate conversions of is-board-platform(2) mk2rbc implements conversions for both is-board-platform(-in-list) and is-board-platform(-in-list)2. The conversions are not the same despite the functions being the same. Make them convert to the same thing. Bug: 201477826 Test: go test Change-Id: I688a2f6114e1688c713e42f0f9229cbc5ee6a917 --- mk2rbc/mk2rbc.go | 30 ++---------------------------- mk2rbc/mk2rbc_test.go | 4 ++-- 2 files changed, 4 insertions(+), 30 deletions(-) diff --git a/mk2rbc/mk2rbc.go b/mk2rbc/mk2rbc.go index 04038e46c..eb036cfab 100644 --- a/mk2rbc/mk2rbc.go +++ b/mk2rbc/mk2rbc.go @@ -91,9 +91,9 @@ var knownFunctions = map[string]interface { "foreach": &foreachCallPaser{}, "if": &ifCallParser{}, "info": &makeControlFuncParser{name: baseName + ".mkinfo"}, - "is-board-platform": &isBoardPlatformCallParser{}, + "is-board-platform": &simpleCallParser{name: baseName + ".board_platform_is", returnType: starlarkTypeBool, addGlobals: true}, "is-board-platform2": &simpleCallParser{name: baseName + ".board_platform_is", returnType: starlarkTypeBool, addGlobals: true}, - "is-board-platform-in-list": &isBoardPlatformInListCallParser{}, + "is-board-platform-in-list": &simpleCallParser{name: baseName + ".board_platform_in", returnType: starlarkTypeBool, addGlobals: true}, "is-board-platform-in-list2": &simpleCallParser{name: baseName + ".board_platform_in", returnType: starlarkTypeBool, addGlobals: true}, "is-product-in-list": &isProductInListCallParser{}, "is-vendor-board-platform": &isVendorBoardPlatformCallParser{}, @@ -1406,32 +1406,6 @@ func (p *myDirCallParser) parse(ctx *parseContext, node mkparser.Node, args *mkp return &variableRefExpr{ctx.addVariable("LOCAL_PATH"), true} } -type isBoardPlatformCallParser struct{} - -func (p *isBoardPlatformCallParser) parse(ctx *parseContext, node mkparser.Node, args *mkparser.MakeString) starlarkExpr { - if args.Empty() { - return ctx.newBadExpr(node, "is-board-platform requires an argument") - } - return &eqExpr{ - left: &variableRefExpr{ctx.addVariable("TARGET_BOARD_PLATFORM"), false}, - right: ctx.parseMakeString(node, args), - isEq: true, - } -} - -type isBoardPlatformInListCallParser struct{} - -func (p *isBoardPlatformInListCallParser) parse(ctx *parseContext, node mkparser.Node, args *mkparser.MakeString) starlarkExpr { - if args.Empty() { - return ctx.newBadExpr(node, "is-board-platform-in-list requires an argument") - } - return &inExpr{ - expr: &variableRefExpr{ctx.addVariable("TARGET_BOARD_PLATFORM"), false}, - list: maybeConvertToStringList(ctx.parseMakeString(node, args)), - isNot: false, - } -} - type isProductInListCallParser struct{} func (p *isProductInListCallParser) parse(ctx *parseContext, node mkparser.Node, args *mkparser.MakeString) starlarkExpr { diff --git a/mk2rbc/mk2rbc_test.go b/mk2rbc/mk2rbc_test.go index 1ba273b41..22117c1a5 100644 --- a/mk2rbc/mk2rbc_test.go +++ b/mk2rbc/mk2rbc_test.go @@ -598,9 +598,9 @@ endif def init(g, handle): cfg = rblf.cfg(handle) - if g.get("TARGET_BOARD_PLATFORM", "") in ["msm8998"]: + if rblf.board_platform_in(g, "msm8998"): pass - elif g.get("TARGET_BOARD_PLATFORM", "") != "copper": + elif not rblf.board_platform_is(g, "copper"): pass elif g.get("TARGET_BOARD_PLATFORM", "") not in g["QCOM_BOARD_PLATFORMS"]: pass