[rtems-lwip commit] wscript: Build a header instead of using -D

Joel Sherrill joel at rtems.org
Thu Mar 30 13:14:21 UTC 2023


Module:    rtems-lwip
Branch:    master
Commit:    8689e18979015df7329da85f9ee820e439b09973
Changeset: http://git.rtems.org/rtems-lwip/commit/?id=8689e18979015df7329da85f9ee820e439b09973

Author:    Kinsey Moore <kinsey.moore at oarcorp.com>
Date:      Mon Mar 27 10:26:20 2023 -0500

wscript: Build a header instead of using -D

This change moves the use of items configured in config.ini from using
-D to set defines on the command line to using a header built by waf.
This also resolves an issue where configuration parameters were bleeding
between BSPs when multiple BSPs were configured.

---

 rtemslwip/include/lwipopts.h |  2 ++
 wscript                      | 19 ++++++++++++++++---
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/rtemslwip/include/lwipopts.h b/rtemslwip/include/lwipopts.h
index 157cce8..27e2c91 100644
--- a/rtemslwip/include/lwipopts.h
+++ b/rtemslwip/include/lwipopts.h
@@ -27,6 +27,8 @@
 #ifndef __LWIPOPTS_H__
 #define __LWIPOPTS_H__
 
+#include <lwipconfig.h>
+
 /* Critical items that all BSPs must use for full functionality */
 #define SYS_LIGHTWEIGHT_PROT 1
 #define NO_SYS 0
diff --git a/wscript b/wscript
index f1b919e..59bf81d 100644
--- a/wscript
+++ b/wscript
@@ -91,15 +91,23 @@ def get_configured_bsp_options(cp, arch, bsp):
     return options
 
 
+bsp_opts_target = os.path.join("rtemslwip", "include", "lwipconfig.h")
+
+
 def bsp_configure(conf, arch_bsp):
     cp = get_config()
     arch = rtems.arch(arch_bsp)
     bsp = rtems.bsp(arch_bsp)
     config_options = get_configured_bsp_options(cp, arch, bsp)
     for key, val in config_options.items():
-        flag = "-D"+key+"="+val
-        conf.env.CFLAGS.append(flag)
-        conf.env.CXXFLAGS.append(flag)
+        conf.define(key, val, quote=False)
+    conf.env.include_key = []
+    conf.write_config_header(
+        os.path.join(arch_bsp, bsp_opts_target),
+        guard="CONFIGURED_LWIP_BSP_OPTS_H",
+        top=True
+    )
+    conf.env.include_key = None
     lwip.bsp_configure(conf, arch_bsp)
 
 
@@ -112,4 +120,9 @@ def configure(conf):
 
 def build(bld):
     rtems.build(bld)
+    arch_bsp = bld.env.RTEMS_ARCH_BSP
+    arch = rtems._arch_from_arch_bsp(arch_bsp)
+    bsp = rtems.bsp(arch_bsp)
+    install_target = os.path.join(bld.env.PREFIX, arch, bsp, "lib", "include")
+    bld.install_files(install_target, bsp_opts_target)
     lwip.build(bld)



More information about the vc mailing list