The waf build system uses lists for tool flags. The build items may use variable substitution. Add the ability to use the variable substitution in lists. For example:
MORE_FLAGS = ['-more', '-flags'] flags: - -some-flag - ${MORE_FLAGS} Before this change, the ${MORE_FLAGS} was substituted to "-more -flags". This would be passed by waf as a single command line argument to the tool. After this change, the ${MORE_FLAGS} list extends the flags list: flags = ['-some-flag', '-more', '-flags'] This list extension is performed if a list element consists of exactly one variable. Update #4670. --- wscript | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/wscript b/wscript index 731d1402ff..6ad230aca5 100755 --- a/wscript +++ b/wscript @@ -115,6 +115,9 @@ class Template(string.Template): idpattern = "[_A-Za-z][_A-Za-z0-9:#]*" +_VAR_PATTERN = re.compile("\$\{?(" + Template.idpattern + ")\}?$") + + def _is_enabled_op_and(enabled, enabled_by): for next_enabled_by in enabled_by: if not _is_enabled(enabled, next_enabled_by): @@ -249,18 +252,22 @@ class Item(object): ) ) if isinstance(value, list): - return [self.substitute(ctx, subvalue) for subvalue in value] + more = [] + for item in value: + if isinstance(item, str): + m = _VAR_PATTERN.match(item) + else: + m = None + if m: + more.extend(ctx.env[m.group(1).strip("{}")]) + else: + more.append(self.substitute(ctx, item)) + return more return value def get(self, ctx, name): return self.substitute(ctx, self.data[name]) - def get_values(self, ctx, name): - more = [] - for value in self.data[name]: - more.extend(self.substitute(ctx, value).split()) - return more - def install_target(self, bld): install_path = self.data["install-path"] if install_path: @@ -512,12 +519,12 @@ class GroupItem(Item): def prepare_build(self, bld, bic): return BuildItemContext( - bic.includes + self.get_values(bld, "includes"), + bic.includes + self.substitute(bld, self.data["includes"]), bic.cppflags, bic.cflags, bic.cxxflags, self.data["use-before"] + bic.use + self.data["use-after"], - bic.ldflags + self.get_values(bld, "ldflags"), + bic.ldflags + self.substitute(bld, self.data["ldflags"]), bic.objects, ) -- 2.35.3 _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel