waf: Add the ability to set FreeBSD options on the configure command line.

Add --freebsd-options to add specific FreeBSD compile time options to
the build. This is a developer tool.
This commit is contained in:
Chris Johns 2016-04-23 17:37:27 +10:00
parent 051ef305f7
commit e1e10cddee
6 changed files with 86 additions and 41 deletions

View File

@ -106,7 +106,6 @@ Steps
one time with different tool sets or configurations you can easly move
between them safe in the knowledge that one build will not infect another.
Updating RTEMS Waf Support
~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -136,3 +135,22 @@ versions:
$ git pull
$ cd ..
$ git commit -m "Update rtems_waf" rtems_waf
FreeBSD Developer Support
~~~~~~~~~~~~~~~~~~~~~~~~~
The --freebsd-option provides a tool you can set special kernel options. This
is a developer tool and should only be used if you are familiar with the
internals of the FreeBSD kernel and what these options do.
The options are listed in:
https://github.com/freebsd/freebsd/blob/master/sys/conf/NOTES
An example to turn on a verbose kernel boot, verbose sysinit and bus debugging
configure with:
--freebsd-options=bootverbose,verbose_sysinit,bus_debug
The LibBSD waf support splits the options and converts them to uppercase and
adds them -D options on the compiler command line.

View File

@ -161,6 +161,11 @@ sysinit_add(struct sysinit **set, struct sysinit **set_end)
newsysinit_end = newset + count;
}
#else /* __rtems__ */
#ifdef BOOTVERBOSE
int bootverbose = 1;
SYSCTL_INT(_debug, OID_AUTO, bootverbose, CTLFLAG_RW, &bootverbose, 0,
"Control the output of verbose kernel messages");
#endif
RWSET_DECLARE(sysinit_set, struct sysinit);
#endif /* __rtems__ */

View File

@ -73,7 +73,11 @@ extern int boothowto; /* reboot flags, from console subsystem */
#ifndef __rtems__
extern int bootverbose; /* nonzero to print verbose messages */
#else /* __rtems__ */
#define bootverbose 0 /* XXX RTEMS doesn't support verbose */
#ifdef BOOTVERBOSE
extern int bootverbose; /* nonzero to print verbose messages */
#else
#define bootverbose 0 /* Remove all verbose code for the standard RTEMS build */
#endif /* BOOTVERBOSE */
#endif /* __rtems__ */

View File

@ -39,6 +39,11 @@ def build(bld):
cflags = ['-std=gnu11'] + common_flags
cxxflags = ['-std=gnu++11'] + common_flags
# Defines
defines = []
for o in bld.env.FREEBSD_OPTIONS.split(","):
defines += ["%s=1" % (o.strip().upper())]
# Include paths
includes = []
for i in ['-Irtemsbsd/@CPU@/include', '-Ifreebsd/sys/@CPU@/include']:
@ -135,18 +140,6 @@ def build(bld):
rule = rkw_rule)
# Lex
if bld.env.AUTO_REGEN:
bld(target = "freebsd/lib/libc/net/nslexer.c",
source = "freebsd/lib/libc/net/nslexer.l",
rule = "${LEX} -P _nsyy -t ${SRC} | sed -e '/YY_BUF_SIZE/s/16384/1024/' > ${TGT}")
bld.objects(target = "lex__nsyy",
features = "c",
cflags = cflags,
includes = [] + includes,
defines = [],
source = "freebsd/lib/libc/net/nslexer.c")
libbsd_use += ["lex__nsyy"]
if bld.env.AUTO_REGEN:
bld(target = "freebsd/contrib/libpcap/scanner.c",
source = "freebsd/contrib/libpcap/scanner.l",
@ -155,10 +148,22 @@ def build(bld):
features = "c",
cflags = cflags,
includes = [] + includes,
defines = ['__FreeBSD__=1', 'BSD=1', 'INET6', '_U_=__attribute__((unused))', 'HAVE_LIMITS_H=1', 'HAVE_INTTYPES=1', 'HAVE_STDINT=1', 'HAVE_STRERROR=1', 'HAVE_STRLCPY=1', 'HAVE_SNPRINTF=1', 'HAVE_VSNPRINTF=1', 'HAVE_SOCKADDR_SA_LEN=1', 'HAVE_NET_IF_MEDIA_H=1', 'HAVE_SYS_IOCCOM_H=1', 'NEED_YYPARSE_WRAPPER=1', 'yylval=pcap_lval'],
defines = defines + ['__FreeBSD__=1', 'BSD=1', 'INET6', '_U_=__attribute__((unused))', 'HAVE_LIMITS_H=1', 'HAVE_INTTYPES=1', 'HAVE_STDINT=1', 'HAVE_STRERROR=1', 'HAVE_STRLCPY=1', 'HAVE_SNPRINTF=1', 'HAVE_VSNPRINTF=1', 'HAVE_SOCKADDR_SA_LEN=1', 'HAVE_NET_IF_MEDIA_H=1', 'HAVE_SYS_IOCCOM_H=1', 'NEED_YYPARSE_WRAPPER=1', 'yylval=pcap_lval'],
source = "freebsd/contrib/libpcap/scanner.c")
libbsd_use += ["lex_pcap"]
if bld.env.AUTO_REGEN:
bld(target = "freebsd/lib/libc/net/nslexer.c",
source = "freebsd/lib/libc/net/nslexer.l",
rule = "${LEX} -P _nsyy -t ${SRC} | sed -e '/YY_BUF_SIZE/s/16384/1024/' > ${TGT}")
bld.objects(target = "lex__nsyy",
features = "c",
cflags = cflags,
includes = [] + includes,
defines = defines + [],
source = "freebsd/lib/libc/net/nslexer.c")
libbsd_use += ["lex__nsyy"]
if bld.env.AUTO_REGEN:
bld(target = "freebsd/lib/libipsec/policy_token.c",
source = "freebsd/lib/libipsec/policy_token.l",
@ -167,7 +172,7 @@ def build(bld):
features = "c",
cflags = cflags,
includes = [] + includes,
defines = [],
defines = defines + [],
source = "freebsd/lib/libipsec/policy_token.c")
libbsd_use += ["lex___libipsecyy"]
@ -180,20 +185,9 @@ def build(bld):
features = "c",
cflags = cflags,
includes = [] + includes,
defines = ['__FreeBSD__=1', 'BSD=1', 'INET6', '_U_=__attribute__((unused))', 'HAVE_LIMITS_H=1', 'HAVE_INTTYPES=1', 'HAVE_STDINT=1', 'HAVE_STRERROR=1', 'HAVE_STRLCPY=1', 'HAVE_SNPRINTF=1', 'HAVE_VSNPRINTF=1', 'HAVE_SOCKADDR_SA_LEN=1', 'HAVE_NET_IF_MEDIA_H=1', 'HAVE_SYS_IOCCOM_H=1', 'NEED_YYPARSE_WRAPPER=1', 'yylval=pcap_lval'],
defines = defines + ['__FreeBSD__=1', 'BSD=1', 'INET6', '_U_=__attribute__((unused))', 'HAVE_LIMITS_H=1', 'HAVE_INTTYPES=1', 'HAVE_STDINT=1', 'HAVE_STRERROR=1', 'HAVE_STRLCPY=1', 'HAVE_SNPRINTF=1', 'HAVE_VSNPRINTF=1', 'HAVE_SOCKADDR_SA_LEN=1', 'HAVE_NET_IF_MEDIA_H=1', 'HAVE_SYS_IOCCOM_H=1', 'NEED_YYPARSE_WRAPPER=1', 'yylval=pcap_lval'],
source = "freebsd/contrib/libpcap/grammar.c")
libbsd_use += ["yacc_pcap"]
if bld.env.AUTO_REGEN:
bld(target = "freebsd/lib/libipsec/policy_parse.c",
source = "freebsd/lib/libipsec/policy_parse.y",
rule = "${YACC} -b __libipsecyy -d -p __libipsecyy ${SRC} && sed -e '/YY_BUF_SIZE/s/16384/1024/' < __libipsecyy.tab.c > ${TGT} && rm -f __libipsecyy.tab.c && mv __libipsecyy.tab.h freebsd/lib/libipsec/y.tab.h")
bld.objects(target = "yacc___libipsecyy",
features = "c",
cflags = cflags,
includes = [] + includes,
defines = [],
source = "freebsd/lib/libipsec/policy_parse.c")
libbsd_use += ["yacc___libipsecyy"]
if bld.env.AUTO_REGEN:
bld(target = "freebsd/lib/libc/net/nsparser.c",
source = "freebsd/lib/libc/net/nsparser.y",
@ -202,9 +196,20 @@ def build(bld):
features = "c",
cflags = cflags,
includes = [] + includes,
defines = [],
defines = defines + [],
source = "freebsd/lib/libc/net/nsparser.c")
libbsd_use += ["yacc__nsyy"]
if bld.env.AUTO_REGEN:
bld(target = "freebsd/lib/libipsec/policy_parse.c",
source = "freebsd/lib/libipsec/policy_parse.y",
rule = "${YACC} -b __libipsecyy -d -p __libipsecyy ${SRC} && sed -e '/YY_BUF_SIZE/s/16384/1024/' < __libipsecyy.tab.c > ${TGT} && rm -f __libipsecyy.tab.c && mv __libipsecyy.tab.h freebsd/lib/libipsec/y.tab.h")
bld.objects(target = "yacc___libipsecyy",
features = "c",
cflags = cflags,
includes = [] + includes,
defines = defines + [],
source = "freebsd/lib/libipsec/policy_parse.c")
libbsd_use += ["yacc___libipsecyy"]
# Objects built with different CFLAGS
objs01_source = ['freebsd/bin/hostname/hostname.c',
@ -349,7 +354,7 @@ def build(bld):
features = "c",
cflags = cflags,
includes = [] + includes,
defines = ['INET6'],
defines = defines + ['INET6'],
source = objs01_source)
libbsd_use += ["objs01"]
@ -358,7 +363,7 @@ def build(bld):
features = "c",
cflags = cflags,
includes = [] + includes,
defines = ['NO_SSL', 'NO_POPEN', 'NO_CGI', 'USE_WEBSOCKET'],
defines = defines + ['NO_SSL', 'NO_POPEN', 'NO_CGI', 'USE_WEBSOCKET'],
source = objs02_source)
libbsd_use += ["objs02"]
@ -390,7 +395,7 @@ def build(bld):
features = "c",
cflags = cflags,
includes = [] + includes,
defines = ['__DBINTERFACE_PRIVATE', 'INET6'],
defines = defines + ['__DBINTERFACE_PRIVATE', 'INET6'],
source = objs03_source)
libbsd_use += ["objs03"]
@ -420,7 +425,7 @@ def build(bld):
features = "c",
cflags = cflags,
includes = [] + includes,
defines = ['__FreeBSD__', 'THERE_IS_NO_FORK', 'MASTER_ONLY', 'INET', 'INET6'],
defines = defines + ['__FreeBSD__', 'THERE_IS_NO_FORK', 'MASTER_ONLY', 'INET', 'INET6'],
source = objs04_source)
libbsd_use += ["objs04"]
@ -441,7 +446,7 @@ def build(bld):
features = "c",
cflags = cflags,
includes = [] + includes,
defines = ['__FreeBSD__=1', 'BSD=1', 'INET6', '_U_=__attribute__((unused))', 'HAVE_LIMITS_H=1', 'HAVE_INTTYPES=1', 'HAVE_STDINT=1', 'HAVE_STRERROR=1', 'HAVE_STRLCPY=1', 'HAVE_SNPRINTF=1', 'HAVE_VSNPRINTF=1', 'HAVE_SOCKADDR_SA_LEN=1', 'HAVE_NET_IF_MEDIA_H=1', 'HAVE_SYS_IOCCOM_H=1'],
defines = defines + ['__FreeBSD__=1', 'BSD=1', 'INET6', '_U_=__attribute__((unused))', 'HAVE_LIMITS_H=1', 'HAVE_INTTYPES=1', 'HAVE_STDINT=1', 'HAVE_STRERROR=1', 'HAVE_STRLCPY=1', 'HAVE_SNPRINTF=1', 'HAVE_VSNPRINTF=1', 'HAVE_SOCKADDR_SA_LEN=1', 'HAVE_NET_IF_MEDIA_H=1', 'HAVE_SYS_IOCCOM_H=1'],
source = objs05_source)
libbsd_use += ["objs05"]
@ -592,7 +597,7 @@ def build(bld):
features = "c",
cflags = cflags,
includes = ['freebsd/contrib/tcpdump', 'freebsd/usr.sbin/tcpdump/tcpdump'] + includes,
defines = ['__FreeBSD__=1', 'INET6', '_U_=__attribute__((unused))', 'HAVE_CONFIG_H=1', 'HAVE_NET_PFVAR_H=1'],
defines = defines + ['__FreeBSD__=1', 'INET6', '_U_=__attribute__((unused))', 'HAVE_CONFIG_H=1', 'HAVE_NET_PFVAR_H=1'],
source = objs06_source)
libbsd_use += ["objs06"]
@ -1066,6 +1071,7 @@ def build(bld):
cflags = cflags,
cxxflags = cxxflags,
includes = includes,
defines = defines,
source = source,
use = libbsd_use)

