summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2019-01-07 14:06:47 +1100
committerChris Johns <chrisj@rtems.org>2019-06-30 11:52:24 +1000
commit525fd1cb11f5180deea0b6ae862eef2ff99613cc (patch)
treebf5e873d91d0787ce26ea3791eb8e3edd58e349e
parentrootfs: Improve the support to build a tar file. (diff)
downloadrtems_waf-525fd1cb11f5180deea0b6ae862eef2ff99613cc.tar.bz2
rtems_bsd: Improve the support for libbsd.
1. Better support for the configure process. 2. Add support to handle a network config file.
-rw-r--r--rtems_bsd.py117
1 files changed, 95 insertions, 22 deletions
diff --git a/rtems_bsd.py b/rtems_bsd.py
index 13212de..f28ef1c 100644
--- a/rtems_bsd.py
+++ b/rtems_bsd.py
@@ -39,7 +39,7 @@ def init(ctx):
pass
def options(opt):
- opt.add_option('--net-test-config',
+ opt.add_option('--net-config',
default = 'config.inc',
dest = 'net_config',
help = 'Network test configuration.')
@@ -49,29 +49,102 @@ def options(opt):
dest = 'rtems_libbsd',
help = 'Path to install RTEMS LibBSD (defauls to prefix).')
-def bsp_configure(conf, arch_bsp):
- conf.check(header_name = 'dlfcn.h', features = 'c')
- if not rtems.check_posix(conf):
- conf.fatal("RTEMS kernel POSIX support is disabled; configure RTEMS with --enable-posix")
- if rtems.check_networking(conf):
- conf.fatal("RTEMS kernel contains the old network support; configure RTEMS with --disable-networking")
- if conf.options.rtems_libbsd is None:
- rtems_libbsd_path = conf.env.PREFIX
- else:
- if not os.path.exists(conf.options.rtems_libbsd):
- conf.fatal('RTEMS LibBSD not found')
+def bsp_configure(conf, arch_bsp, mandatory = True):
+ configure = mandatory
+
+ if not mandatory and conf.options.rtems_libbsd is not None:
+ configure = True
+
+ if configure:
+ conf.msg('RTEMS LibBSD',
+ rtems.arch(arch_bsp) + '/' + rtems.bsp(arch_bsp),
+ 'YELLOW')
+
+ conf.check(header_name = 'dlfcn.h', features = 'c')
+ if not rtems.check_posix(conf):
+ conf.fatal('RTEMS kernel POSIX support is disabled; ' +
+ 'configure RTEMS with --enable-posix')
+ if rtems.check_networking(conf):
+ conf.fatal('RTEMS kernel contains the old network support; ' +
+ 'configure RTEMS with --disable-networking')
rtems_libbsd_path = conf.options.rtems_libbsd
+ if rtems_libbsd_path is None:
+ if conf.options.rtems is None:
+ rtems_libbsd_path = conf.options.rtems
+ else:
+ rtems_libbsd_path = conf.env.PREFIX
+
+ if not os.path.exists(rtems_libbsd_path):
+ conf.fatal('RTEMS LibBSD path not found: %s' % (rtems_libbsd_path))
- rtems_libbsd_inc_path = os.path.join(rtems_libbsd_path,
- rtems.arch_bsp_include_path(conf.env.RTEMS_VERSION,
+ rtems_libbsd_inc_path = os.path.join(rtems_libbsd_path,
+ rtems.arch_bsp_include_path(conf.env.RTEMS_VERSION,
conf.env.RTEMS_ARCH_BSP))
- rtems_libbsd_lib_path = os.path.join(rtems_libbsd_path,
- rtems.arch_bsp_lib_path(conf.env.RTEMS_VERSION,
- conf.env.RTEMS_ARCH_BSP))
+ rtems_libbsd_lib_path = os.path.join(rtems_libbsd_path,
+ rtems.arch_bsp_lib_path(conf.env.RTEMS_VERSION,
+ conf.env.RTEMS_ARCH_BSP))
+
+ conf.env.IFLAGS += [rtems_libbsd_inc_path]
+ conf.check(header_name = 'machine/rtems-bsd-sysinit.h',
+ features = 'c',
+ includes = conf.env.IFLAGS)
+
+ conf.env.RTEMS_LIBBSD = 'Yes'
+ conf.env.INCLUDES = conf.env.IFLAGS
+ conf.env.LIBPATH += [rtems_libbsd_lib_path]
+ conf.env.LIB += ['bsd', 'z', 'm']
+
+ configure_net_config(conf, arch_bsp)
+
+def configure_net_config(conf, arch_bsp):
+ if check_libbsd(conf) and conf.options.net_config is not None:
+ net_config = conf.options.net_config
+
+ if not os.path.exists(net_config):
+ conf.fatal('network configuraiton \'%s\' not found' % (net_config))
+
+ try:
+ net_cfg_lines = open(net_config).readlines()
+ except:
+ conf.fatal('network configuraiton \'%s\' read failed' % (net_config))
+
+ tags = [ 'NET_CFG_SELF_IP',
+ 'NET_CFG_NETMASK',
+ 'NET_CFG_PEER_IP',
+ 'NET_CFG_GATEWAY_IP' ]
+
+ lc = 0
+ sed = 'sed '
+ defines = []
+ for l in net_cfg_lines:
+ lc += 1
+ if l.strip().startswith('NET_CFG_'):
+ ls = l.split('=')
+ if len(ls) != 2:
+ conf.fatal('network configuraiton \'%s\' ' + \
+ 'parse error: %d: %s' % (net_config, lc, l))
+ lhs = ls[0].strip()
+ rhs = ls[1].strip()
+ for t in tags:
+ if lhs.startswith(t):
+ conf.env[lhs] = rhs
+ sed += "-e 's/@%s@/%s/'" % (lhs, rhs)
+ defines += ['%s="%s"' % (lhs, rhs)]
+
+ conf.env.NET_CONFIG = net_config
+ conf.env.NET_CONFIG_SED = sed
+ conf.env.NET_CONFIG_DEFINES = ','.join(defines)
+
+ conf.msg('Net Config', 'found', 'YELLOW')
+
+def check_libbsd(ctx):
+ return rtems.check(ctx, 'RTEMS_LIBBSD')
- conf.env.IFLAGS += [rtems_libbsd_inc_path]
- conf.check(header_name = 'machine/rtems-bsd-sysinit.h', features = 'c', includes = conf.env.IFLAGS)
+def check_net_config(ctx):
+ return rtems.check(ctx, 'NET_CONFIG', setting = True)
- conf.env.INCLUDES = conf.env.IFLAGS
- conf.env.LIBPATH += [rtems_libbsd_lib_path]
- conf.env.LIB += ['bsd', 'z', 'm']
+def net_config_header(ctx, target):
+ ctx(target = target,
+ source = "rtems_waf/network-config.h.in",
+ rule = sed + " < ${SRC} > ${TGT}",
+ update_outputs = True)