Merge "Fix include paths that match one file being included unconditionally"
This commit is contained in:
@@ -807,20 +807,16 @@ func (ctx *parseContext) handleSubConfig(
|
|||||||
if len(matchingPaths) > maxMatchingFiles {
|
if len(matchingPaths) > maxMatchingFiles {
|
||||||
return []starlarkNode{ctx.newBadNode(v, "there are >%d files matching the pattern, please rewrite it", maxMatchingFiles)}
|
return []starlarkNode{ctx.newBadNode(v, "there are >%d files matching the pattern, please rewrite it", maxMatchingFiles)}
|
||||||
}
|
}
|
||||||
if len(matchingPaths) == 1 {
|
|
||||||
res := inheritedStaticModule{ctx.newDependentModule(matchingPaths[0], loadAlways && ctx.ifNestLevel == 0), loadAlways}
|
needsWarning := pathPattern[0] == "" && len(ctx.includeTops) == 0
|
||||||
return []starlarkNode{processModule(res)}
|
res := inheritedDynamicModule{*varPath, []*moduleInfo{}, loadAlways, ctx.errorLocation(v), needsWarning}
|
||||||
} else {
|
for _, p := range matchingPaths {
|
||||||
needsWarning := pathPattern[0] == "" && len(ctx.includeTops) == 0
|
// A product configuration files discovered dynamically may attempt to inherit
|
||||||
res := inheritedDynamicModule{*varPath, []*moduleInfo{}, loadAlways, ctx.errorLocation(v), needsWarning}
|
// from another one which does not exist in this source tree. Prevent load errors
|
||||||
for _, p := range matchingPaths {
|
// by always loading the dynamic files as optional.
|
||||||
// A product configuration files discovered dynamically may attempt to inherit
|
res.candidateModules = append(res.candidateModules, ctx.newDependentModule(p, true))
|
||||||
// from another one which does not exist in this source tree. Prevent load errors
|
|
||||||
// by always loading the dynamic files as optional.
|
|
||||||
res.candidateModules = append(res.candidateModules, ctx.newDependentModule(p, true))
|
|
||||||
}
|
|
||||||
return []starlarkNode{processModule(res)}
|
|
||||||
}
|
}
|
||||||
|
return []starlarkNode{processModule(res)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ctx *parseContext) findMatchingPaths(pattern []string) []string {
|
func (ctx *parseContext) findMatchingPaths(pattern []string) []string {
|
||||||
|
@@ -1081,7 +1081,13 @@ load("//vendor/foo1:cfg.star|init", _cfg_init = "init")
|
|||||||
def init(g, handle):
|
def init(g, handle):
|
||||||
cfg = rblf.cfg(handle)
|
cfg = rblf.cfg(handle)
|
||||||
g["MY_PATH"] = "foo"
|
g["MY_PATH"] = "foo"
|
||||||
rblf.inherit(handle, "vendor/foo1/cfg", _cfg_init)
|
_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)
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1101,8 +1107,20 @@ load("//vendor/foo1:cfg.star|init", _cfg_init = "init")
|
|||||||
def init(g, handle):
|
def init(g, handle):
|
||||||
cfg = rblf.cfg(handle)
|
cfg = rblf.cfg(handle)
|
||||||
g["MY_PATH"] = "foo"
|
g["MY_PATH"] = "foo"
|
||||||
rblf.inherit(handle, "vendor/foo1/cfg", _cfg_init)
|
_entry = {
|
||||||
rblf.inherit(handle, "vendor/foo1/cfg", _cfg_init)
|
"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)
|
||||||
|
_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)
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1126,9 +1144,21 @@ load("//bar:font.star|init", _font1_init = "init")
|
|||||||
|
|
||||||
def init(g, handle):
|
def init(g, handle):
|
||||||
cfg = rblf.cfg(handle)
|
cfg = rblf.cfg(handle)
|
||||||
rblf.inherit(handle, "foo/font", _font_init)
|
_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)
|
||||||
# There's some space and even this comment between the include_top and the inherit-product
|
# There's some space and even this comment between the include_top and the inherit-product
|
||||||
rblf.inherit(handle, "foo/font", _font_init)
|
_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.mkwarning("product.mk:11", "Please avoid starting an include path with a variable. See https://source.android.com/setup/build/bazel/product_config/issues/includes for details.")
|
rblf.mkwarning("product.mk:11", "Please avoid starting an include path with a variable. See https://source.android.com/setup/build/bazel/product_config/issues/includes for details.")
|
||||||
_entry = {
|
_entry = {
|
||||||
"foo/font.mk": ("foo/font", _font_init),
|
"foo/font.mk": ("foo/font", _font_init),
|
||||||
|
Reference in New Issue
Block a user