From 857fb17db1c467ce72fd4a6e410a653b26e31c34 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 27 Jun 2022 10:51:08 +0200 Subject: build: Add more flags to BuildItemContext 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(-) (limited to 'wscript') 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) -- cgit v1.2.3