View File

@ -294,6 +294,11 @@ class ModuleManager(builder.ModuleManager):
self.add(' cflags = %r + common_flags' % (builder.cflags()))
self.add(' cxxflags = %r + common_flags' % (builder.cxxflags()))
self.add('')
self.add(' # Defines')
self.add(' defines = []')
self.add(' for o in bld.env.FREEBSD_OPTIONS.split(","):')
self.add(' defines += ["%s=1" % (o.strip().upper())]')
self.add('')
self.add(' # Include paths')
self.add(' includes = []')
self.add(' for i in %r:' % (builder.cpu_includes()))
@ -409,7 +414,7 @@ class ModuleManager(builder.ModuleManager):
if 'lex' in data:
lexes = data['lex']
self.add(' # Lex')
for l in lexes:
for l in sorted(lexes.keys()):
lex = lexes[l]['all']
if 'cflags' in lex:
lex_defines = [d[2:] for d in lex['cflags']]
@ -428,7 +433,7 @@ class ModuleManager(builder.ModuleManager):
self.add(' features = "c",')
self.add(' cflags = cflags,')
self.add(' includes = %r + includes,' % (lex_includes))
self.add(' defines = %r,' % (lex_defines))
self.add(' defines = defines + %r,' % (lex_defines))
self.add(' source = "%s.c")' % (lex['file'][:-2]))
self.add(' libbsd_use += ["lex_%s"]' % (lex['sym']))
self.add('')
@ -436,7 +441,7 @@ class ModuleManager(builder.ModuleManager):
if 'yacc' in data:
yaccs = data['yacc']
self.add(' # Yacc')
for y in yaccs:
for y in sorted(yaccs.keys()):
yacc = yaccs[y]['all']
yacc_file = yacc['file']
if yacc['sym'] is not None:
@ -462,7 +467,7 @@ class ModuleManager(builder.ModuleManager):
self.add(' features = "c",')
self.add(' cflags = cflags,')
self.add(' includes = %r + includes,' % (yacc_includes))
self.add(' defines = %r,' % (yacc_defines))
self.add(' defines = defines + %r,' % (yacc_defines))
self.add(' source = "%s.c")' % (yacc_file[:-2]))
self.add(' libbsd_use += ["yacc_%s"]' % (yacc_sym))
self.add('')
@ -496,7 +501,7 @@ class ModuleManager(builder.ModuleManager):
self.add(' features = "c",')
self.add(' cflags = cflags,')
self.add(' includes = %r + includes,' % (includes))
self.add(' defines = %r,' % (defines))
self.add(' defines = defines + %r,' % (defines))
self.add(' source = objs%02d_source)' % objs)
self.add(' libbsd_use += ["objs%02d"]' % (objs))
self.add('')
@ -518,6 +523,7 @@ class ModuleManager(builder.ModuleManager):
self.add(' cflags = cflags,')
self.add(' cxxflags = cxxflags,')
self.add(' includes = includes,')
self.add(' defines = defines,')
self.add(' source = source,')
self.add(' use = libbsd_use)')
self.add('')

View File

@ -63,6 +63,11 @@ def options(opt):
default = "config.inc",
dest = "net_config",
help = "Network test configuration.")
opt.add_option("--freebsd-options",
action = "store",
default = "",
dest = "freebsd_options",
help = "Set FreeBSD options (developer option).")
libbsd_waf.options(opt)
def bsp_configure(conf, arch_bsp):
@ -82,8 +87,9 @@ def configure(conf):
conf.env.AUTO_REGEN = conf.options.auto_regen
conf.env.WARNINGS = conf.options.warnings
conf.env.NET_CONFIG = conf.options.net_config
conf.env.FREEBSD_OPTIONS =conf.options.freebsd_options
rtems.configure(conf, bsp_configure)
libbsd_waf.configure(conf, arch_bsp)
libbsd_waf.configure(conf)
def build(bld):
rtems.build(bld)