Add board_platform_in/board_platform_is runtime functions.
Bug: 190051051 Test: treehugger Change-Id: I27269fc0f0f7063635fbb1b1645919b604afb762
This commit is contained in:
parent
dc154164db
commit
3370ad5b70
3 changed files with 28 additions and 1 deletions
|
@ -396,6 +396,18 @@ def __base(path):
|
||||||
"""Returns basename."""
|
"""Returns basename."""
|
||||||
return path.rsplit("/",1)[-1]
|
return path.rsplit("/",1)[-1]
|
||||||
|
|
||||||
|
def _board_platform_in(g, string_or_list):
|
||||||
|
"""Returns true if board is in the list."""
|
||||||
|
board = g.get("TARGET_BOARD_PLATFORM","")
|
||||||
|
if not board:
|
||||||
|
return False
|
||||||
|
return board in __words(string_or_list)
|
||||||
|
|
||||||
|
|
||||||
|
def _board_platform_is(g, s):
|
||||||
|
"""True if board is the same as argument."""
|
||||||
|
return g.get("TARGET_BOARD_PLATFORM","") == s
|
||||||
|
|
||||||
|
|
||||||
def _copy_files(l, outdir):
|
def _copy_files(l, outdir):
|
||||||
"""Generate <item>:<outdir>/item for each item."""
|
"""Generate <item>:<outdir>/item for each item."""
|
||||||
|
@ -621,6 +633,8 @@ rblf = struct(
|
||||||
abspath = _abspath,
|
abspath = _abspath,
|
||||||
addprefix = _addprefix,
|
addprefix = _addprefix,
|
||||||
addsuffix = _addsuffix,
|
addsuffix = _addsuffix,
|
||||||
|
board_platform_in = _board_platform_in,
|
||||||
|
board_platform_is = _board_platform_is,
|
||||||
copy_files = _copy_files,
|
copy_files = _copy_files,
|
||||||
copy_if_exists = _copy_if_exists,
|
copy_if_exists = _copy_if_exists,
|
||||||
cfg = __h_cfg,
|
cfg = __h_cfg,
|
||||||
|
|
|
@ -55,3 +55,14 @@ def init(g, handle):
|
||||||
rblf.soong_config_set(g, "NS2", "v3", "abc")
|
rblf.soong_config_set(g, "NS2", "v3", "abc")
|
||||||
rblf.soong_config_set(g, "NS2", "v3", "xyz")
|
rblf.soong_config_set(g, "NS2", "v3", "xyz")
|
||||||
|
|
||||||
|
if rblf.board_platform_in(g, "board1 board2"):
|
||||||
|
cfg["PRODUCT_PACKAGES"] += ["bad_package"]
|
||||||
|
g["TARGET_BOARD_PLATFORM"] = "board1"
|
||||||
|
if rblf.board_platform_in(g, "board1 board2"):
|
||||||
|
cfg["PRODUCT_PACKAGES"] += ["board1_in"]
|
||||||
|
if rblf.board_platform_in(g, ["board3","board2"]):
|
||||||
|
cfg["PRODUCT_PACKAGES"] += ["bad_board_in"]
|
||||||
|
if rblf.board_platform_is(g, "board1"):
|
||||||
|
cfg["PRODUCT_PACKAGES"] += ["board1_is"]
|
||||||
|
if rblf.board_platform_is(g, "board2"):
|
||||||
|
cfg["PRODUCT_PACKAGES"] += ["bad_board1_is"]
|
||||||
|
|
|
@ -69,7 +69,9 @@ assert_eq(
|
||||||
"PRODUCT_PACKAGES": [
|
"PRODUCT_PACKAGES": [
|
||||||
"dev",
|
"dev",
|
||||||
"inc",
|
"inc",
|
||||||
"dev_after"
|
"dev_after",
|
||||||
|
"board1_in",
|
||||||
|
"board1_is",
|
||||||
],
|
],
|
||||||
"PRODUCT_PRODUCT_PROPERTIES": ["part_properties"]
|
"PRODUCT_PRODUCT_PROPERTIES": ["part_properties"]
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue