Allow variable-prefixed include statements in mk2rbc
mk2rbc was already searching the whole android tree for Makefiles, so allowing variable-prefixed include statements doesn't affect performance on the file searching front. On the generated code front, there's already a cap of 150 potentially-included makefiles that prevents the performance from getting too bad, and it can be lowered if necessary. Bug: 213508006 Test: go test Change-Id: I3a4e81acb3d97bee08ac3dbe63052a274acf5793
This commit is contained in:
@@ -1072,13 +1072,7 @@ def init(g, handle):
|
||||
cfg = rblf.cfg(handle)
|
||||
g["MY_PATH"] = "foo"
|
||||
#RBC# include_top vendor/foo1
|
||||
_entry = {
|
||||
"vendor/foo1/cfg.mk": ("vendor/foo1/cfg", _cfg_init),
|
||||
}.get("%s/cfg.mk" % g["MY_PATH"])
|
||||
(_varmod, _varmod_init) = _entry if _entry else (None, None)
|
||||
if not _varmod_init:
|
||||
rblf.mkerror("product.mk", "Cannot find %s" % ("%s/cfg.mk" % g["MY_PATH"]))
|
||||
rblf.inherit(handle, _varmod, _varmod_init)
|
||||
rblf.inherit(handle, "vendor/foo1/cfg", _cfg_init)
|
||||
`,
|
||||
},
|
||||
{
|
||||
@@ -1098,25 +1092,13 @@ def init(g, handle):
|
||||
cfg = rblf.cfg(handle)
|
||||
g["MY_PATH"] = "foo"
|
||||
#RBC# include_top vendor/foo1
|
||||
_entry = {
|
||||
"vendor/foo1/cfg.mk": ("vendor/foo1/cfg", _cfg_init),
|
||||
}.get("%s/cfg.mk" % g["MY_PATH"])
|
||||
(_varmod, _varmod_init) = _entry if _entry else (None, None)
|
||||
if not _varmod_init:
|
||||
rblf.mkerror("product.mk", "Cannot find %s" % ("%s/cfg.mk" % g["MY_PATH"]))
|
||||
rblf.inherit(handle, _varmod, _varmod_init)
|
||||
rblf.inherit(handle, "vendor/foo1/cfg", _cfg_init)
|
||||
#RBC# include_top vendor/foo1
|
||||
_entry = {
|
||||
"vendor/foo1/cfg.mk": ("vendor/foo1/cfg", _cfg_init),
|
||||
}.get("%s/cfg.mk" % g["MY_PATH"])
|
||||
(_varmod, _varmod_init) = _entry if _entry else (None, None)
|
||||
if not _varmod_init:
|
||||
rblf.mkerror("product.mk", "Cannot find %s" % ("%s/cfg.mk" % g["MY_PATH"]))
|
||||
rblf.inherit(handle, _varmod, _varmod_init)
|
||||
rblf.inherit(handle, "vendor/foo1/cfg", _cfg_init)
|
||||
`,
|
||||
},
|
||||
{
|
||||
desc: "Dynamic inherit path that lacks necessary hint",
|
||||
desc: "Dynamic inherit path that lacks hint",
|
||||
mkname: "product.mk",
|
||||
in: `
|
||||
#RBC# include_top foo
|
||||
@@ -1133,26 +1115,23 @@ $(call inherit-product,$(MY_VAR)/font.mk)
|
||||
expected: `#RBC# include_top foo
|
||||
load("//build/make/core:product_config.rbc", "rblf")
|
||||
load("//foo:font.star|init", _font_init = "init")
|
||||
load("//bar:font.star|init", _font1_init = "init")
|
||||
|
||||
def init(g, handle):
|
||||
cfg = rblf.cfg(handle)
|
||||
_entry = {
|
||||
"foo/font.mk": ("foo/font", _font_init),
|
||||
}.get("%s/font.mk" % g.get("MY_VAR", ""))
|
||||
(_varmod, _varmod_init) = _entry if _entry else (None, None)
|
||||
if not _varmod_init:
|
||||
rblf.mkerror("product.mk", "Cannot find %s" % ("%s/font.mk" % g.get("MY_VAR", "")))
|
||||
rblf.inherit(handle, _varmod, _varmod_init)
|
||||
rblf.inherit(handle, "foo/font", _font_init)
|
||||
#RBC# include_top foo
|
||||
# There's some space and even this comment between the include_top and the inherit-product
|
||||
rblf.inherit(handle, "foo/font", _font_init)
|
||||
rblf.mkwarning("product.mk:11", "Including a path with a non-constant prefix, please convert this to a simple literal to generate cleaner starlark.")
|
||||
_entry = {
|
||||
"foo/font.mk": ("foo/font", _font_init),
|
||||
"bar/font.mk": ("bar/font", _font1_init),
|
||||
}.get("%s/font.mk" % g.get("MY_VAR", ""))
|
||||
(_varmod, _varmod_init) = _entry if _entry else (None, None)
|
||||
if not _varmod_init:
|
||||
rblf.mkerror("product.mk", "Cannot find %s" % ("%s/font.mk" % g.get("MY_VAR", "")))
|
||||
rblf.inherit(handle, _varmod, _varmod_init)
|
||||
rblf.mk2rbc_error("product.mk:11", "inherit-product/include statements must not be prefixed with a variable, or must include a #RBC# include_top comment beforehand giving a root directory to search.")
|
||||
`,
|
||||
},
|
||||
{
|
||||
|
Reference in New Issue
Block a user