Loading mk2rbc/mk2rbc.go +23 −17 Original line number Original line Diff line number Diff line Loading @@ -830,21 +830,13 @@ func (ctx *parseContext) handleSubConfig( pathPattern = append(pathPattern, chunk) pathPattern = append(pathPattern, chunk) } } } } if pathPattern[0] == "" && len(ctx.includeTops) > 0 { if len(pathPattern) == 1 { // If pattern starts from the top. restrict it to the directories where pathPattern = append(pathPattern, "") // we know inherit-product uses dynamically calculated path. for _, p := range ctx.includeTops { pathPattern[0] = p matchingPaths = append(matchingPaths, ctx.findMatchingPaths(pathPattern)...) } } } else { matchingPaths = ctx.findMatchingPaths(pathPattern) matchingPaths = ctx.findMatchingPaths(pathPattern) } needsWarning = pathPattern[0] == "" && len(ctx.includeTops) == 0 needsWarning = pathPattern[0] == "" && len(ctx.includeTops) == 0 } else if len(ctx.includeTops) > 0 { } else if len(ctx.includeTops) > 0 { for _, p := range ctx.includeTops { matchingPaths = append(matchingPaths, ctx.findMatchingPaths([]string{"", ""})...) matchingPaths = append(matchingPaths, ctx.findMatchingPaths([]string{p, ""})...) } } else { } else { return []starlarkNode{ctx.newBadNode(v, "inherit-product/include argument is too complex")} return []starlarkNode{ctx.newBadNode(v, "inherit-product/include argument is too complex")} } } Loading Loading @@ -872,17 +864,31 @@ func (ctx *parseContext) findMatchingPaths(pattern []string) []string { } } // Create regular expression from the pattern // Create regular expression from the pattern s_regexp := "^" + regexp.QuoteMeta(pattern[0]) regexString := "^" + regexp.QuoteMeta(pattern[0]) for _, s := range pattern[1:] { for _, s := range pattern[1:] { s_regexp += ".*" + regexp.QuoteMeta(s) regexString += ".*" + regexp.QuoteMeta(s) } regexString += "$" rex := regexp.MustCompile(regexString) includeTopRegexString := "" if len(ctx.includeTops) > 0 { for i, top := range ctx.includeTops { if i > 0 { includeTopRegexString += "|" } } s_regexp += "$" includeTopRegexString += "^" + regexp.QuoteMeta(top) rex := regexp.MustCompile(s_regexp) } } else { includeTopRegexString = ".*" } includeTopRegex := regexp.MustCompile(includeTopRegexString) // Now match // Now match var res []string var res []string for _, p := range files { for _, p := range files { if rex.MatchString(p) { if rex.MatchString(p) && includeTopRegex.MatchString(p) { res = append(res, p) res = append(res, p) } } } } Loading mk2rbc/mk2rbc_test.go +9 −0 Original line number Original line Diff line number Diff line Loading @@ -1157,6 +1157,8 @@ $(call inherit-product,$(MY_PATH)/cfg.mk) #RBC# include_top vendor/foo1 #RBC# include_top vendor/foo1 $(call inherit-product,$(MY_OTHER_PATH)) $(call inherit-product,$(MY_OTHER_PATH)) #RBC# include_top vendor/foo1 #RBC# include_top vendor/foo1 $(call inherit-product,vendor/$(MY_OTHER_PATH)) #RBC# include_top vendor/foo1 $(foreach f,$(MY_MAKEFILES), \ $(foreach f,$(MY_MAKEFILES), \ $(call inherit-product,$(f))) $(call inherit-product,$(f))) `, `, Loading @@ -1180,6 +1182,13 @@ def init(g, handle): if not _varmod_init: if not _varmod_init: rblf.mkerror("product.mk", "Cannot find %s" % (g.get("MY_OTHER_PATH", ""))) rblf.mkerror("product.mk", "Cannot find %s" % (g.get("MY_OTHER_PATH", ""))) rblf.inherit(handle, _varmod, _varmod_init) rblf.inherit(handle, _varmod, _varmod_init) _entry = { "vendor/foo1/cfg.mk": ("vendor/foo1/cfg", _cfg_init), }.get("vendor/%s" % g.get("MY_OTHER_PATH", "")) (_varmod, _varmod_init) = _entry if _entry else (None, None) if not _varmod_init: rblf.mkerror("product.mk", "Cannot find %s" % ("vendor/%s" % g.get("MY_OTHER_PATH", ""))) rblf.inherit(handle, _varmod, _varmod_init) for f in rblf.words(g.get("MY_MAKEFILES", "")): for f in rblf.words(g.get("MY_MAKEFILES", "")): _entry = { _entry = { "vendor/foo1/cfg.mk": ("vendor/foo1/cfg", _cfg_init), "vendor/foo1/cfg.mk": ("vendor/foo1/cfg", _cfg_init), Loading Loading
mk2rbc/mk2rbc.go +23 −17 Original line number Original line Diff line number Diff line Loading @@ -830,21 +830,13 @@ func (ctx *parseContext) handleSubConfig( pathPattern = append(pathPattern, chunk) pathPattern = append(pathPattern, chunk) } } } } if pathPattern[0] == "" && len(ctx.includeTops) > 0 { if len(pathPattern) == 1 { // If pattern starts from the top. restrict it to the directories where pathPattern = append(pathPattern, "") // we know inherit-product uses dynamically calculated path. for _, p := range ctx.includeTops { pathPattern[0] = p matchingPaths = append(matchingPaths, ctx.findMatchingPaths(pathPattern)...) } } } else { matchingPaths = ctx.findMatchingPaths(pathPattern) matchingPaths = ctx.findMatchingPaths(pathPattern) } needsWarning = pathPattern[0] == "" && len(ctx.includeTops) == 0 needsWarning = pathPattern[0] == "" && len(ctx.includeTops) == 0 } else if len(ctx.includeTops) > 0 { } else if len(ctx.includeTops) > 0 { for _, p := range ctx.includeTops { matchingPaths = append(matchingPaths, ctx.findMatchingPaths([]string{"", ""})...) matchingPaths = append(matchingPaths, ctx.findMatchingPaths([]string{p, ""})...) } } else { } else { return []starlarkNode{ctx.newBadNode(v, "inherit-product/include argument is too complex")} return []starlarkNode{ctx.newBadNode(v, "inherit-product/include argument is too complex")} } } Loading Loading @@ -872,17 +864,31 @@ func (ctx *parseContext) findMatchingPaths(pattern []string) []string { } } // Create regular expression from the pattern // Create regular expression from the pattern s_regexp := "^" + regexp.QuoteMeta(pattern[0]) regexString := "^" + regexp.QuoteMeta(pattern[0]) for _, s := range pattern[1:] { for _, s := range pattern[1:] { s_regexp += ".*" + regexp.QuoteMeta(s) regexString += ".*" + regexp.QuoteMeta(s) } regexString += "$" rex := regexp.MustCompile(regexString) includeTopRegexString := "" if len(ctx.includeTops) > 0 { for i, top := range ctx.includeTops { if i > 0 { includeTopRegexString += "|" } } s_regexp += "$" includeTopRegexString += "^" + regexp.QuoteMeta(top) rex := regexp.MustCompile(s_regexp) } } else { includeTopRegexString = ".*" } includeTopRegex := regexp.MustCompile(includeTopRegexString) // Now match // Now match var res []string var res []string for _, p := range files { for _, p := range files { if rex.MatchString(p) { if rex.MatchString(p) && includeTopRegex.MatchString(p) { res = append(res, p) res = append(res, p) } } } } Loading
mk2rbc/mk2rbc_test.go +9 −0 Original line number Original line Diff line number Diff line Loading @@ -1157,6 +1157,8 @@ $(call inherit-product,$(MY_PATH)/cfg.mk) #RBC# include_top vendor/foo1 #RBC# include_top vendor/foo1 $(call inherit-product,$(MY_OTHER_PATH)) $(call inherit-product,$(MY_OTHER_PATH)) #RBC# include_top vendor/foo1 #RBC# include_top vendor/foo1 $(call inherit-product,vendor/$(MY_OTHER_PATH)) #RBC# include_top vendor/foo1 $(foreach f,$(MY_MAKEFILES), \ $(foreach f,$(MY_MAKEFILES), \ $(call inherit-product,$(f))) $(call inherit-product,$(f))) `, `, Loading @@ -1180,6 +1182,13 @@ def init(g, handle): if not _varmod_init: if not _varmod_init: rblf.mkerror("product.mk", "Cannot find %s" % (g.get("MY_OTHER_PATH", ""))) rblf.mkerror("product.mk", "Cannot find %s" % (g.get("MY_OTHER_PATH", ""))) rblf.inherit(handle, _varmod, _varmod_init) rblf.inherit(handle, _varmod, _varmod_init) _entry = { "vendor/foo1/cfg.mk": ("vendor/foo1/cfg", _cfg_init), }.get("vendor/%s" % g.get("MY_OTHER_PATH", "")) (_varmod, _varmod_init) = _entry if _entry else (None, None) if not _varmod_init: rblf.mkerror("product.mk", "Cannot find %s" % ("vendor/%s" % g.get("MY_OTHER_PATH", ""))) rblf.inherit(handle, _varmod, _varmod_init) for f in rblf.words(g.get("MY_MAKEFILES", "")): for f in rblf.words(g.get("MY_MAKEFILES", "")): _entry = { _entry = { "vendor/foo1/cfg.mk": ("vendor/foo1/cfg", _cfg_init), "vendor/foo1/cfg.mk": ("vendor/foo1/cfg", _cfg_init), Loading