[PATCH v1 2/2] wscript: Allow substitution outside values
Kinsey Moore
kinsey.moore at oarcorp.com
Tue Apr 12 18:55:31 UTC 2022
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 | 52 ++++++++++++++++++++++++++--------------------------
1 file changed, 26 insertions(+), 26 deletions(-)
diff --git a/wscript b/wscript
index 9de9d67b91..e2fc047ea8 100755
--- a/wscript
+++ b/wscript
@@ -276,10 +276,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, asflag) for asflag in self.data["asflags"]],
+ cppflags=[self.substitute(bld, cppflag) for cppflag in self.data["cppflags"]],
features="asm_explicit_target asm c",
- includes=bic.includes + self.data["includes"],
+ includes=bic.includes + [self.substitute(bld, inc) for inc in self.data["includes"]],
source=[source],
target=target,
)
@@ -289,10 +289,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, cflag) for cflag in self.data["cflags"]],
+ cppflags=cppflags + [self.substitute(bld, cppflag) for cppflag in self.data["cppflags"]],
features="c",
- includes=bic.includes + self.data["includes"],
+ includes=bic.includes + [self.substitute(bld, inc) for inc in self.data["includes"]],
rule="${CC} ${CFLAGS} ${CPPFLAGS} ${DEFINES_ST:DEFINES} ${CPPPATH_ST:INCPATHS} -c ${SRC[0]} -o ${TGT}",
source=[source] + deps,
target=target,
@@ -303,10 +303,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, cppflag) for cppflag in self.data["cppflags"]],
+ cxxflags=[self.substitute(bld, cxxflag) for cxxflag in self.data["cxxflags"]],
features="cxx",
- includes=bic.includes + self.data["includes"],
+ includes=bic.includes + [self.substitute(bld, inc) for inc in self.data["includes"]],
rule="${CXX} ${CXXFLAGS} ${CPPFLAGS} ${DEFINES_ST:DEFINES} ${CPPPATH_ST:INCPATHS} -c ${SRC[0]} -o ${TGT}",
source=[source] + deps,
target=target,
@@ -578,11 +578,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, cppflag) for cppflag in self.data["cppflags"]],
+ cflags=[self.substitute(bld, cflag) for cflag in self.data["cflags"]],
+ cppflags=[self.substitute(bld, cppflag) for cppflag in self.data["cppflags"]],
+ cxxflags=[self.substitute(bld, cxxflag) for cxxflag in self.data["cxxflags"]],
+ includes=bic.includes + [self.substitute(bld, inc) for inc in self.data["includes"]],
source=self.data["source"],
target=self.uid,
)
@@ -603,10 +603,10 @@ class BSPItem(Item):
def do_build(self, bld, bic):
bld(
- cflags=self.data["cflags"],
- cppflags=self.data["cppflags"],
+ cflags=[self.substitute(bld, cflag) for cflag in self.data["cflags"]],
+ cppflags=[self.substitute(bld, cppflag) for cppflag in self.data["cppflags"]],
features="c cstlib",
- includes=bic.includes + self.data["includes"],
+ includes=bic.includes + [self.substitute(bld, inc) for inc in self.data["includes"]],
install_path="${BSP_LIBDIR}",
source=self.data["source"],
target="rtemsbsp",
@@ -624,11 +624,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, cflag) for cflag in self.data["cflags"]],
+ cppflags=[self.substitute(bld, cppflag) for cppflag in self.data["cppflags"]],
+ cxxflags=[self.substitute(bld, cxxflag) for cxxflag in self.data["cxxflags"]],
features="c cxx cstlib",
- includes=bic.includes + self.data["includes"],
+ includes=bic.includes + [self.substitute(bld, inc) for inc in self.data["includes"]],
install_path=self.data["install-path"],
source=self.data["source"],
target=self.get(bld, "target"),
@@ -652,13 +652,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, cflag) for cflag in self.data["cflags"]],
+ cppflags=bld.env[self.cppflags] + [self.substitute(bld, cppflag) for cppflag in self.data["cppflags"]],
+ cxxflags=[self.substitute(bld, cxxflag) for cxxflag in self.data["cxxflags"]],
features=self.data["features"],
- includes=bic.includes + self.data["includes"],
+ includes=bic.includes + [self.substitute(bld, inc) for inc in self.data["includes"]],
install_path=None,
- ldflags=bic.ldflags + self.data["ldflags"],
+ ldflags=bic.ldflags + [self.substitute(bld, ldflag) for ldflag in self.data["ldflags"]],
source=self.data["source"],
start_files=True,
stlib=self.data["stlib"],
--
2.30.2
More information about the devel
mailing list