Merge "Prevent duplicate entries in ctx.include_tops"
This commit is contained in:
@@ -1629,6 +1629,13 @@ func (ctx *parseContext) maybeHandleAnnotation(cnode *mkparser.Comment) {
|
||||
return
|
||||
}
|
||||
if p, ok := maybeTrim(annotation, "include_top"); ok {
|
||||
// Don't allow duplicate include tops, because then we will generate
|
||||
// invalid starlark code. (duplicate keys in the _entry dictionary)
|
||||
for _, top := range ctx.includeTops {
|
||||
if top == p {
|
||||
return
|
||||
}
|
||||
}
|
||||
ctx.includeTops = append(ctx.includeTops, p)
|
||||
return
|
||||
}
|
||||
|
@@ -1075,6 +1075,40 @@ def init(g, handle):
|
||||
if not _varmod_init:
|
||||
rblf.mkerror("cannot")
|
||||
rblf.inherit(handle, _varmod, _varmod_init)
|
||||
`,
|
||||
},
|
||||
{
|
||||
desc: "Dynamic inherit with duplicated hint",
|
||||
mkname: "product.mk",
|
||||
in: `
|
||||
MY_PATH:=foo
|
||||
#RBC# include_top vendor/foo1
|
||||
$(call inherit-product,$(MY_PATH)/cfg.mk)
|
||||
#RBC# include_top vendor/foo1
|
||||
$(call inherit-product,$(MY_PATH)/cfg.mk)
|
||||
`,
|
||||
expected: `load("//build/make/core:product_config.rbc", "rblf")
|
||||
load("//vendor/foo1:cfg.star|init", _cfg_init = "init")
|
||||
|
||||
def init(g, handle):
|
||||
cfg = rblf.cfg(handle)
|
||||
g["MY_PATH"] = "foo"
|
||||
#RBC# include_top vendor/foo1
|
||||
_entry = {
|
||||
"vendor/foo1/cfg.mk": ("_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("cannot")
|
||||
rblf.inherit(handle, _varmod, _varmod_init)
|
||||
#RBC# include_top vendor/foo1
|
||||
_entry = {
|
||||
"vendor/foo1/cfg.mk": ("_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("cannot")
|
||||
rblf.inherit(handle, _varmod, _varmod_init)
|
||||
`,
|
||||
},
|
||||
{
|
||||
|
Reference in New Issue
Block a user