Merge "Handle include statements with trailing whitespace" into main am: a32f556ad3
am: 4a699d0d6d
am: 24a715658d
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2776869 Change-Id: Ia3e1486817acbf979062ca472c15ad7149960f80 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
750d2e9c56
2 changed files with 27 additions and 0 deletions
|
@ -941,6 +941,8 @@ func (p *inheritProductCallParser) parse(ctx *parseContext, v mkparser.Node, arg
|
||||||
|
|
||||||
func (ctx *parseContext) handleInclude(v *mkparser.Directive) []starlarkNode {
|
func (ctx *parseContext) handleInclude(v *mkparser.Directive) []starlarkNode {
|
||||||
loadAlways := v.Name[0] != '-'
|
loadAlways := v.Name[0] != '-'
|
||||||
|
v.Args.TrimRightSpaces()
|
||||||
|
v.Args.TrimLeftSpaces()
|
||||||
return ctx.handleSubConfig(v, ctx.parseMakeString(v, v.Args), loadAlways, func(im inheritedModule) starlarkNode {
|
return ctx.handleSubConfig(v, ctx.parseMakeString(v, v.Args), loadAlways, func(im inheritedModule) starlarkNode {
|
||||||
return &includeNode{im, loadAlways}
|
return &includeNode{im, loadAlways}
|
||||||
})
|
})
|
||||||
|
|
|
@ -192,6 +192,31 @@ def init(g, handle):
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
desc: "Include with trailing whitespace",
|
||||||
|
mkname: "product.mk",
|
||||||
|
in: `
|
||||||
|
# has a trailing whitespace after cfg.mk
|
||||||
|
include vendor/$(foo)/cfg.mk
|
||||||
|
`,
|
||||||
|
expected: `# has a trailing whitespace after cfg.mk
|
||||||
|
load("//build/make/core:product_config.rbc", "rblf")
|
||||||
|
load("//vendor/foo1:cfg.star|init", _cfg_init = "init")
|
||||||
|
load("//vendor/bar/baz:cfg.star|init", _cfg1_init = "init")
|
||||||
|
|
||||||
|
def init(g, handle):
|
||||||
|
cfg = rblf.cfg(handle)
|
||||||
|
_entry = {
|
||||||
|
"vendor/foo1/cfg.mk": ("vendor/foo1/cfg", _cfg_init),
|
||||||
|
"vendor/bar/baz/cfg.mk": ("vendor/bar/baz/cfg", _cfg1_init),
|
||||||
|
}.get("vendor/%s/cfg.mk" % _foo)
|
||||||
|
(_varmod, _varmod_init) = _entry if _entry else (None, None)
|
||||||
|
if not _varmod_init:
|
||||||
|
rblf.mkerror("product.mk", "Cannot find %s" % ("vendor/%s/cfg.mk" % _foo))
|
||||||
|
_varmod_init(g, handle)
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
desc: "Synonymous inherited configurations",
|
desc: "Synonymous inherited configurations",
|
||||||
mkname: "path/product.mk",
|
mkname: "path/product.mk",
|
||||||
|
|
Loading…
Reference in a new issue