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 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. between them safe in the knowledge that one build will not infect another.
Updating RTEMS Waf Support Updating RTEMS Waf Support
~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -136,3 +135,22 @@ versions:
$ git pull $ git pull
$ cd .. $ cd ..
$ git commit -m "Update rtems_waf" rtems_waf $ 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; newsysinit_end = newset + count;
} }
#else /* __rtems__ */ #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); RWSET_DECLARE(sysinit_set, struct sysinit);
#endif /* __rtems__ */ #endif /* __rtems__ */

View File

@ -73,7 +73,11 @@ extern int boothowto; /* reboot flags, from console subsystem */
#ifndef __rtems__ #ifndef __rtems__
extern int bootverbose; /* nonzero to print verbose messages */ extern int bootverbose; /* nonzero to print verbose messages */
#else /* __rtems__ */ #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__ */ #endif /* __rtems__ */

View File

@ -39,6 +39,11 @@ def build(bld):
cflags = ['-std=gnu11'] + common_flags cflags = ['-std=gnu11'] + common_flags
cxxflags = ['-std=gnu++11'] + 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 # Include paths
includes = [] includes = []
for i in ['-Irtemsbsd/@CPU@/include', '-Ifreebsd/sys/@CPU@/include']: for i in ['-Irtemsbsd/@CPU@/include', '-Ifreebsd/sys/@CPU@/include']:
@ -135,18 +140,6 @@ def build(bld):
rule = rkw_rule) rule = rkw_rule)
# Lex # 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: if bld.env.AUTO_REGEN:
bld(target = "freebsd/contrib/libpcap/scanner.c", bld(target = "freebsd/contrib/libpcap/scanner.c",
source = "freebsd/contrib/libpcap/scanner.l", source = "freebsd/contrib/libpcap/scanner.l",
@ -155,10 +148,22 @@ def build(bld):
features = "c", features = "c",
cflags = cflags, cflags = cflags,
includes = [] + includes, 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") source = "freebsd/contrib/libpcap/scanner.c")
libbsd_use += ["lex_pcap"] 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: if bld.env.AUTO_REGEN:
bld(target = "freebsd/lib/libipsec/policy_token.c", bld(target = "freebsd/lib/libipsec/policy_token.c",
source = "freebsd/lib/libipsec/policy_token.l", source = "freebsd/lib/libipsec/policy_token.l",
@ -167,7 +172,7 @@ def build(bld):
features = "c", features = "c",
cflags = cflags, cflags = cflags,
includes = [] + includes, includes = [] + includes,
defines = [], defines = defines + [],
source = "freebsd/lib/libipsec/policy_token.c") source = "freebsd/lib/libipsec/policy_token.c")
libbsd_use += ["lex___libipsecyy"] libbsd_use += ["lex___libipsecyy"]
@ -180,20 +185,9 @@ def build(bld):
features = "c", features = "c",
cflags = cflags, cflags = cflags,
includes = [] + includes, 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") source = "freebsd/contrib/libpcap/grammar.c")
libbsd_use += ["yacc_pcap"] 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: if bld.env.AUTO_REGEN:
bld(target = "freebsd/lib/libc/net/nsparser.c", bld(target = "freebsd/lib/libc/net/nsparser.c",
source = "freebsd/lib/libc/net/nsparser.y", source = "freebsd/lib/libc/net/nsparser.y",
@ -202,9 +196,20 @@ def build(bld):
features = "c", features = "c",
cflags = cflags, cflags = cflags,
includes = [] + includes, includes = [] + includes,
defines = [], defines = defines + [],
source = "freebsd/lib/libc/net/nsparser.c") source = "freebsd/lib/libc/net/nsparser.c")
libbsd_use += ["yacc__nsyy"] 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 # Objects built with different CFLAGS
objs01_source = ['freebsd/bin/hostname/hostname.c', objs01_source = ['freebsd/bin/hostname/hostname.c',
@ -349,7 +354,7 @@ def build(bld):
features = "c", features = "c",
cflags = cflags, cflags = cflags,
includes = [] + includes, includes = [] + includes,
defines = ['INET6'], defines = defines + ['INET6'],
source = objs01_source) source = objs01_source)
libbsd_use += ["objs01"] libbsd_use += ["objs01"]
@ -358,7 +363,7 @@ def build(bld):
features = "c", features = "c",
cflags = cflags, cflags = cflags,
includes = [] + includes, includes = [] + includes,
defines = ['NO_SSL', 'NO_POPEN', 'NO_CGI', 'USE_WEBSOCKET'], defines = defines + ['NO_SSL', 'NO_POPEN', 'NO_CGI', 'USE_WEBSOCKET'],
source = objs02_source) source = objs02_source)
libbsd_use += ["objs02"] libbsd_use += ["objs02"]
@ -390,7 +395,7 @@ def build(bld):
features = "c", features = "c",
cflags = cflags, cflags = cflags,
includes = [] + includes, includes = [] + includes,
defines = ['__DBINTERFACE_PRIVATE', 'INET6'], defines = defines + ['__DBINTERFACE_PRIVATE', 'INET6'],
source = objs03_source) source = objs03_source)
libbsd_use += ["objs03"] libbsd_use += ["objs03"]
@ -420,7 +425,7 @@ def build(bld):
features = "c", features = "c",
cflags = cflags, cflags = cflags,
includes = [] + includes, 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) source = objs04_source)
libbsd_use += ["objs04"] libbsd_use += ["objs04"]
@ -441,7 +446,7 @@ def build(bld):
features = "c", features = "c",
cflags = cflags, cflags = cflags,
includes = [] + includes, 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) source = objs05_source)
libbsd_use += ["objs05"] libbsd_use += ["objs05"]
@ -592,7 +597,7 @@ def build(bld):
features = "c", features = "c",
cflags = cflags, cflags = cflags,
includes = ['freebsd/contrib/tcpdump', 'freebsd/usr.sbin/tcpdump/tcpdump'] + includes, 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) source = objs06_source)
libbsd_use += ["objs06"] libbsd_use += ["objs06"]
@ -1066,6 +1071,7 @@ def build(bld):
cflags = cflags, cflags = cflags,
cxxflags = cxxflags, cxxflags = cxxflags,
includes = includes, includes = includes,
defines = defines,
source = source, source = source,
use = libbsd_use) use = libbsd_use)

View File

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

View File

@ -63,6 +63,11 @@ def options(opt):
default = "config.inc", default = "config.inc",
dest = "net_config", dest = "net_config",
help = "Network test configuration.") 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) libbsd_waf.options(opt)
def bsp_configure(conf, arch_bsp): def bsp_configure(conf, arch_bsp):
@ -82,8 +87,9 @@ def configure(conf):
conf.env.AUTO_REGEN = conf.options.auto_regen conf.env.AUTO_REGEN = conf.options.auto_regen
conf.env.WARNINGS = conf.options.warnings conf.env.WARNINGS = conf.options.warnings
conf.env.NET_CONFIG = conf.options.net_config conf.env.NET_CONFIG = conf.options.net_config
conf.env.FREEBSD_OPTIONS =conf.options.freebsd_options
rtems.configure(conf, bsp_configure) rtems.configure(conf, bsp_configure)
libbsd_waf.configure(conf, arch_bsp) libbsd_waf.configure(conf)
def build(bld): def build(bld):
rtems.build(bld) rtems.build(bld)