[PATCH 01/12] build: Add more flags to BuildItemContext

Sebastian Huber sebastian.huber at embedded-brains.de
Wed Jun 29 06:30:37 UTC 2022


Add cppflags, cflags, and cxxflags to BuildItemContext.  This allows to
propagate the flags from parent items to child items.

Update #4670.
---
 wscript | 93 +++++++++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 70 insertions(+), 23 deletions(-)

diff --git a/wscript b/wscript
index 8ad0ed30b1..e6abdaa7b5 100755
--- a/wscript
+++ b/wscript
@@ -513,6 +513,9 @@ class GroupItem(Item):
     def prepare_build(self, bld, bic):
         return BuildItemContext(
             bic.includes + self.get_values(bld, "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.objects,
@@ -578,13 +581,24 @@ class ObjectsItem(Item):
     def __init__(self, uid, data):
         super(ObjectsItem, self).__init__(uid, data)
 
+    def prepare_build(self, bld, bic):
+        return BuildItemContext(
+            bic.includes + self.substitute(bld, self.data["includes"]),
+            bic.cppflags + self.substitute(bld, self.data["cppflags"]),
+            bic.cflags + self.substitute(bld, self.data["cflags"]),
+            bic.cxxflags + self.substitute(bld, self.data["cxxflags"]),
+            bic.use,
+            bic.ldflags,
+            bic.objects,
+        )
+
     def do_build(self, bld, bic):
         bld.objects(
-            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"]),
+            asflags=bic.cppflags,
+            cflags=bic.cflags,
+            cppflags=bic.cppflags,
+            cxxflags=bic.cxxflags,
+            includes=bic.includes,
             source=self.data["source"],
             target=self.uid,
         )
@@ -600,15 +614,23 @@ class BSPItem(Item):
 
     def prepare_build(self, bld, bic):
         return BuildItemContext(
-            bic.includes + bld.env.BSP_INCLUDES.split(), [], [], []
+            bic.includes
+            + bld.env.BSP_INCLUDES.split()
+            + self.substitute(bld, self.data["includes"]),
+            self.substitute(bld, self.data["cppflags"]),
+            self.substitute(bld, self.data["cflags"]),
+            [],
+            [],
+            [],
+            [],
         )
 
     def do_build(self, bld, bic):
         bld(
-            cflags=self.substitute(bld, self.data["cflags"]),
-            cppflags=self.substitute(bld, self.data["cppflags"]),
+            cflags=bic.cflags,
+            cppflags=bic.cppflags,
             features="c cstlib",
-            includes=bic.includes + self.substitute(bld, self.data["includes"]),
+            includes=bic.includes,
             install_path="${BSP_LIBDIR}",
             source=self.data["source"],
             target="rtemsbsp",
@@ -622,15 +644,23 @@ class LibraryItem(Item):
         super(LibraryItem, self).__init__(uid, data)
 
     def prepare_build(self, bld, bic):
-        return BuildItemContext(bic.includes, [], [], [])
+        return BuildItemContext(
+            bic.includes + self.substitute(bld, self.data["includes"]),
+            bic.cppflags + self.substitute(bld, self.data["cppflags"]),
+            bic.cflags + self.substitute(bld, self.data["cflags"]),
+            bic.cxxflags + self.substitute(bld, self.data["cxxflags"]),
+            bic.use,
+            bic.ldflags,
+            [],
+        )
 
     def do_build(self, bld, bic):
         bld(
-            cflags=self.substitute(bld, self.data["cflags"]),
-            cppflags=self.substitute(bld, self.data["cppflags"]),
-            cxxflags=self.substitute(bld, self.data["cxxflags"]),
+            cflags=bic.cflags,
+            cppflags=bic.cppflags,
+            cxxflags=bic.cxxflags,
             features="c cxx cstlib",
-            includes=bic.includes + self.substitute(bld, self.data["includes"]),
+            includes=bic.includes,
             install_path=self.data["install-path"],
             source=self.data["source"],
             target=self.get(bld, "target"),
@@ -650,22 +680,32 @@ class TestProgramItem(Item):
         return [{"and": [{"not": self.exclude}, self.data["enabled-by"]]}]
 
     def prepare_build(self, bld, bic):
-        return BuildItemContext(bic.includes, bic.use, bic.ldflags, [])
+        return BuildItemContext(
+            bic.includes + self.substitute(bld, self.data["includes"]),
+            bic.cppflags
+            + bld.env[self.cppflags]
+            + self.substitute(bld, self.data["cppflags"]),
+            bic.cflags + self.substitute(bld, self.data["cflags"]),
+            bic.cxxflags + self.substitute(bld, self.data["cxxflags"]),
+            self.data["use-before"] + bic.use + self.data["use-after"],
+            bic.ldflags + self.substitute(bld, self.data["ldflags"]),
+            [],
+        )
 
     def do_build(self, bld, bic):
         bld(
-            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"]),
+            cflags=bic.cflags,
+            cppflags=bic.cppflags,
+            cxxflags=bic.cxxflags,
             features=self.data["features"],
-            includes=bic.includes + self.substitute(bld, self.data["includes"]),
+            includes=bic.includes,
             install_path=None,
-            ldflags=bic.ldflags + self.substitute(bld, self.data["ldflags"]),
+            ldflags=bic.ldflags,
             source=self.data["source"],
             start_files=True,
             stlib=self.data["stlib"],
             target=self.get(bld, "target"),
-            use=bic.objects + self.data["use-before"] + bic.use + self.data["use-after"],
+            use=bic.objects + bic.use,
         )
 
 
@@ -1105,8 +1145,13 @@ class ConfigItemContext(object):
 
 
 class BuildItemContext(object):
-    def __init__(self, includes, use, ldflags, objects):
+    def __init__(
+        self, includes, cppflags, cflags, cxxflags, use, ldflags, objects
+    ):
         self.includes = includes
+        self.cppflags = cppflags
+        self.cflags = cflags
+        self.cxxflags = cxxflags
         self.use = use
         self.ldflags = ldflags
         self.objects = objects
@@ -1555,7 +1600,9 @@ def build(bld):
         append_variant_builds(bld)
         return
     long_command_line_workaround(bld)
-    bic = BuildItemContext(bld.env.ARCH_INCLUDES.split(), [], [], [])
+    bic = BuildItemContext(
+        bld.env.ARCH_INCLUDES.split(), [], [], [], [], [], []
+    )
     bsps[bld.env.ARCH][bld.env.BSP_BASE].build(bld, bic)
     items[bld.env.TOPGROUP].build(bld, bic)
 
-- 
2.35.3



More information about the devel mailing list