This expands the ability to substitute variables outside the current
limitation of values in options to asflags, cflags, cppflags, cxxflags,
ldflags, and includes. It is possible for all of these flags to utilize
user-defined information in config.ini, especially for paths to external
resources.
---
 wscript | 54 ++++++++++++++++++++++++++++--------------------------
 1 file changed, 28 insertions(+), 26 deletions(-)

diff --git a/wscript b/wscript
index 4d63dbc66f..eb5761c53d 100755
--- a/wscript
+++ b/wscript
@@ -239,6 +239,8 @@ class Item(object):
         return
 
     def substitute(self, ctx, value):
+        if isinstance(value, list):
+            return [self.substitute(ctx, subvalue) for subvalue in value]
         if isinstance(value, str):
             try:
                 return Template(value).substitute(EnvWrapper(ctx.env))
@@ -272,10 +274,10 @@ class Item(object):
         if target is None:
             target = os.path.splitext(source)[0] + ".o"
         bld(
-            asflags=self.data["asflags"],
-            cppflags=self.data["cppflags"],
+            asflags=self.substitute(bld, self.data["asflags"]),
+            cppflags=self.substitute(bld, self.data["cppflags"]),
             features="asm_explicit_target asm c",
-            includes=bic.includes + self.data["includes"],
+            includes=bic.includes + self.substitute(bld, 
self.data["includes"]),
             source=[source],
             target=target,
         )
@@ -285,10 +287,10 @@ class Item(object):
         if target is None:
             target = os.path.splitext(source)[0] + ".o"
         bld(
-            cflags=self.data["cflags"],
-            cppflags=cppflags + self.data["cppflags"],
+            cflags=self.substitute(bld, self.data["cflags"]),
+            cppflags=cppflags + self.substitute(bld, self.data["cppflags"]),
             features="c",
-            includes=bic.includes + self.data["includes"],
+            includes=bic.includes + self.substitute(bld, 
self.data["includes"]),
             rule="${CC} ${CFLAGS} ${CPPFLAGS} ${DEFINES_ST:DEFINES} 
${CPPPATH_ST:INCPATHS} -c ${SRC[0]} -o ${TGT}",
             source=[source] + deps,
             target=target,
@@ -299,10 +301,10 @@ class Item(object):
         if target is None:
             target = os.path.splitext(source)[0] + ".o"
         bld(
-            cppflags=cppflags + self.data["cppflags"],
-            cxxflags=self.data["cxxflags"],
+            cppflags=cppflags + self.substitute(bld, self.data["cppflags"]),
+            cxxflags=self.substitute(bld, self.data["cxxflags"]),
             features="cxx",
-            includes=bic.includes + self.data["includes"],
+            includes=bic.includes + self.substitute(bld, 
self.data["includes"]),
             rule="${CXX} ${CXXFLAGS} ${CPPFLAGS} ${DEFINES_ST:DEFINES} 
${CPPPATH_ST:INCPATHS} -c ${SRC[0]} -o ${TGT}",
             source=[source] + deps,
             target=target,
@@ -574,11 +576,11 @@ class ObjectsItem(Item):
 
     def do_build(self, bld, bic):
         bld.objects(
-            asflags=self.data["cppflags"],
-            cflags=self.data["cflags"],
-            cppflags=self.data["cppflags"],
-            cxxflags=self.data["cxxflags"],
-            includes=bic.includes + self.data["includes"],
+            asflags=self.substitute(bld, self.data["cppflags"]),
+            cflags=self.substitute(bld, self.data["cflags"]),
+            cppflags=self.substitute(bld, self.data["cppflags"]),
+            cxxflags=self.substitute(bld, self.data["cxxflags"]),
+            includes=bic.includes + self.substitute(bld, 
self.data["includes"]),
             source=self.data["source"],
             target=self.uid,
         )
@@ -599,10 +601,10 @@ class BSPItem(Item):
 
     def do_build(self, bld, bic):
         bld(
-            cflags=self.data["cflags"],
-            cppflags=self.data["cppflags"],
+            cflags=self.substitute(bld, self.data["cflags"]),
+            cppflags=self.substitute(bld, self.data["cppflags"]),
             features="c cstlib",
-            includes=bic.includes + self.data["includes"],
+            includes=bic.includes + self.substitute(bld, 
self.data["includes"]),
             install_path="${BSP_LIBDIR}",
             source=self.data["source"],
             target="rtemsbsp",
@@ -620,11 +622,11 @@ class LibraryItem(Item):
 
     def do_build(self, bld, bic):
         bld(
-            cflags=self.data["cflags"],
-            cppflags=self.data["cppflags"],
-            cxxflags=self.data["cxxflags"],
+            cflags=self.substitute(bld, self.data["cflags"]),
+            cppflags=self.substitute(bld, self.data["cppflags"]),
+            cxxflags=self.substitute(bld, self.data["cxxflags"]),
             features="c cxx cstlib",
-            includes=bic.includes + self.data["includes"],
+            includes=bic.includes + self.substitute(bld, 
self.data["includes"]),
             install_path=self.data["install-path"],
             source=self.data["source"],
             target=self.get(bld, "target"),
@@ -648,13 +650,13 @@ class TestProgramItem(Item):
 
     def do_build(self, bld, bic):
         bld(
-            cflags=self.data["cflags"],
-            cppflags=bld.env[self.cppflags] + self.data["cppflags"],
-            cxxflags=self.data["cxxflags"],
+            cflags=self.substitute(bld, self.data["cflags"]),
+            cppflags=bld.env[self.cppflags] + self.substitute(bld, 
self.data["cppflags"]),
+            cxxflags=self.substitute(bld, self.data["cxxflags"]),
             features=self.data["features"],
-            includes=bic.includes + self.data["includes"],
+            includes=bic.includes + self.substitute(bld, 
self.data["includes"]),
             install_path=None,
-            ldflags=bic.ldflags + self.data["ldflags"],
+            ldflags=bic.ldflags + self.substitute(bld, self.data["ldflags"]),
             source=self.data["source"],
             start_files=True,
             stlib=self.data["stlib"],
-- 
2.30.2

_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Reply via email to