[PATCH rtems-lwip] wscript: Allow deeper lwIP configuration
Kinsey Moore
kinsey.moore at oarcorp.com
Fri Nov 11 22:03:09 UTC 2022
This adds a basic configuration mechanism in config.ini to control which
BSPs are enabled and to alter lwIP's define/macro-based configuration
directives. Existing builds using --rtems-bsps are unaffected if
config.ini is not used.
---
README | 14 ++++++++++++++
wscript | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 73 insertions(+), 1 deletion(-)
diff --git a/README b/README
index 99800bf..a8cbc21 100644
--- a/README
+++ b/README
@@ -30,3 +30,17 @@ git submodule update
More `waf` arguments can be found by using:
`./waf --help`
+
+Further Build Information
+-------------------------
+
+The BSPs configured to build may be specified on the waf configure command line
+with --rtems-bsps or they may be configured in config.ini as in RTEMS. The
+command line option will override the BSPs configured in config.ini, but options
+in config.ini will still be applied for enabled BSPs. Any additional
+configuration options desired in lwipopts.h may be specified in config.ini under
+the appropriate section as key/value pairs like so:
+
+[aarch64/xilinx_zynqmp_lp64_zu3eg]
+LWIP_IGMP=1
+ZYNQMP_USE_SGMII=1
diff --git a/wscript b/wscript
index 1546a3d..f1b919e 100644
--- a/wscript
+++ b/wscript
@@ -1,3 +1,5 @@
+#!/usr/bin/env python
+
#
# RTEMS Project (https://www.rtems.org/)
#
@@ -28,7 +30,13 @@
from __future__ import print_function
from rtems_waf import rtems
+try:
+ import configparser
+except:
+ import ConfigParser as configparser
+
import lwip
+import os
import sys
top = '.'
@@ -48,8 +56,58 @@ def options(opt):
rtems.options(opt)
+def no_unicode(value):
+ if sys.version_info[0] > 2:
+ return value
+ if isinstance(value, unicode):
+ return str(value)
+ return value
+
+
+def get_config():
+ cp = configparser.ConfigParser()
+ filename = "config.ini"
+ if filename not in cp.read([filename]):
+ return None
+ return cp
+
+
+def get_configured_bsps(cp):
+ if not cp:
+ return "all"
+ bsps = []
+ for raw_bsp in cp.sections():
+ bsps.append(no_unicode(raw_bsp))
+ return ",".join(bsps)
+
+
+def get_configured_bsp_options(cp, arch, bsp):
+ if not cp:
+ return {}
+ options = {}
+ for config_option in cp.items(os.path.join(arch, bsp)):
+ opt_name = config_option[0].upper()
+ options[opt_name] = config_option[1]
+ return options
+
+
+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)
+ lwip.bsp_configure(conf, arch_bsp)
+
+
def configure(conf):
- rtems.configure(conf, lwip.bsp_configure)
+ cp = get_config()
+ if conf.options.rtems_bsps == "all":
+ conf.options.rtems_bsps = get_configured_bsps(cp)
+ rtems.configure(conf, bsp_configure)
def build(bld):
--
2.30.2
More information about the devel
mailing list