Merge "Make include_top comments only apply to the next statement" am: 03a0679529
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1940099 Change-Id: Ife489d526319269520ebd3b9d93e3f079c4ed2b2
This commit is contained in:
commit
4d8ab7d1cc
2 changed files with 52 additions and 1 deletions
|
@ -446,7 +446,7 @@ func newParseContext(ss *StarlarkScript, nodes []mkparser.Node) *parseContext {
|
|||
variables: make(map[string]variable),
|
||||
dependentModules: make(map[string]*moduleInfo),
|
||||
soongNamespaces: make(map[string]map[string]bool),
|
||||
includeTops: []string{"vendor/google-devices"},
|
||||
includeTops: []string{},
|
||||
}
|
||||
ctx.pushVarAssignments()
|
||||
for _, item := range predefined {
|
||||
|
@ -809,6 +809,10 @@ func (ctx *parseContext) handleSubConfig(
|
|||
}
|
||||
}
|
||||
if pathPattern[0] == "" {
|
||||
if len(ctx.includeTops) == 0 {
|
||||
ctx.errorf(v, "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.")
|
||||
return
|
||||
}
|
||||
// If pattern starts from the top. restrict it to the directories where
|
||||
// we know inherit-product uses dynamically calculated path.
|
||||
for _, p := range ctx.includeTops {
|
||||
|
@ -1671,6 +1675,13 @@ func (ctx *parseContext) handleSimpleStatement(node mkparser.Node) {
|
|||
default:
|
||||
ctx.errorf(x, "unsupported line %s", strings.ReplaceAll(x.Dump(), "\n", "\n#"))
|
||||
}
|
||||
|
||||
// Clear the includeTops after each non-comment statement
|
||||
// so that include annotations placed on certain statements don't apply
|
||||
// globally for the rest of the makefile was well.
|
||||
if _, wasComment := node.(*mkparser.Comment); !wasComment && len(ctx.includeTops) > 0 {
|
||||
ctx.includeTops = []string{}
|
||||
}
|
||||
}
|
||||
|
||||
// Processes annotation. An annotation is a comment that starts with #RBC# and provides
|
||||
|
|
|
@ -1109,6 +1109,46 @@ def init(g, handle):
|
|||
if not _varmod_init:
|
||||
rblf.mkerror("product.mk", "Cannot find %s" % ("%s/cfg.mk" % g["MY_PATH"]))
|
||||
rblf.inherit(handle, _varmod, _varmod_init)
|
||||
`,
|
||||
},
|
||||
{
|
||||
desc: "Dynamic inherit path that lacks necessary hint",
|
||||
mkname: "product.mk",
|
||||
in: `
|
||||
#RBC# include_top foo
|
||||
$(call inherit-product,$(MY_VAR)/font.mk)
|
||||
|
||||
#RBC# include_top foo
|
||||
|
||||
# There's some space and even this comment between the include_top and the inherit-product
|
||||
|
||||
$(call inherit-product,$(MY_VAR)/font.mk)
|
||||
|
||||
$(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")
|
||||
|
||||
def init(g, handle):
|
||||
cfg = rblf.cfg(handle)
|
||||
_entry = {
|
||||
"foo/font.mk": ("_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)
|
||||
#RBC# include_top foo
|
||||
# There's some space and even this comment between the include_top and the inherit-product
|
||||
_entry = {
|
||||
"foo/font.mk": ("_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.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.")
|
||||
`,
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue