Merge "Fix the names of the dynamically inherited modules."

This commit is contained in:
Treehugger Robot 2022-01-29 04:35:39 +00:00 committed by Gerrit Code Review
commit fd8f0ffee0
2 changed files with 12 additions and 12 deletions

View file

@ -1048,8 +1048,8 @@ def init(g, handle):
cfg = rblf.cfg(handle)
g["MY_PATH"] = "foo"
_entry = {
"vendor/foo1/cfg.mk": ("_cfg", _cfg_init),
"vendor/bar/baz/cfg.mk": ("_cfg1", _cfg1_init),
"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" % g["MY_PATH"])
(_varmod, _varmod_init) = _entry if _entry else (None, None)
if not _varmod_init:
@ -1073,7 +1073,7 @@ def init(g, handle):
g["MY_PATH"] = "foo"
#RBC# include_top vendor/foo1
_entry = {
"vendor/foo1/cfg.mk": ("_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:
@ -1099,7 +1099,7 @@ def init(g, handle):
g["MY_PATH"] = "foo"
#RBC# include_top vendor/foo1
_entry = {
"vendor/foo1/cfg.mk": ("_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:
@ -1107,7 +1107,7 @@ def init(g, handle):
rblf.inherit(handle, _varmod, _varmod_init)
#RBC# include_top vendor/foo1
_entry = {
"vendor/foo1/cfg.mk": ("_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:
@ -1137,7 +1137,7 @@ load("//foo:font.star|init", _font_init = "init")
def init(g, handle):
cfg = rblf.cfg(handle)
_entry = {
"foo/font.mk": ("_font", _font_init),
"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:
@ -1146,7 +1146,7 @@ def init(g, handle):
#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),
"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:

View file

@ -54,6 +54,10 @@ func (im moduleInfo) entryName() string {
return im.moduleLocalName + "_init"
}
func (mi moduleInfo) name() string {
return fmt.Sprintf("%q", MakePath2ModuleName(mi.originalPath))
}
type inheritedModule interface {
name() string
entryName() string
@ -67,10 +71,6 @@ type inheritedStaticModule struct {
loadAlways bool
}
func (im inheritedStaticModule) name() string {
return fmt.Sprintf("%q", MakePath2ModuleName(im.originalPath))
}
func (im inheritedStaticModule) emitSelect(_ *generationContext) {
}
@ -102,7 +102,7 @@ func (i inheritedDynamicModule) emitSelect(gctx *generationContext) {
gctx.indentLevel++
for _, mi := range i.candidateModules {
gctx.newLine()
gctx.writef(`"%s": (%q, %s),`, mi.originalPath, mi.moduleLocalName, mi.entryName())
gctx.writef(`"%s": (%s, %s),`, mi.originalPath, mi.name(), mi.entryName())
}
gctx.indentLevel--
gctx.newLine()