mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-05-13 04:34:34 +08:00
waf: Support building from libbsd.py directly from waf.
Remove the need to generate a waf script. Move various pieces of data from the builder code to libbsd.py and make it configuration data. Update #3351
This commit is contained in:
parent
8189ea825a
commit
f7a09b5985
158
builder.py
158
builder.py
@ -155,153 +155,6 @@ class diffRecord:
|
||||
#
|
||||
# This stuff needs to move to libbsd.py.
|
||||
#
|
||||
def commonFlags():
|
||||
return ['-g',
|
||||
'-fno-strict-aliasing',
|
||||
'-ffreestanding',
|
||||
'-fno-common']
|
||||
|
||||
def commonWarnings():
|
||||
return ['-Wall',
|
||||
'-Wno-format',
|
||||
'-Wno-pointer-sign']
|
||||
|
||||
def commonNoWarnings():
|
||||
return ['-w']
|
||||
|
||||
def includes():
|
||||
return ['-Irtemsbsd/include',
|
||||
'-Ifreebsd/sys',
|
||||
'-Ifreebsd/sys/contrib/pf',
|
||||
'-Ifreebsd/crypto',
|
||||
'-Ifreebsd/sys/net',
|
||||
'-Ifreebsd/include',
|
||||
'-Ifreebsd/lib',
|
||||
'-Ifreebsd/lib/libbsdstat',
|
||||
'-Ifreebsd/lib/libc/include',
|
||||
'-Ifreebsd/lib/libc/isc/include',
|
||||
'-Ifreebsd/lib/libc/resolv',
|
||||
'-Ifreebsd/lib/libutil',
|
||||
'-Ifreebsd/lib/libkvm',
|
||||
'-Ifreebsd/lib/libmemstat',
|
||||
'-Ifreebsd/lib/libipsec',
|
||||
'-Ifreebsd/contrib/expat/lib',
|
||||
'-Ifreebsd/contrib/libpcap',
|
||||
'-Ifreebsd/contrib/libxo',
|
||||
'-Ilinux/include',
|
||||
'-Ilinux/drivers/net/ethernet/freescale/fman',
|
||||
'-Irtemsbsd/sys',
|
||||
'-ImDNSResponder/mDNSCore',
|
||||
'-ImDNSResponder/mDNSShared',
|
||||
'-ImDNSResponder/mDNSPosix',
|
||||
'-Itestsuite/include']
|
||||
|
||||
def buildInclude():
|
||||
""" Returns the path where headers will be copied during build. """
|
||||
return 'build-include'
|
||||
|
||||
def cpuIncludes():
|
||||
return ['-Irtemsbsd/@CPU@/include',
|
||||
'-Ifreebsd/sys/@CPU@/include']
|
||||
|
||||
def cflags():
|
||||
return []
|
||||
|
||||
def cxxflags():
|
||||
return []
|
||||
|
||||
def headerPaths():
|
||||
""" Returns a list of information about what header files should be
|
||||
installed.
|
||||
|
||||
The list is also used to find headers with a local path that doesn't match
|
||||
it's dest path. Due to the difference in the path name such files are
|
||||
problematic during the build if they are included using their later
|
||||
installation path (dest path) name. Therefore they are copied into a
|
||||
sub-directory of the build path so that they can be included with their
|
||||
normal installation path. """
|
||||
|
||||
# local path wildcard dest path
|
||||
return [('rtemsbsd/include', '**/*.h', ''),
|
||||
('rtemsbsd/\' + bld.env.RTEMS_ARCH + \'/include', '**/*.h', ''),
|
||||
('rtemsbsd/mghttpd', 'mongoose.h', 'mghttpd'),
|
||||
('freebsd/include', '**/*.h', ''),
|
||||
('freebsd/sys/bsm', '**/*.h', 'bsm'),
|
||||
('freebsd/sys/cam', '**/*.h', 'cam'),
|
||||
('freebsd/sys/net', '**/*.h', 'net'),
|
||||
('freebsd/sys/net80211', '**/*.h', 'net80211'),
|
||||
('freebsd/sys/netinet', '**/*.h', 'netinet'),
|
||||
('freebsd/sys/netinet6', '**/*.h', 'netinet6'),
|
||||
('freebsd/sys/netipsec', '**/*.h', 'netipsec'),
|
||||
('freebsd/contrib/libpcap', '*.h', ''),
|
||||
('freebsd/contrib/libpcap/pcap', '*.h', 'pcap'),
|
||||
('freebsd/crypto/openssl', '*.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto', '*.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/ssl', '(ssl|kssl|ssl2).h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/aes', 'aes.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/err', 'err.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/bio', '*.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/dsa', '*.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/ssl', '*.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/bn', 'bn.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/x509', 'x509.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/cast', 'cast.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/lhash', 'lhash.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/ecdh', 'ecdh.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/ecdsa', 'ecdsa.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/idea', 'idea.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/mdc2', 'mdc2.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/md4', 'md4.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/md5', 'md5.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/rc2', 'rc2.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/rc4', 'rc4.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/ripemd','ripemd.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/seed', 'seed.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/sha', 'sha.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/x509v3','x509v3.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/x509', 'x509_vfy.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/buffer','buffer.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/comp', 'comp.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/asn1', 'asn1_mac.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/pem', '(pem|pem2).h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/rsa', 'rsa.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/evp', 'evp.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/ec', 'ec.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/engine', 'engine.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/pkcs7', 'pkcs7.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/hmac', 'hmac.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/pqueue', 'pqueue.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/ocsp', 'ocsp.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/rand', 'rand.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/srp', 'srp.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/dh', 'dh.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/dso', 'dso.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/krb5', 'krb5_asn.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/cms', 'cms.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/txt_db', 'txt_db.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/ts', 'ts.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/modes', 'modes.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/pkcs12', 'pkcs12.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/bf', 'blowfish.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/cmac', 'cmac.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/asn1', '(asn1|asn1t).h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/camellia', 'camellia.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/objects', '(objects|obj_mac).h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/conf', '(conf|conf_api).h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/des', '(des|des_old).h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/ui', '(ui_compat|ui).h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/whrlpool', 'whrlpool.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/stack', '(stack|safestack).h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto', '(opensslconf|opensslv|crypto).h', 'openssl'),
|
||||
('freebsd/sys/rpc', '**/*.h', 'rpc'),
|
||||
('freebsd/sys/sys', '**/*.h', 'sys'),
|
||||
('freebsd/sys/vm', '**/*.h', 'vm'),
|
||||
('freebsd/sys/dev/mii', '**/*.h', 'dev/mii'),
|
||||
('linux/include', '**/*.h', ''),
|
||||
('mDNSResponder/mDNSCore', 'mDNSDebug.h', ''),
|
||||
('mDNSResponder/mDNSCore', 'mDNSEmbeddedAPI.h', ''),
|
||||
('mDNSResponder/mDNSShared', 'dns_sd.h', ''),
|
||||
('mDNSResponder/mDNSPosix', 'mDNSPosix.h', '')]
|
||||
|
||||
# Move target dependent files under a machine directory
|
||||
def mapCPUDependentPath(path):
|
||||
@ -630,7 +483,7 @@ class File(object):
|
||||
#
|
||||
# Module - logical group of related files we can perform actions on
|
||||
#
|
||||
class Module:
|
||||
class Module(object):
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
self.conditionalOn = "none"
|
||||
@ -774,10 +627,11 @@ class Module:
|
||||
#
|
||||
# Manager - a collection of modules.
|
||||
#
|
||||
class ModuleManager:
|
||||
class ModuleManager(object):
|
||||
def __init__(self):
|
||||
self.modules = {}
|
||||
self.generator = {}
|
||||
self.configuration = {}
|
||||
self.setGenerators()
|
||||
|
||||
def __getitem__(self, key):
|
||||
@ -796,3 +650,9 @@ class ModuleManager:
|
||||
print("process modules:")
|
||||
for m in sorted(self.modules):
|
||||
self.modules[m].processSource(direction)
|
||||
|
||||
def setConfiguration(self, config):
|
||||
self.configuration = config
|
||||
|
||||
def getConfiguration(self):
|
||||
return self.configuration
|
||||
|
@ -42,12 +42,10 @@ import sys
|
||||
import getopt
|
||||
|
||||
import builder
|
||||
import waf_generator
|
||||
import libbsd
|
||||
|
||||
isForward = True
|
||||
isEarlyExit = False
|
||||
isOnlyBuildScripts = False
|
||||
statsReport = False
|
||||
|
||||
def usage():
|
||||
@ -57,7 +55,6 @@ def usage():
|
||||
print(" -D|--diff provide diff of files between trees")
|
||||
print(" -e|--early-exit evaluate arguments, print results, and exit")
|
||||
print(" -m|--makefile Warning: depreciated and will be removed ")
|
||||
print(" -b|--buildscripts just generate the build scripts")
|
||||
print(" -S|--stats Print a statistics report")
|
||||
print(" -R|--reverse default origin -> LibBSD, reverse that")
|
||||
print(" -r|--rtems LibBSD directory (default: '.')")
|
||||
@ -67,7 +64,6 @@ def usage():
|
||||
# Parse the arguments
|
||||
def parseArguments():
|
||||
global isForward, isEarlyExit, statsReport
|
||||
global isOnlyBuildScripts
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:],
|
||||
"?hdDembSRr:f:v",
|
||||
@ -100,8 +96,6 @@ def parseArguments():
|
||||
builder.isDiffMode = True
|
||||
elif o in ("-e", "--early-exit"):
|
||||
isEarlyExit = True
|
||||
elif o in ("-b", "--buildscripts") or o in ("-m", "--makefile"):
|
||||
isOnlyBuildScripts = True
|
||||
elif o in ("-S", "--stats"):
|
||||
statsReport = True
|
||||
elif o in ("-R", "--reverse"):
|
||||
@ -119,7 +113,6 @@ print("Verbose: %s (%d)" % (("no", "yes")[builder.verbose()]
|
||||
builder.verboseLevel))
|
||||
print("Dry Run: %s" % (("no", "yes")[builder.isDryRun]))
|
||||
print("Diff Mode Enabled: %s" % (("no", "yes")[builder.isDiffMode]))
|
||||
print("Only Generate Build Scripts: %s" % (("no", "yes")[isOnlyBuildScripts]))
|
||||
print("LibBSD Directory: %s" % (builder.LIBBSD_DIR))
|
||||
print("FreeBSD Directory: %s" % (builder.FreeBSD_DIR))
|
||||
print("Direction: %s" % (("reverse", "forward")[isForward]))
|
||||
@ -143,20 +136,15 @@ if isForward == True:
|
||||
print("Forward from", builder.FreeBSD_DIR, "into", builder.LIBBSD_DIR)
|
||||
else:
|
||||
print("Reverting from", builder.LIBBSD_DIR)
|
||||
if isOnlyBuildScripts == True:
|
||||
print("error: Build Script generation and Reverse are contradictory")
|
||||
sys.exit(2)
|
||||
|
||||
if isEarlyExit == True:
|
||||
print("Early exit at user request")
|
||||
sys.exit(0)
|
||||
|
||||
try:
|
||||
wafGen = waf_generator.ModuleManager()
|
||||
libbsd.sources(wafGen)
|
||||
if not isOnlyBuildScripts:
|
||||
wafGen.processSource(isForward)
|
||||
wafGen.generate(libbsd.rtems_version())
|
||||
build = builder.ModuleManager()
|
||||
libbsd.loadModules(build)
|
||||
build.processSource(isForward)
|
||||
builder.changedFileSummary(statsReport)
|
||||
except IOError as ioe:
|
||||
print('error: %s' % (str(ioe)))
|
||||
|
321
libbsd.py
321
libbsd.py
@ -1,5 +1,6 @@
|
||||
#
|
||||
# Copyright (c) 2015-2016 Chris Johns <chrisj@rtems.org>. All rights reserved.
|
||||
# Copyright (c) 2015-2016, 2018 Chris Johns <chrisj@rtems.org>.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Copyright (c) 2009, 2018 embedded brains GmbH. All rights reserved.
|
||||
#
|
||||
@ -35,10 +36,152 @@
|
||||
import builder
|
||||
|
||||
#
|
||||
# RTEMS version
|
||||
# Default configuration.
|
||||
#
|
||||
def rtems_version():
|
||||
return '4.12'
|
||||
_defaults = {
|
||||
#
|
||||
# Compile flags
|
||||
#
|
||||
'common-flags': ['-g',
|
||||
'-fno-strict-aliasing',
|
||||
'-ffreestanding',
|
||||
'-fno-common'],
|
||||
'common-warnings' : ['-Wall',
|
||||
'-Wno-format',
|
||||
'-Wno-pointer-sign'],
|
||||
'common-no-warnings': ['-w'],
|
||||
'cflags': [],
|
||||
'cxxflags': [],
|
||||
|
||||
#
|
||||
# Includes
|
||||
#
|
||||
'include-paths': ['rtemsbsd/include',
|
||||
'freebsd/sys',
|
||||
'freebsd/sys/contrib/pf',
|
||||
'freebsd/crypto',
|
||||
'freebsd/sys/net',
|
||||
'freebsd/include',
|
||||
'freebsd/lib',
|
||||
'freebsd/lib/libbsdstat',
|
||||
'freebsd/lib/libc/include',
|
||||
'freebsd/lib/libc/isc/include',
|
||||
'freebsd/lib/libc/resolv',
|
||||
'freebsd/lib/libutil',
|
||||
'freebsd/lib/libkvm',
|
||||
'freebsd/lib/libmemstat',
|
||||
'freebsd/lib/libipsec',
|
||||
'freebsd/contrib/expat/lib',
|
||||
'freebsd/contrib/libpcap',
|
||||
'freebsd/contrib/libxo',
|
||||
'linux/include',
|
||||
'linux/drivers/net/ethernet/freescale/fman',
|
||||
'rtemsbsd/sys',
|
||||
'mDNSResponder/mDNSCore',
|
||||
'mDNSResponder/mDNSShared',
|
||||
'mDNSResponder/mDNSPosix',
|
||||
'testsuite/include'],
|
||||
'cpu-include-paths': ['rtemsbsd/@CPU@/include',
|
||||
'freebsd/sys/@CPU@/include'],
|
||||
|
||||
# The path where headers will be copied during build.
|
||||
'build-include-path': ['build-include'],
|
||||
|
||||
#
|
||||
# Install headers
|
||||
#
|
||||
# A list of information about what header files should be installed.
|
||||
#
|
||||
# The list is also used to find headers with a local path that doesn't
|
||||
# match it's dest path. Due to the difference in the path name such files
|
||||
# are problematic during the build if they are included using their later
|
||||
# installation path (dest path) name. Therefore they are copied into a
|
||||
# sub-directory of the build path so that they can be included with their
|
||||
# normal installation path.
|
||||
#
|
||||
'header-paths':
|
||||
# local path wildcard dest path
|
||||
[('rtemsbsd/include', '**/*.h', ''),
|
||||
('rtemsbsd/@CPU@/include', '**/*.h', ''),
|
||||
('rtemsbsd/mghttpd', 'mongoose.h', 'mghttpd'),
|
||||
('freebsd/include', '**/*.h', ''),
|
||||
('freebsd/sys/bsm', '**/*.h', 'bsm'),
|
||||
('freebsd/sys/cam', '**/*.h', 'cam'),
|
||||
('freebsd/sys/net', '**/*.h', 'net'),
|
||||
('freebsd/sys/net80211', '**/*.h', 'net80211'),
|
||||
('freebsd/sys/netinet', '**/*.h', 'netinet'),
|
||||
('freebsd/sys/netinet6', '**/*.h', 'netinet6'),
|
||||
('freebsd/sys/netipsec', '**/*.h', 'netipsec'),
|
||||
('freebsd/contrib/libpcap', '*.h', ''),
|
||||
('freebsd/contrib/libpcap/pcap', '*.h', 'pcap'),
|
||||
('freebsd/crypto/openssl', '*.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto', '*.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/ssl', '(ssl|kssl|ssl2).h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/aes', 'aes.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/err', 'err.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/bio', '*.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/dsa', '*.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/ssl', '*.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/bn', 'bn.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/x509', 'x509.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/cast', 'cast.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/lhash', 'lhash.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/ecdh', 'ecdh.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/ecdsa', 'ecdsa.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/idea', 'idea.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/mdc2', 'mdc2.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/md4', 'md4.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/md5', 'md5.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/rc2', 'rc2.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/rc4', 'rc4.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/ripemd', 'ripemd.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/seed', 'seed.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/sha', 'sha.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/x509v3', 'x509v3.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/x509', 'x509_vfy.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/buffer', 'buffer.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/comp', 'comp.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/asn1', 'asn1_mac.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/pem', '(pem|pem2).h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/rsa', 'rsa.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/evp', 'evp.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/ec', 'ec.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/engine', 'engine.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/pkcs7', 'pkcs7.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/hmac', 'hmac.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/pqueue', 'pqueue.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/ocsp', 'ocsp.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/rand', 'rand.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/srp', 'srp.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/dh', 'dh.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/dso', 'dso.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/krb5', 'krb5_asn.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/cms', 'cms.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/txt_db', 'txt_db.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/ts', 'ts.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/modes', 'modes.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/pkcs12', 'pkcs12.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/bf', 'blowfish.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/cmac', 'cmac.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/asn1', '(asn1|asn1t).h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/camellia', 'camellia.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/objects', '(objects|obj_mac).h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/conf', '(conf|conf_api).h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/des', '(des|des_old).h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/ui', '(ui_compat|ui).h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/whrlpool', 'whrlpool.h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto/stack', '(stack|safestack).h', 'openssl'),
|
||||
('freebsd/crypto/openssl/crypto', '(opensslconf|opensslv|crypto).h', 'openssl'),
|
||||
('freebsd/sys/rpc', '**/*.h', 'rpc'),
|
||||
('freebsd/sys/sys', '**/*.h', 'sys'),
|
||||
('freebsd/sys/vm', '**/*.h', 'vm'),
|
||||
('freebsd/sys/dev/mii', '**/*.h', 'dev/mii'),
|
||||
('linux/include', '**/*.h', ''),
|
||||
('mDNSResponder/mDNSCore', 'mDNSDebug.h', ''),
|
||||
('mDNSResponder/mDNSCore', 'mDNSEmbeddedAPI.h', ''),
|
||||
('mDNSResponder/mDNSShared', 'dns_sd.h', ''),
|
||||
('mDNSResponder/mDNSPosix', 'mDNSPosix.h', '')]
|
||||
}
|
||||
|
||||
#
|
||||
# RTEMS
|
||||
@ -4367,86 +4510,6 @@ def in_cksum(mm):
|
||||
)
|
||||
return mod
|
||||
|
||||
#
|
||||
# Tests
|
||||
#
|
||||
def tests(mm):
|
||||
mod = builder.Module('tests')
|
||||
mod.addTest(mm.generator['test']('nfs01', ['test_main'], netTest = True))
|
||||
mod.addTest(mm.generator['test']('foobarclient', ['test_main'],
|
||||
runTest = False, netTest = True))
|
||||
mod.addTest(mm.generator['test']('foobarserver', ['test_main'],
|
||||
runTest = False, netTest = True))
|
||||
mod.addTest(mm.generator['test']('dhcpcd01', ['test_main'],
|
||||
runTest = False, netTest = True))
|
||||
mod.addTest(mm.generator['test']('dhcpcd02', ['test_main'],
|
||||
runTest = False, netTest = True))
|
||||
mod.addTest(mm.generator['test']('arphole', ['test_main'],
|
||||
runTest = False, netTest = True))
|
||||
mod.addTest(mm.generator['test']('telnetd01', ['test_main'],
|
||||
runTest = False, netTest = True))
|
||||
mod.addTest(mm.generator['test']('unix01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('ftpd01', ['test_main'], netTest = True))
|
||||
mod.addTest(mm.generator['test']('ftpd02', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('ping01', ['test_main'], netTest = True))
|
||||
mod.addTest(mm.generator['test']('selectpollkqueue01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('rwlock01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('sleep01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('syscalls01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('program01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('commands01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('usb01', ['init'], False))
|
||||
mod.addTest(mm.generator['test']('usbserial01', ['init'], False))
|
||||
mod.addTest(mm.generator['test']('usbkbd01', ['init'], False))
|
||||
mod.addTest(mm.generator['test']('usbmouse01', ['init'], False))
|
||||
mod.addTest(mm.generator['test']('evdev01', ['init'], False))
|
||||
mod.addTest(mm.generator['test']('loopback01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('netshell01', ['test_main', 'shellconfig'], False))
|
||||
mod.addTest(mm.generator['test']('swi01', ['init', 'swi_test']))
|
||||
mod.addTest(mm.generator['test']('timeout01', ['init', 'timeout_test']))
|
||||
mod.addTest(mm.generator['test']('init01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('thread01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('mutex01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('condvar01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('ppp01', ['test_main'], runTest = False))
|
||||
mod.addTest(mm.generator['test']('zerocopy01', ['test_main'],
|
||||
runTest = False, netTest = True))
|
||||
mod.addTest(mm.generator['test']('smp01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('media01', ['test_main'], runTest = False))
|
||||
mod.addTest(mm.generator['test']('vlan01', ['test_main'], netTest = True))
|
||||
mod.addTest(mm.generator['test']('lagg01', ['test_main'], netTest = True))
|
||||
mod.addTest(mm.generator['test']('log01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('rcconf01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('rcconf02', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('cdev01', ['test_main', 'test_cdev']))
|
||||
mod.addTest(mm.generator['test']('pf01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('pf02', ['test_main'], runTest = False))
|
||||
mod.addTest(mm.generator['test']('termios', ['test_main',
|
||||
'test_termios_driver',
|
||||
'test_termios_utilities']))
|
||||
mod.addTest(mm.generator['test']('termios01', ['test_main',
|
||||
'../termios/test_termios_driver',
|
||||
'../termios/test_termios_utilities']))
|
||||
mod.addTest(mm.generator['test']('termios02', ['test_main',
|
||||
'../termios/test_termios_driver',
|
||||
'../termios/test_termios_utilities']))
|
||||
mod.addTest(mm.generator['test']('termios03', ['test_main',
|
||||
'../termios/test_termios_driver',
|
||||
'../termios/test_termios_utilities']))
|
||||
mod.addTest(mm.generator['test']('termios04', ['test_main',
|
||||
'../termios/test_termios_driver',
|
||||
'../termios/test_termios_utilities']))
|
||||
mod.addTest(mm.generator['test']('termios05', ['test_main',
|
||||
'../termios/test_termios_driver',
|
||||
'../termios/test_termios_utilities']))
|
||||
mod.addTest(mm.generator['test']('termios06', ['test_main',
|
||||
'../termios/test_termios_driver',
|
||||
'../termios/test_termios_utilities']))
|
||||
mod.addTest(mm.generator['test-if-header']('debugger01', 'rtems/rtems-debugger.h',
|
||||
['test_main'], runTest = False, netTest = True))
|
||||
mod.addTest(mm.generator['test']('crypto01', ['test_main']))
|
||||
return mod
|
||||
|
||||
#
|
||||
# DHCP
|
||||
#
|
||||
@ -4589,7 +4652,92 @@ def dpaa(mm):
|
||||
)
|
||||
return mod
|
||||
|
||||
def sources(mm):
|
||||
#
|
||||
# Tests
|
||||
#
|
||||
# Note: Keep as the last module
|
||||
#
|
||||
def tests(mm):
|
||||
mod = builder.Module('tests')
|
||||
mod.addTest(mm.generator['test']('nfs01', ['test_main'], netTest = True))
|
||||
mod.addTest(mm.generator['test']('foobarclient', ['test_main'],
|
||||
runTest = False, netTest = True))
|
||||
mod.addTest(mm.generator['test']('foobarserver', ['test_main'],
|
||||
runTest = False, netTest = True))
|
||||
mod.addTest(mm.generator['test']('dhcpcd01', ['test_main'],
|
||||
runTest = False, netTest = True))
|
||||
mod.addTest(mm.generator['test']('dhcpcd02', ['test_main'],
|
||||
runTest = False, netTest = True))
|
||||
mod.addTest(mm.generator['test']('arphole', ['test_main'],
|
||||
runTest = False, netTest = True))
|
||||
mod.addTest(mm.generator['test']('telnetd01', ['test_main'],
|
||||
runTest = False, netTest = True))
|
||||
mod.addTest(mm.generator['test']('unix01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('ftpd01', ['test_main'], netTest = True))
|
||||
mod.addTest(mm.generator['test']('ftpd02', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('ping01', ['test_main'], netTest = True))
|
||||
mod.addTest(mm.generator['test']('selectpollkqueue01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('rwlock01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('sleep01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('syscalls01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('program01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('commands01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('usb01', ['init'], False))
|
||||
mod.addTest(mm.generator['test']('usbserial01', ['init'], False))
|
||||
mod.addTest(mm.generator['test']('usbkbd01', ['init'], False))
|
||||
mod.addTest(mm.generator['test']('usbmouse01', ['init'], False))
|
||||
mod.addTest(mm.generator['test']('evdev01', ['init'], False))
|
||||
mod.addTest(mm.generator['test']('loopback01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('netshell01', ['test_main', 'shellconfig'], False))
|
||||
mod.addTest(mm.generator['test']('swi01', ['init', 'swi_test']))
|
||||
mod.addTest(mm.generator['test']('timeout01', ['init', 'timeout_test']))
|
||||
mod.addTest(mm.generator['test']('init01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('thread01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('mutex01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('condvar01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('ppp01', ['test_main'], runTest = False))
|
||||
mod.addTest(mm.generator['test']('zerocopy01', ['test_main'],
|
||||
runTest = False, netTest = True))
|
||||
mod.addTest(mm.generator['test']('smp01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('media01', ['test_main'], runTest = False))
|
||||
mod.addTest(mm.generator['test']('vlan01', ['test_main'], netTest = True))
|
||||
mod.addTest(mm.generator['test']('lagg01', ['test_main'], netTest = True))
|
||||
mod.addTest(mm.generator['test']('log01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('rcconf01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('rcconf02', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('cdev01', ['test_main', 'test_cdev']))
|
||||
mod.addTest(mm.generator['test']('pf01', ['test_main']))
|
||||
mod.addTest(mm.generator['test']('pf02', ['test_main'], runTest = False))
|
||||
mod.addTest(mm.generator['test']('termios', ['test_main',
|
||||
'test_termios_driver',
|
||||
'test_termios_utilities']))
|
||||
mod.addTest(mm.generator['test']('termios01', ['test_main',
|
||||
'../termios/test_termios_driver',
|
||||
'../termios/test_termios_utilities']))
|
||||
mod.addTest(mm.generator['test']('termios02', ['test_main',
|
||||
'../termios/test_termios_driver',
|
||||
'../termios/test_termios_utilities']))
|
||||
mod.addTest(mm.generator['test']('termios03', ['test_main',
|
||||
'../termios/test_termios_driver',
|
||||
'../termios/test_termios_utilities']))
|
||||
mod.addTest(mm.generator['test']('termios04', ['test_main',
|
||||
'../termios/test_termios_driver',
|
||||
'../termios/test_termios_utilities']))
|
||||
mod.addTest(mm.generator['test']('termios05', ['test_main',
|
||||
'../termios/test_termios_driver',
|
||||
'../termios/test_termios_utilities']))
|
||||
mod.addTest(mm.generator['test']('termios06', ['test_main',
|
||||
'../termios/test_termios_driver',
|
||||
'../termios/test_termios_utilities']))
|
||||
mod.addTest(mm.generator['test-if-header']('debugger01', 'rtems/rtems-debugger.h',
|
||||
['test_main'], runTest = False, netTest = True))
|
||||
mod.addTest(mm.generator['test']('crypto01', ['test_main']))
|
||||
return mod
|
||||
|
||||
def load(mm):
|
||||
|
||||
mm.setConfiguration(_defaults)
|
||||
|
||||
mm.addModule(dpaa(mm))
|
||||
mm.addModule(rtems(mm))
|
||||
mm.addModule(base(mm))
|
||||
@ -4659,10 +4807,11 @@ def sources(mm):
|
||||
mm.addModule(usr_sbin_wpa_supplicant(mm))
|
||||
mm.addModule(crypto_openssl(mm))
|
||||
|
||||
mm.addModule(tests(mm))
|
||||
mm.addModule(dhcpcd(mm))
|
||||
mm.addModule(mghttpd(mm))
|
||||
mm.addModule(mdnsresponder(mm))
|
||||
|
||||
mm.addModule(tests(mm))
|
||||
|
||||
# XXX TODO Check that no file is also listed in empty
|
||||
# XXX TODO Check that no file in in two modules
|
||||
|
10
libbsd.txt
10
libbsd.txt
@ -32,7 +32,7 @@ Please help by adding to it.
|
||||
|
||||
=== Tool Chain ===
|
||||
|
||||
You need a tool chain for RTEMS based on at least RSB 4.12 April 2016 or later.
|
||||
You need a tool chain for RTEMS based on at least RSB 5 April 2016 or later.
|
||||
|
||||
=== Installation Overview ===
|
||||
|
||||
@ -57,7 +57,7 @@ status' says `rtems_waf` need updating run the submodule update command:
|
||||
|
||||
=== Board Support Package Requirements ===
|
||||
|
||||
The RTEMS version must be at least 4.12. The Board Support Package (BSP)
|
||||
The RTEMS version must be at least 5. The Board Support Package (BSP)
|
||||
should support the
|
||||
http://www.rtems.org/onlinedocs/doxygen/cpukit/html/group\__rtems\__interrupt__extension.html[Interrupt Manager Extension]
|
||||
// The first underscores have to be masked to stop asciidoc interpreting them
|
||||
@ -99,7 +99,7 @@ mkdir b-xilinx_zynq_a9_qemu
|
||||
cd b-xilinx_zynq_a9_qemu
|
||||
${HOME}/git-rtems/configure \
|
||||
--prefix=${HOME}/sandbox/install \
|
||||
--target=arm-rtems4.12 \
|
||||
--target=arm-rtems5 \
|
||||
--enable-rtemsbsp=xilinx_zynq_a9_qemu \
|
||||
--disable-networking && \
|
||||
make && \
|
||||
@ -410,7 +410,7 @@ qemu-system-arm \
|
||||
-net nic,model=cadence_gem,macaddr=0e:b0:ba:5e:ba:11 \
|
||||
-net tap,ifname=qtap1,script=no,downscript=no \
|
||||
-m 256M \
|
||||
-kernel build/arm-rtems4.12-xilinx_zynq_a9_qemu/media01.exe
|
||||
-kernel build/arm-rtems5-xilinx_zynq_a9_qemu/media01.exe
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Make sure that each Qemu instance uses its own MAC address to avoid an address
|
||||
@ -474,7 +474,7 @@ To run qemu:
|
||||
-net nic,model=cadence_gem,macaddr=0e:b0:ba:5e:ba:11 \
|
||||
-net vde,id=vde0,sock=/tmp/vde1
|
||||
-m 256M \
|
||||
-kernel build/arm-rtems4.12-xilinx_zynq_a9_qemu/rcconf02.exe
|
||||
-kernel build/arm-rtems5-xilinx_zynq_a9_qemu/rcconf02.exe
|
||||
|
||||
== Issues and TODO
|
||||
|
||||
|
3092
libbsd_waf.py
3092
libbsd_waf.py
File diff suppressed because it is too large
Load Diff
690
waf_generator.py
690
waf_generator.py
@ -1,690 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2015-2016 Chris Johns <chrisj@rtems.org>. All rights reserved.
|
||||
#
|
||||
# Copyright (c) 2009-2015 embedded brains GmbH. All rights reserved.
|
||||
#
|
||||
# embedded brains GmbH
|
||||
# Dornierstr. 4
|
||||
# 82178 Puchheim
|
||||
# Germany
|
||||
# <info@embedded-brains.de>
|
||||
#
|
||||
# Copyright (c) 2012 OAR Corporation. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
import builder
|
||||
|
||||
#
|
||||
# Dump the data created from the fragments returned from the builder composers.
|
||||
#
|
||||
trace = False
|
||||
|
||||
data = { }
|
||||
|
||||
def _addFiles(name, files):
|
||||
if type(files) is not list:
|
||||
files = [files]
|
||||
if name not in data:
|
||||
data[name] = []
|
||||
data[name] += files
|
||||
|
||||
def _cflagsIncludes(cflags, includes):
|
||||
if type(cflags) is not list:
|
||||
if cflags is not None:
|
||||
_cflags = cflags.split(' ')
|
||||
else:
|
||||
_cflags = [None]
|
||||
else:
|
||||
_cflags = cflags
|
||||
if type(includes) is not list:
|
||||
_includes = [includes]
|
||||
else:
|
||||
_includes = includes
|
||||
return _cflags, _includes
|
||||
|
||||
class SourceFileFragmentComposer(builder.BuildSystemFragmentComposer):
|
||||
|
||||
def __init__(self, cflags = "default", includes = None):
|
||||
self.cflags, self.includes = _cflagsIncludes(cflags, includes)
|
||||
|
||||
def compose(self, path):
|
||||
if None in self.includes:
|
||||
flags = self.cflags
|
||||
else:
|
||||
flags = self.cflags + self.includes
|
||||
return ['sources', flags, ('default', None)], [path], self.cflags, self.includes
|
||||
|
||||
class SourceFileIfHeaderComposer(SourceFileFragmentComposer):
|
||||
|
||||
def __init__(self, headers, cflags = "default", includes = None):
|
||||
if headers is not list:
|
||||
headers = [headers]
|
||||
self.headers = headers
|
||||
super(SourceFileIfHeaderComposer, self).__init__(cflags = cflags, includes = includes)
|
||||
|
||||
def compose(self, path):
|
||||
r = SourceFileFragmentComposer.compose(self, path)
|
||||
define_keys = ''
|
||||
for h in self.headers:
|
||||
h = h.upper()
|
||||
for c in '\/-.':
|
||||
h = h.replace(c, '_')
|
||||
define_keys += ' ' + h
|
||||
r[0][2] = (define_keys.strip(), self.headers)
|
||||
return r
|
||||
|
||||
class TestFragementComposer(builder.BuildSystemFragmentComposer):
|
||||
|
||||
def __init__(self, testName, fileFragments, runTest = True, netTest = False):
|
||||
self.testName = testName
|
||||
self.fileFragments = fileFragments
|
||||
self.runTest = runTest
|
||||
self.netTest = netTest
|
||||
|
||||
def compose(self, path):
|
||||
return ['tests', self.testName, ('default', None)], { 'files': self.fileFragments,
|
||||
'run': self.runTest,
|
||||
'net': self.netTest }
|
||||
|
||||
class TestIfHeaderComposer(TestFragementComposer):
|
||||
|
||||
def __init__(self, testName, headers, fileFragments, runTest = True, netTest = False):
|
||||
if headers is not list:
|
||||
headers = [headers]
|
||||
self.headers = headers
|
||||
super(TestIfHeaderComposer, self).__init__(testName, fileFragments,
|
||||
runTest = runTest, netTest = netTest)
|
||||
|
||||
def compose(self, path):
|
||||
r = TestFragementComposer.compose(self, path)
|
||||
define_keys = ''
|
||||
for h in self.headers:
|
||||
h = h.upper()
|
||||
for c in '\/-.':
|
||||
h = h.replace(c, '_')
|
||||
define_keys += ' ' + h
|
||||
r[0][2] = (define_keys.strip(), self.headers)
|
||||
return r
|
||||
|
||||
class KVMSymbolsFragmentComposer(builder.BuildSystemFragmentComposer):
|
||||
|
||||
def compose(self, path):
|
||||
return ['KVMSymbols', 'files', ('default', None)], [path], self.includes
|
||||
|
||||
class RPCGENFragmentComposer(builder.BuildSystemFragmentComposer):
|
||||
|
||||
def compose(self, path):
|
||||
return ['RPCGen', 'files', ('default', None)], [path]
|
||||
|
||||
class RouteKeywordsFragmentComposer(builder.BuildSystemFragmentComposer):
|
||||
|
||||
def compose(self, path):
|
||||
return ['RouteKeywords', 'files', ('default', None)], [path]
|
||||
|
||||
class LexFragmentComposer(builder.BuildSystemFragmentComposer):
|
||||
|
||||
def __init__(self, sym, dep, cflags = None, includes = None):
|
||||
self.sym = sym
|
||||
self.dep = dep
|
||||
self.cflags, self.includes = _cflagsIncludes(cflags, includes)
|
||||
|
||||
def compose(self, path):
|
||||
d = { 'file': path,
|
||||
'sym': self.sym,
|
||||
'dep': self.dep }
|
||||
if None not in self.cflags:
|
||||
d['cflags'] = self.cflags
|
||||
if None not in self.includes:
|
||||
d['includes'] = self.includes
|
||||
return ['lex', path, ('default', None)], d
|
||||
|
||||
class YaccFragmentComposer(builder.BuildSystemFragmentComposer):
|
||||
|
||||
def __init__(self, sym, header, cflags = None, includes = None):
|
||||
self.sym = sym
|
||||
self.header = header
|
||||
self.cflags, self.includes = _cflagsIncludes(cflags, includes)
|
||||
|
||||
def compose(self, path):
|
||||
d = { 'file': path,
|
||||
'sym': self.sym,
|
||||
'header': self.header }
|
||||
if None not in self.cflags:
|
||||
d['cflags'] = self.cflags
|
||||
if None not in self.includes:
|
||||
d['includes'] = self.includes
|
||||
return ['yacc', path, ('default', None)], d
|
||||
|
||||
def headerPathSpec(headerPath):
|
||||
return '(\'%s\', \'%s\', \'%s\')' % (headerPath[0], headerPath[1], headerPath[2])
|
||||
|
||||
# Module Manager - Collection of Modules
|
||||
class ModuleManager(builder.ModuleManager):
|
||||
|
||||
def restart(self):
|
||||
self.script = ''
|
||||
|
||||
def add(self, line = ''):
|
||||
self.script += line + os.linesep
|
||||
|
||||
def write(self):
|
||||
name = os.path.join(builder.LIBBSD_DIR, 'libbsd_waf.py')
|
||||
converter = builder.Converter()
|
||||
converter.convert(name, name, srcContents = self.script)
|
||||
|
||||
def setGenerators(self):
|
||||
self.generator['convert'] = builder.Converter
|
||||
self.generator['no-convert'] = builder.NoConverter
|
||||
self.generator['from-FreeBSD-to-RTEMS-UserSpaceSourceConverter'] = builder.FromFreeBSDToRTEMSUserSpaceSourceConverter
|
||||
self.generator['from-RTEMS-To-FreeBSD-SourceConverter'] = builder.FromRTEMSToFreeBSDSourceConverter
|
||||
self.generator['buildSystemFragmentComposer'] = builder.BuildSystemFragmentComposer
|
||||
|
||||
self.generator['file'] = builder.File
|
||||
|
||||
self.generator['path'] = builder.PathComposer
|
||||
self.generator['freebsd-path'] = builder.FreeBSDPathComposer
|
||||
self.generator['rtems-path'] = builder.RTEMSPathComposer
|
||||
self.generator['cpu-path'] = builder.CPUDependentFreeBSDPathComposer
|
||||
self.generator['target-src-cpu--path'] = builder.TargetSourceCPUDependentPathComposer
|
||||
|
||||
self.generator['source'] = SourceFileFragmentComposer
|
||||
self.generator['test'] = TestFragementComposer
|
||||
self.generator['kvm-symbols'] = KVMSymbolsFragmentComposer
|
||||
self.generator['rpc-gen'] = RPCGENFragmentComposer
|
||||
self.generator['route-keywords'] = RouteKeywordsFragmentComposer
|
||||
self.generator['lex'] = LexFragmentComposer
|
||||
self.generator['yacc'] = YaccFragmentComposer
|
||||
|
||||
self.generator['source-if-header'] = SourceFileIfHeaderComposer
|
||||
self.generator['test-if-header'] = TestIfHeaderComposer
|
||||
|
||||
def generate(self, rtems_version):
|
||||
|
||||
def _sourceListSources(lhs, sources, append = False, block = 0):
|
||||
indent = block * 4
|
||||
if append:
|
||||
adder = '+'
|
||||
adderSpace = ' '
|
||||
else:
|
||||
adder = ''
|
||||
adderSpace = ''
|
||||
ll = len(lhs)
|
||||
if len(sources) == 1:
|
||||
self.add('%s%s %s= [%r]' % (' ' * indent, lhs, adder, sources[0]))
|
||||
elif len(sources) == 2:
|
||||
self.add('%s%s %s= [%r,' % (' ' * indent, lhs, adder, sources[0]))
|
||||
self.add('%s%s %s %r]' % (' ' * indent, ' ' * ll, adderSpace, sources[-1]))
|
||||
elif len(sources) > 0:
|
||||
self.add('%s%s %s= [%r,' % (' ' * indent, lhs, adder, sources[0]))
|
||||
for f in sources[1:-1]:
|
||||
self.add('%s%s %s %r,' % (' ' * indent, ' ' * ll, adderSpace, f))
|
||||
self.add('%s%s %s %r]' % (' ' * indent, ' ' * ll, adderSpace, sources[-1]))
|
||||
|
||||
def _sourceList(lhs, files, append = False):
|
||||
if type(files) is dict:
|
||||
appending = False
|
||||
for cfg in files:
|
||||
if cfg in ['cflags', 'includes']:
|
||||
continue
|
||||
if cfg != 'default':
|
||||
cs = ''
|
||||
ors = ''
|
||||
for c in cfg.split(' '):
|
||||
cs += '%s bld.env["HAVE_%s"]' % (ors, c)
|
||||
ors = ' and'
|
||||
self.add(' if%s:' % (cs))
|
||||
_sourceListSources(lhs, sorted(files[cfg]), append = appending, block = 1)
|
||||
else:
|
||||
_sourceListSources(lhs, sorted(files[cfg]), append)
|
||||
appending = True
|
||||
else:
|
||||
_sourceListSources(lhs, sorted(files), append)
|
||||
|
||||
def _dataInsert(data, cpu, frag):
|
||||
#
|
||||
# The default handler returns an empty string. Skip it.
|
||||
#
|
||||
if type(frag) is not str:
|
||||
# Start at the top of the tree
|
||||
d = data
|
||||
path = frag[0]
|
||||
if path[0] not in d:
|
||||
d[path[0]] = {}
|
||||
# Select the sub-part of the tree as the compile options
|
||||
# specialise how files are built.
|
||||
d = d[path[0]]
|
||||
if type(path[1]) is list:
|
||||
p = ' '.join(path[1])
|
||||
else:
|
||||
p = path[1]
|
||||
if p not in d:
|
||||
d[p] = {}
|
||||
d = d[p]
|
||||
if cpu not in d:
|
||||
d[cpu] = { }
|
||||
config = frag[0][2][0]
|
||||
if config != 'default':
|
||||
if 'configure' not in data:
|
||||
data['configure'] = { }
|
||||
data['configure'][config] = frag[0][2][1]
|
||||
if type(frag[1]) is list:
|
||||
if config not in d[cpu]:
|
||||
d[cpu][config] = []
|
||||
d[cpu][config] += frag[1]
|
||||
else:
|
||||
d[cpu][config] = frag[1]
|
||||
#
|
||||
# The CPU is for files and the flags and includes are common.
|
||||
#
|
||||
if len(frag) > 3:
|
||||
if 'cflags' not in d:
|
||||
d['cflags'] = []
|
||||
d['cflags'] += frag[2]
|
||||
d['cflags'] = list(set(d['cflags']))
|
||||
if len(frag) >= 3 and None not in frag[-1]:
|
||||
if 'includes' not in d:
|
||||
d['includes'] = []
|
||||
d['includes'] += frag[-1]
|
||||
d['includes'] = list(set(d['includes']))
|
||||
|
||||
data = { }
|
||||
|
||||
for mn in self.getModules():
|
||||
m = self[mn]
|
||||
if m.conditionalOn == "none":
|
||||
for f in m.files:
|
||||
_dataInsert(data, 'all', f.getFragment())
|
||||
for cpu, files in sorted(m.cpuDependentSourceFiles.items()):
|
||||
for f in files:
|
||||
_dataInsert(data, cpu, f.getFragment())
|
||||
|
||||
if trace:
|
||||
import pprint
|
||||
pprint.pprint(data)
|
||||
|
||||
self.restart()
|
||||
|
||||
self.add('#')
|
||||
self.add('# RTEMS Project (https://www.rtems.org)')
|
||||
self.add('#')
|
||||
self.add('# Generated waf script. Do not edit, run ./freebsd-to-rtems.py -m')
|
||||
self.add('#')
|
||||
self.add('# To use see README.waf shipped with this file.')
|
||||
self.add('#')
|
||||
self.add('')
|
||||
self.add('from __future__ import print_function')
|
||||
self.add('')
|
||||
self.add('import os')
|
||||
self.add('import os.path')
|
||||
# Import check done in the top level wscript file.
|
||||
self.add('import rtems_waf.rtems as rtems')
|
||||
self.add('')
|
||||
self.add('windows = os.name == "nt"')
|
||||
self.add('')
|
||||
self.add('if windows:')
|
||||
self.add(' host_shell = "sh -c "')
|
||||
self.add('else:')
|
||||
self.add(' host_shell = ""')
|
||||
self.add('')
|
||||
self.add('def init(ctx):')
|
||||
self.add(' pass')
|
||||
self.add('')
|
||||
self.add('def options(opt):')
|
||||
self.add(' pass')
|
||||
self.add('')
|
||||
self.add('def bsp_configure(conf, arch_bsp):')
|
||||
|
||||
if 'configure' in data:
|
||||
for cfg in data['configure']:
|
||||
for h in data['configure'][cfg]:
|
||||
self.add(' conf.check(header_name = "%s", features = "c", includes = conf.env.IFLAGS, mandatory = False)' % h)
|
||||
else:
|
||||
self.add(' pass')
|
||||
|
||||
self.add('')
|
||||
self.add('def configure(conf):')
|
||||
self.add(' rtems.configure(conf, bsp_configure)')
|
||||
self.add('')
|
||||
self.add('def build(bld):')
|
||||
self.add(' # C/C++ flags')
|
||||
self.add(' common_flags = []')
|
||||
self.add(' common_flags += ["-O%s" % (bld.env.OPTIMIZATION)]')
|
||||
for f in builder.commonFlags():
|
||||
self.add(' common_flags += ["%s"]' % (f))
|
||||
self.add(' if bld.env.WARNINGS:')
|
||||
for f in builder.commonWarnings():
|
||||
self.add(' common_flags += ["%s"]' % (f))
|
||||
self.add(' else:')
|
||||
for f in builder.commonNoWarnings():
|
||||
self.add(' common_flags += ["%s"]' % (f))
|
||||
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(' if len(bld.env.FREEBSD_OPTIONS) > 0:')
|
||||
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.cpuIncludes()))
|
||||
self.add(' includes += ["%s" % (i[2:].replace("@CPU@", bld.get_env()["RTEMS_ARCH"]))]')
|
||||
self.add(' if bld.get_env()["RTEMS_ARCH"] == "i386":')
|
||||
self.add(' for i in %r:' % (builder.cpuIncludes()))
|
||||
self.add(' includes += ["%s" % (i[2:].replace("@CPU@", "x86"))]')
|
||||
for i in builder.includes() + ['-I' + builder.buildInclude()]:
|
||||
self.add(' includes += ["%s"]' % (i[2:]))
|
||||
self.add('')
|
||||
self.add(' # Collect the libbsd uses')
|
||||
self.add(' libbsd_use = []')
|
||||
self.add('')
|
||||
|
||||
#
|
||||
# Support the existing Makefile based network configuration file.
|
||||
#
|
||||
self.add(' # Network test configuration')
|
||||
self.add(' if not os.path.exists(bld.env.NET_CONFIG):')
|
||||
self.add(' bld.fatal("network configuraiton \'%s\' not found" % (bld.env.NET_CONFIG))')
|
||||
self.add(' net_cfg_self_ip = None')
|
||||
self.add(' net_cfg_netmask = None')
|
||||
self.add(' net_cfg_peer_ip = None')
|
||||
self.add(' net_cfg_gateway_ip = None')
|
||||
self.add(' try:')
|
||||
self.add(' net_cfg_lines = open(bld.env.NET_CONFIG).readlines()')
|
||||
self.add(' except:')
|
||||
self.add(' bld.fatal("network configuraiton \'%s\' read failed" % (bld.env.NET_CONFIG))')
|
||||
self.add(' lc = 0')
|
||||
self.add(' for l in net_cfg_lines:')
|
||||
self.add(' lc += 1')
|
||||
self.add(' if l.strip().startswith("NET_CFG_"):')
|
||||
self.add(' ls = l.split("=")')
|
||||
self.add(' if len(ls) != 2:')
|
||||
self.add(' bld.fatal("network configuraiton \'%s\' parse error: %d: %s" % ' + \
|
||||
'(bld.env.NET_CONFIG, lc, l))')
|
||||
self.add(' lhs = ls[0].strip()')
|
||||
self.add(' rhs = ls[1].strip()')
|
||||
self.add(' if lhs == "NET_CFG_SELF_IP":')
|
||||
self.add(' net_cfg_self_ip = rhs')
|
||||
self.add(' if lhs == "NET_CFG_NETMASK":')
|
||||
self.add(' net_cfg_netmask = rhs')
|
||||
self.add(' if lhs == "NET_CFG_PEER_IP":')
|
||||
self.add(' net_cfg_peer_ip = rhs')
|
||||
self.add(' if lhs == "NET_CFG_GATEWAY_IP":')
|
||||
self.add(' net_cfg_gateway_ip = rhs')
|
||||
self.add(' bld(target = "testsuite/include/rtems/bsd/test/network-config.h",')
|
||||
self.add(' source = "testsuite/include/rtems/bsd/test/network-config.h.in",')
|
||||
self.add(' rule = "sed -e \'s/@NET_CFG_SELF_IP@/%s/\' ' + \
|
||||
'-e \'s/@NET_CFG_NETMASK@/%s/\' ' + \
|
||||
'-e \'s/@NET_CFG_PEER_IP@/%s/\' ' + \
|
||||
'-e \'s/@NET_CFG_GATEWAY_IP@/%s/\' < ${SRC} > ${TGT}" % ' + \
|
||||
'(net_cfg_self_ip, net_cfg_netmask, net_cfg_peer_ip, net_cfg_gateway_ip),')
|
||||
self.add(' update_outputs = True)')
|
||||
self.add('')
|
||||
|
||||
#
|
||||
# Add a copy rule for all headers where the install path and the source
|
||||
# path are not the same.
|
||||
#
|
||||
self.add(' # copy headers if necessary')
|
||||
self.add(' header_build_copy_paths = [')
|
||||
for hp in builder.headerPaths():
|
||||
if hp[2] != '' and not hp[0].endswith(hp[2]):
|
||||
self.add(' %s,' % (str(hp)))
|
||||
self.add(' ]')
|
||||
self.add(' for headers in header_build_copy_paths:')
|
||||
self.add(' target = os.path.join("%s", headers[2])' % (builder.buildInclude()))
|
||||
self.add(' start_dir = bld.path.find_dir(headers[0])')
|
||||
self.add(' for header in start_dir.ant_glob(headers[1]):')
|
||||
self.add(' relsourcepath = header.path_from(start_dir)')
|
||||
self.add(' targetheader = os.path.join(target, relsourcepath)')
|
||||
self.add(' bld(features = \'subst\',')
|
||||
self.add(' target = targetheader,')
|
||||
self.add(' source = header,')
|
||||
self.add(' is_copy = True)')
|
||||
self.add('')
|
||||
|
||||
#
|
||||
# Add the specific rule based builders for generating files.
|
||||
#
|
||||
if 'KVMSymbols' in data:
|
||||
kvmsymbols = data['KVMSymbols']
|
||||
if 'includes' in kvmsymbols['files']:
|
||||
includes = kvmsymbols['files']['includes']
|
||||
else:
|
||||
includes = []
|
||||
self.add(' # KVM Symbols')
|
||||
self.add(' bld(target = "%s",' % (kvmsymbols['files']['all']['default'][0]))
|
||||
self.add(' source = "rtemsbsd/rtems/generate_kvm_symbols",')
|
||||
self.add(' rule = host_shell + "./${SRC} > ${TGT}",')
|
||||
self.add(' update_outputs = True)')
|
||||
self.add(' bld.objects(target = "kvmsymbols",')
|
||||
self.add(' features = "c",')
|
||||
self.add(' cflags = cflags,')
|
||||
self.add(' includes = %r + includes,' % (includes))
|
||||
self.add(' source = "%s")' % (kvmsymbols['files']['all']['default'][0]))
|
||||
self.add(' libbsd_use += ["kvmsymbols"]')
|
||||
self.add('')
|
||||
|
||||
self.add(' bld.add_group()')
|
||||
|
||||
if 'RPCGen' in data:
|
||||
rpcgen = data['RPCGen']
|
||||
rpcname = rpcgen['files']['all']['default'][0][:-2]
|
||||
self.add(' # RPC Generation')
|
||||
self.add(' if bld.env.AUTO_REGEN:')
|
||||
self.add(' bld(target = "%s.h",' % (rpcname))
|
||||
self.add(' source = "%s.x",' % (rpcname))
|
||||
self.add(' rule = host_shell + "${RPCGEN} -h -o ${TGT} ${SRC}")')
|
||||
self.add('')
|
||||
|
||||
if 'RouteKeywords' in data:
|
||||
routekw = data['RouteKeywords']
|
||||
rkwname = routekw['files']['all']['default'][0]
|
||||
self.add(' # Route keywords')
|
||||
self.add(' if bld.env.AUTO_REGEN:')
|
||||
self.add(' rkw_rule = host_shell + "cat ${SRC} | ' + \
|
||||
'awk \'BEGIN { r = 0 } { if (NF == 1) ' + \
|
||||
'printf \\"#define\\\\tK_%%s\\\\t%%d\\\\n\\\\t{\\\\\\"%%s\\\\\\", K_%%s},\\\\n\\", ' + \
|
||||
'toupper($1), ++r, $1, toupper($1)}\' > ${TGT}"')
|
||||
self.add(' bld(target = "%s.h",' % (rkwname))
|
||||
self.add(' source = "%s",' % (rkwname))
|
||||
self.add(' rule = rkw_rule)')
|
||||
self.add('')
|
||||
|
||||
if 'lex' in data:
|
||||
lexes = data['lex']
|
||||
self.add(' # Lex')
|
||||
for l in sorted(lexes.keys()):
|
||||
lex = lexes[l]['all']['default']
|
||||
if 'cflags' in lex:
|
||||
lexDefines = [d[2:] for d in lex['cflags']]
|
||||
else:
|
||||
lexDefines = []
|
||||
if 'includes' in lex:
|
||||
lexIncludes = lex['includes']
|
||||
else:
|
||||
lexIncludes = []
|
||||
self.add(' if bld.env.AUTO_REGEN:')
|
||||
self.add(' bld(target = "%s.c",' % (lex['file'][:-2]))
|
||||
self.add(' source = "%s",' % (lex['file']))
|
||||
self.add(' rule = host_shell + "${LEX} -P %s -t ${SRC} | ' % (lex['sym']) + \
|
||||
'sed -e \'/YY_BUF_SIZE/s/16384/1024/\' > ${TGT}")')
|
||||
self.add(' bld.objects(target = "lex_%s",' % (lex['sym']))
|
||||
self.add(' features = "c",')
|
||||
self.add(' cflags = cflags,')
|
||||
self.add(' includes = %r + includes,' % (lexIncludes))
|
||||
self.add(' defines = defines + %r,' % (lexDefines))
|
||||
self.add(' source = "%s.c")' % (lex['file'][:-2]))
|
||||
self.add(' libbsd_use += ["lex_%s"]' % (lex['sym']))
|
||||
self.add('')
|
||||
|
||||
if 'yacc' in data:
|
||||
yaccs = data['yacc']
|
||||
self.add(' # Yacc')
|
||||
for y in sorted(yaccs.keys()):
|
||||
yacc = yaccs[y]['all']['default']
|
||||
yaccFile = yacc['file']
|
||||
if yacc['sym'] is not None:
|
||||
yaccSym = yacc['sym']
|
||||
else:
|
||||
yaccSym = os.path.basename(yaccFile)[:-2]
|
||||
yaccHeader = '%s/%s' % (os.path.dirname(yaccFile), yacc['header'])
|
||||
if 'cflags' in yacc:
|
||||
yaccDefines = [d[2:] for d in yacc['cflags']]
|
||||
else:
|
||||
yaccDefines = []
|
||||
if 'includes' in yacc:
|
||||
yaccIncludes = yacc['includes']
|
||||
else:
|
||||
yaccIncludes = []
|
||||
self.add(' if bld.env.AUTO_REGEN:')
|
||||
self.add(' bld(target = "%s.c",' % (yaccFile[:-2]))
|
||||
self.add(' source = "%s",' % (yaccFile))
|
||||
self.add(' rule = host_shell + "${YACC} -b %s -d -p %s ${SRC} && ' % \
|
||||
(yaccSym, yaccSym) + \
|
||||
'sed -e \'/YY_BUF_SIZE/s/16384/1024/\' < %s.tab.c > ${TGT} && ' % (yaccSym) + \
|
||||
'rm -f %s.tab.c && mv %s.tab.h %s")' % (yaccSym, yaccSym, yaccHeader))
|
||||
self.add(' bld.objects(target = "yacc_%s",' % (yaccSym))
|
||||
self.add(' features = "c",')
|
||||
self.add(' cflags = cflags,')
|
||||
self.add(' includes = %r + includes,' % (yaccIncludes))
|
||||
self.add(' defines = defines + %r,' % (yaccDefines))
|
||||
self.add(' source = "%s.c")' % (yaccFile[:-2]))
|
||||
self.add(' libbsd_use += ["yacc_%s"]' % (yaccSym))
|
||||
self.add('')
|
||||
|
||||
#
|
||||
# We have 'm' different sets of flags and there can be 'n' cpus
|
||||
# specific files for those flags.
|
||||
#
|
||||
objs = 0
|
||||
self.add(' # Objects built with different CFLAGS')
|
||||
sources = sorted(data['sources'])
|
||||
if 'default' in sources:
|
||||
sources.remove('default')
|
||||
for flags in sources:
|
||||
objs += 1
|
||||
build = data['sources'][flags]
|
||||
_sourceList(' objs%02d_source' % objs, build['all'])
|
||||
archs = sorted(build)
|
||||
for i in ['all', 'cflags', 'includes']:
|
||||
if i in archs:
|
||||
archs.remove(i)
|
||||
for arch in archs:
|
||||
self.add(' if bld.get_env()["RTEMS_ARCH"] == "%s":' % arch)
|
||||
_sourceList(' objs%02d_source' % objs, build[arch], append = True)
|
||||
if 'cflags' in build:
|
||||
defines = [d[2:] for d in build['cflags']]
|
||||
else:
|
||||
defines = []
|
||||
if 'includes' in build:
|
||||
includes = build['includes']
|
||||
else:
|
||||
includes = []
|
||||
self.add(' bld.objects(target = "objs%02d",' % (objs))
|
||||
self.add(' features = "c",')
|
||||
self.add(' cflags = cflags,')
|
||||
self.add(' includes = %r + includes,' % (sorted(includes)))
|
||||
self.add(' defines = defines + %r,' % (sorted(defines)))
|
||||
self.add(' source = objs%02d_source)' % objs)
|
||||
self.add(' libbsd_use += ["objs%02d"]' % (objs))
|
||||
self.add('')
|
||||
|
||||
#
|
||||
# We hold the 'default' cflags set of files to the end to create the
|
||||
# static library with.
|
||||
#
|
||||
build = data['sources']['default']
|
||||
_sourceList(' source', build['all'])
|
||||
archs = sorted(build)
|
||||
archs.remove('all')
|
||||
for arch in archs:
|
||||
self.add(' if bld.get_env()["RTEMS_ARCH"] == "%s":' % arch)
|
||||
_sourceList(' source', build[arch], append = True)
|
||||
self.add(' bld.stlib(target = "bsd",')
|
||||
self.add(' features = "c cxx",')
|
||||
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('')
|
||||
|
||||
#
|
||||
# Header file collector.
|
||||
#
|
||||
self.add(' # Installs. ')
|
||||
self.add(' bld.install_files("${PREFIX}/" + rtems.arch_bsp_lib_path(bld.env.RTEMS_VERSION, bld.env.RTEMS_ARCH_BSP), ["libbsd.a"])')
|
||||
headerPaths = builder.headerPaths()
|
||||
self.add(' header_paths = [%s,' % (headerPathSpec(headerPaths[0])))
|
||||
for hp in headerPaths[1:-1]:
|
||||
self.add(' %s,' % (headerPathSpec(hp)))
|
||||
self.add(' %s]' % (headerPathSpec(headerPaths[-1])))
|
||||
self.add(' for headers in header_paths:')
|
||||
self.add(' ipath = os.path.join(rtems.arch_bsp_include_path(bld.env.RTEMS_VERSION, bld.env.RTEMS_ARCH_BSP), headers[2])')
|
||||
self.add(' start_dir = bld.path.find_dir(headers[0])')
|
||||
self.add(' if start_dir != None:')
|
||||
self.add(' bld.install_files("${PREFIX}/" + ipath,')
|
||||
self.add(' start_dir.ant_glob(headers[1]),')
|
||||
self.add(' cwd = start_dir,')
|
||||
self.add(' relative_trick = True)')
|
||||
self.add('')
|
||||
|
||||
self.add(' # Tests')
|
||||
tests = data['tests']
|
||||
for testName in sorted(tests):
|
||||
test = data['tests'][testName]['all']
|
||||
block = 0
|
||||
files = []
|
||||
for cfg in test:
|
||||
if cfg != 'default':
|
||||
cs = ''
|
||||
ors = ''
|
||||
for c in cfg.split(' '):
|
||||
cs += '%s bld.env["HAVE_%s"]' % (ors, c)
|
||||
ors = ' and'
|
||||
self.add(' if%s:' % (cs))
|
||||
block = 1
|
||||
files = ['testsuite/%s/%s.c' % (testName, f) \
|
||||
for f in test[cfg]['files']]
|
||||
indent = ' ' * block * 4
|
||||
_sourceList('%s test_%s' % (indent, testName), files)
|
||||
self.add('%s bld.program(target = "%s.exe",' % (indent, testName))
|
||||
self.add('%s features = "cprogram",' % (indent))
|
||||
self.add('%s cflags = cflags,' % (indent))
|
||||
self.add('%s includes = includes,' % (indent))
|
||||
self.add('%s source = test_%s,' % (indent, testName))
|
||||
self.add('%s use = ["bsd"],' % (indent))
|
||||
self.add('%s lib = ["m", "z"],' % (indent))
|
||||
self.add('%s install_path = None)' % (indent))
|
||||
self.add('')
|
||||
|
||||
self.write()
|
644
waf_libbsd.py
Normal file
644
waf_libbsd.py
Normal file
@ -0,0 +1,644 @@
|
||||
#
|
||||
# Copyright (c) 2015-2018 Chris Johns <chrisj@rtems.org>. All rights reserved.
|
||||
#
|
||||
# Copyright (c) 2009-2015 embedded brains GmbH. All rights reserved.
|
||||
#
|
||||
# embedded brains GmbH
|
||||
# Dornierstr. 4
|
||||
# 82178 Puchheim
|
||||
# Germany
|
||||
# <info@embedded-brains.de>
|
||||
#
|
||||
# Copyright (c) 2012 OAR Corporation. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
import builder
|
||||
|
||||
import rtems_waf.rtems as rtems
|
||||
|
||||
windows = os.name == 'nt'
|
||||
|
||||
if windows:
|
||||
host_shell = 'sh -c '
|
||||
else:
|
||||
host_shell = ''
|
||||
|
||||
def _cflagsIncludes(cflags, includes):
|
||||
if type(cflags) is not list:
|
||||
if cflags is not None:
|
||||
_cflags = cflags.split(' ')
|
||||
else:
|
||||
_cflags = [None]
|
||||
else:
|
||||
_cflags = cflags
|
||||
if type(includes) is not list:
|
||||
_includes = [includes]
|
||||
else:
|
||||
_includes = includes
|
||||
return _cflags, _includes
|
||||
|
||||
class SourceFileFragmentComposer(builder.BuildSystemFragmentComposer):
|
||||
|
||||
def __init__(self, cflags = "default", includes = None):
|
||||
self.cflags, self.includes = _cflagsIncludes(cflags, includes)
|
||||
|
||||
def compose(self, path):
|
||||
if None in self.includes:
|
||||
flags = self.cflags
|
||||
else:
|
||||
flags = self.cflags + self.includes
|
||||
return ['sources', flags, ('default', None)], [path], self.cflags, self.includes
|
||||
|
||||
class SourceFileIfHeaderComposer(SourceFileFragmentComposer):
|
||||
|
||||
def __init__(self, headers, cflags = "default", includes = None):
|
||||
if headers is not list:
|
||||
headers = [headers]
|
||||
self.headers = headers
|
||||
super(SourceFileIfHeaderComposer, self).__init__(cflags = cflags, includes = includes)
|
||||
|
||||
def compose(self, path):
|
||||
r = SourceFileFragmentComposer.compose(self, path)
|
||||
define_keys = ''
|
||||
for h in self.headers:
|
||||
h = h.upper()
|
||||
for c in '\/-.':
|
||||
h = h.replace(c, '_')
|
||||
define_keys += ' ' + h
|
||||
r[0][2] = (define_keys.strip(), self.headers)
|
||||
return r
|
||||
|
||||
class TestFragementComposer(builder.BuildSystemFragmentComposer):
|
||||
|
||||
def __init__(self, testName, fileFragments, runTest = True, netTest = False):
|
||||
self.testName = testName
|
||||
self.fileFragments = fileFragments
|
||||
self.runTest = runTest
|
||||
self.netTest = netTest
|
||||
|
||||
def compose(self, path):
|
||||
return ['tests', self.testName, ('default', None)], { 'files': self.fileFragments,
|
||||
'run': self.runTest,
|
||||
'net': self.netTest }
|
||||
|
||||
class TestIfHeaderComposer(TestFragementComposer):
|
||||
|
||||
def __init__(self, testName, headers, fileFragments, runTest = True, netTest = False):
|
||||
if headers is not list:
|
||||
headers = [headers]
|
||||
self.headers = headers
|
||||
super(TestIfHeaderComposer, self).__init__(testName, fileFragments,
|
||||
runTest = runTest, netTest = netTest)
|
||||
|
||||
def compose(self, path):
|
||||
r = TestFragementComposer.compose(self, path)
|
||||
define_keys = ''
|
||||
for h in self.headers:
|
||||
h = h.upper()
|
||||
for c in '\/-.':
|
||||
h = h.replace(c, '_')
|
||||
define_keys += ' ' + h
|
||||
r[0][2] = (define_keys.strip(), self.headers)
|
||||
return r
|
||||
|
||||
class KVMSymbolsFragmentComposer(builder.BuildSystemFragmentComposer):
|
||||
|
||||
def compose(self, path):
|
||||
return ['KVMSymbols', 'files', ('default', None)], [path], self.includes
|
||||
|
||||
class RPCGENFragmentComposer(builder.BuildSystemFragmentComposer):
|
||||
|
||||
def compose(self, path):
|
||||
return ['RPCGen', 'files', ('default', None)], [path]
|
||||
|
||||
class RouteKeywordsFragmentComposer(builder.BuildSystemFragmentComposer):
|
||||
|
||||
def compose(self, path):
|
||||
return ['RouteKeywords', 'files', ('default', None)], [path]
|
||||
|
||||
class LexFragmentComposer(builder.BuildSystemFragmentComposer):
|
||||
|
||||
def __init__(self, sym, dep, cflags = None, includes = None):
|
||||
self.sym = sym
|
||||
self.dep = dep
|
||||
self.cflags, self.includes = _cflagsIncludes(cflags, includes)
|
||||
|
||||
def compose(self, path):
|
||||
d = { 'file': path,
|
||||
'sym': self.sym,
|
||||
'dep': self.dep }
|
||||
if None not in self.cflags:
|
||||
d['cflags'] = self.cflags
|
||||
if None not in self.includes:
|
||||
d['includes'] = self.includes
|
||||
return ['lex', path, ('default', None)], d
|
||||
|
||||
class YaccFragmentComposer(builder.BuildSystemFragmentComposer):
|
||||
|
||||
def __init__(self, sym, header, cflags = None, includes = None):
|
||||
self.sym = sym
|
||||
self.header = header
|
||||
self.cflags, self.includes = _cflagsIncludes(cflags, includes)
|
||||
|
||||
def compose(self, path):
|
||||
d = { 'file': path,
|
||||
'sym': self.sym,
|
||||
'header': self.header }
|
||||
if None not in self.cflags:
|
||||
d['cflags'] = self.cflags
|
||||
if None not in self.includes:
|
||||
d['includes'] = self.includes
|
||||
return ['yacc', path, ('default', None)], d
|
||||
|
||||
#
|
||||
# The waf builder for libbsd.
|
||||
#
|
||||
class Builder(builder.ModuleManager):
|
||||
|
||||
def __init__(self, trace = False):
|
||||
super(Builder, self).__init__()
|
||||
self.trace = trace
|
||||
self.data = {}
|
||||
|
||||
@staticmethod
|
||||
def _sourceList(bld, files):
|
||||
sources = []
|
||||
if type(files) is dict:
|
||||
for cfg in files:
|
||||
if cfg in ['cflags', 'includes']:
|
||||
continue
|
||||
if cfg != 'default':
|
||||
for c in cfg.split(' '):
|
||||
if not bld.env['HAVE_%s' % (c)]:
|
||||
continue
|
||||
sources += sorted(files[cfg])
|
||||
else:
|
||||
sources = sorted(files)
|
||||
return sources
|
||||
|
||||
def setGenerators(self):
|
||||
#
|
||||
# Called when the builder.ModuleManager.__init__ is run
|
||||
#
|
||||
self.generator['convert'] = builder.Converter
|
||||
self.generator['no-convert'] = builder.NoConverter
|
||||
self.generator['from-FreeBSD-to-RTEMS-UserSpaceSourceConverter'] = builder.FromFreeBSDToRTEMSUserSpaceSourceConverter
|
||||
self.generator['from-RTEMS-To-FreeBSD-SourceConverter'] = builder.FromRTEMSToFreeBSDSourceConverter
|
||||
self.generator['buildSystemFragmentComposer'] = builder.BuildSystemFragmentComposer
|
||||
|
||||
self.generator['file'] = builder.File
|
||||
|
||||
self.generator['path'] = builder.PathComposer
|
||||
self.generator['freebsd-path'] = builder.FreeBSDPathComposer
|
||||
self.generator['rtems-path'] = builder.RTEMSPathComposer
|
||||
self.generator['cpu-path'] = builder.CPUDependentFreeBSDPathComposer
|
||||
self.generator['target-src-cpu--path'] = builder.TargetSourceCPUDependentPathComposer
|
||||
|
||||
self.generator['source'] = SourceFileFragmentComposer
|
||||
self.generator['test'] = TestFragementComposer
|
||||
self.generator['kvm-symbols'] = KVMSymbolsFragmentComposer
|
||||
self.generator['rpc-gen'] = RPCGENFragmentComposer
|
||||
self.generator['route-keywords'] = RouteKeywordsFragmentComposer
|
||||
self.generator['lex'] = LexFragmentComposer
|
||||
self.generator['yacc'] = YaccFragmentComposer
|
||||
|
||||
self.generator['source-if-header'] = SourceFileIfHeaderComposer
|
||||
self.generator['test-if-header'] = TestIfHeaderComposer
|
||||
|
||||
def generate(self, rtems_version):
|
||||
|
||||
def _dataInsert(data, cpu, frag):
|
||||
#
|
||||
# The default handler returns an empty string. Skip it.
|
||||
#
|
||||
if type(frag) is not str:
|
||||
# Start at the top of the tree
|
||||
d = data
|
||||
path = frag[0]
|
||||
if path[0] not in d:
|
||||
d[path[0]] = {}
|
||||
# Select the sub-part of the tree as the compile options
|
||||
# specialise how files are built.
|
||||
d = d[path[0]]
|
||||
if type(path[1]) is list:
|
||||
p = ' '.join(path[1])
|
||||
else:
|
||||
p = path[1]
|
||||
if p not in d:
|
||||
d[p] = {}
|
||||
d = d[p]
|
||||
if cpu not in d:
|
||||
d[cpu] = { }
|
||||
config = frag[0][2][0]
|
||||
if config != 'default':
|
||||
if 'configure' not in data:
|
||||
data['configure'] = { }
|
||||
data['configure'][config] = frag[0][2][1]
|
||||
if type(frag[1]) is list:
|
||||
if config not in d[cpu]:
|
||||
d[cpu][config] = []
|
||||
d[cpu][config] += frag[1]
|
||||
else:
|
||||
d[cpu][config] = frag[1]
|
||||
#
|
||||
# The CPU is for files and the flags and includes are common.
|
||||
#
|
||||
if len(frag) > 3:
|
||||
if 'cflags' not in d:
|
||||
d['cflags'] = []
|
||||
d['cflags'] += frag[2]
|
||||
d['cflags'] = list(set(d['cflags']))
|
||||
if len(frag) >= 3 and None not in frag[-1]:
|
||||
if 'includes' not in d:
|
||||
d['includes'] = []
|
||||
d['includes'] += frag[-1]
|
||||
d['includes'] = list(set(d['includes']))
|
||||
|
||||
self.data = {}
|
||||
|
||||
for mn in self.getModules():
|
||||
m = self[mn]
|
||||
if m.conditionalOn == "none":
|
||||
for f in m.files:
|
||||
_dataInsert(self.data, 'all', f.getFragment())
|
||||
for cpu, files in sorted(m.cpuDependentSourceFiles.items()):
|
||||
for f in files:
|
||||
_dataInsert(self.data, cpu, f.getFragment())
|
||||
|
||||
if self.trace:
|
||||
import pprint
|
||||
pprint.pprint(self.data)
|
||||
|
||||
def init(self, ctx):
|
||||
pass
|
||||
|
||||
def options(self, opt):
|
||||
pass
|
||||
|
||||
def bsp_configure(self, conf, arch_bsp):
|
||||
if 'configure' in self.data:
|
||||
for cfg in self.data['configure']:
|
||||
for h in self.data['configure'][cfg]:
|
||||
conf.check(header_name = h,
|
||||
features = "c",
|
||||
includes = conf.env.IFLAGS,
|
||||
mandatory = False)
|
||||
|
||||
def configure(self, conf):
|
||||
pass
|
||||
|
||||
def build(self, bld):
|
||||
#
|
||||
# Localize the config.
|
||||
#
|
||||
config = self.getConfiguration()
|
||||
|
||||
#
|
||||
#
|
||||
# C/C++ flags
|
||||
#
|
||||
common_flags = []
|
||||
common_flags += ['-O%s' % (bld.env.OPTIMIZATION)]
|
||||
if 'common-flags' in config:
|
||||
common_flags += [f for f in config['common-flags']]
|
||||
if bld.env.WARNINGS and 'common-warnings' in config:
|
||||
common_flags += [f for f in config['common-warnings']]
|
||||
elif 'common-no-warnings' in config:
|
||||
common_flags += [f for f in config['common-no-warnings']]
|
||||
if 'cflags' in config:
|
||||
cflags = config['cflags'] + common_flags
|
||||
if 'cxxflags' in config:
|
||||
cxxflags = config['cxxflags'] + common_flags
|
||||
|
||||
#
|
||||
# Defines
|
||||
#
|
||||
defines = []
|
||||
if len(bld.env.FREEBSD_OPTIONS) > 0:
|
||||
for o in bld.env.FREEBSD_OPTIONS.split(','):
|
||||
defines += ['%s=1' % (o.strip().upper())]
|
||||
|
||||
#
|
||||
# Include paths
|
||||
#
|
||||
includes = []
|
||||
if 'cpu-include-paths' in config:
|
||||
cpu = bld.get_env()['RTEMS_ARCH']
|
||||
if cpu == "i386":
|
||||
cpu = 'x86'
|
||||
for i in config['cpu-include-paths']:
|
||||
includes += [i.replace('@CPU@', cpu)]
|
||||
if 'include-paths' in config:
|
||||
includes += config['include-paths']
|
||||
if 'build-include-path' in config:
|
||||
includes += config['build-include-path']
|
||||
|
||||
#
|
||||
# Collect the libbsd uses
|
||||
#
|
||||
libbsd_use = []
|
||||
|
||||
#
|
||||
# Network test configuration
|
||||
#
|
||||
if not os.path.exists(bld.env.NET_CONFIG):
|
||||
bld.fatal('network configuraiton \'%s\' not found' % (bld.env.NET_CONFIG))
|
||||
tags = [ 'NET_CFG_SELF_IP',
|
||||
'NET_CFG_NETMASK',
|
||||
'NET_CFG_PEER_IP',
|
||||
'NET_CFG_GATEWAY_IP' ]
|
||||
try:
|
||||
net_cfg_lines = open(bld.env.NET_CONFIG).readlines()
|
||||
except:
|
||||
bld.fatal('network configuraiton \'%s\' read failed' % (bld.env.NET_CONFIG))
|
||||
lc = 0
|
||||
for l in net_cfg_lines:
|
||||
lc += 1
|
||||
if l.strip().startswith('NET_CFG_'):
|
||||
ls = l.split('=')
|
||||
if len(ls) != 2:
|
||||
bld.fatal('network configuraiton \'%s\' ' + \
|
||||
'parse error: %d: %s' % (bld.env.NET_CONFIG, lc, l))
|
||||
lhs = ls[0].strip()
|
||||
rhs = ls[1].strip()
|
||||
sed = 'sed '
|
||||
for t in tags:
|
||||
if lhs == t:
|
||||
sed += "-e 's/@%s@/%s/'" % (t, rhs)
|
||||
bld(target = "testsuite/include/rtems/bsd/test/network-config.h",
|
||||
source = "testsuite/include/rtems/bsd/test/network-config.h.in",
|
||||
rule = sed + " < ${SRC} > ${TGT}",
|
||||
update_outputs = True)
|
||||
|
||||
#
|
||||
# Add a copy rule for all headers where the install path and the source
|
||||
# path are not the same.
|
||||
#
|
||||
if 'header-paths' in config:
|
||||
header_build_copy_paths = [
|
||||
hp for hp in config['header-paths'] if hp[2] != '' and not hp[0].endswith(hp[2])
|
||||
]
|
||||
for headers in header_build_copy_paths:
|
||||
target = os.path.join("build-include", headers[2])
|
||||
start_dir = bld.path.find_dir(headers[0])
|
||||
for header in start_dir.ant_glob(headers[1]):
|
||||
relsourcepath = header.path_from(start_dir)
|
||||
targetheader = os.path.join(target, relsourcepath)
|
||||
bld(features = 'subst',
|
||||
target = targetheader,
|
||||
source = header,
|
||||
is_copy = True)
|
||||
|
||||
#
|
||||
# Add the specific rule based builders
|
||||
#
|
||||
|
||||
#
|
||||
# KVM Symbols
|
||||
#
|
||||
if 'KVMSymbols' in self.data:
|
||||
kvmsymbols = self.data['KVMSymbols']
|
||||
if 'includes' in kvmsymbols['files']:
|
||||
kvmsymbols_includes = kvmsymbols['files']['includes']
|
||||
else:
|
||||
kvmsymbols_includes = []
|
||||
bld(target = kvmsymbols['files']['all']['default'][0],
|
||||
source = 'rtemsbsd/rtems/generate_kvm_symbols',
|
||||
rule = host_shell + './${SRC} > ${TGT}',
|
||||
update_outputs = True)
|
||||
bld.objects(target = 'kvmsymbols',
|
||||
features = 'c',
|
||||
cflags = cflags,
|
||||
includes = kvmsymbols_includes + includes,
|
||||
source = kvmsymbols['files']['all']['default'][0])
|
||||
libbsd_use += ["kvmsymbols"]
|
||||
|
||||
bld.add_group()
|
||||
|
||||
#
|
||||
# RPC Generation
|
||||
#
|
||||
if 'RPCGen' in self.data:
|
||||
if bld.env.AUTO_REGEN:
|
||||
rpcgen = self.data['RPCGen']
|
||||
rpcname = rpcgen['files']['all']['default'][0][:-2]
|
||||
bld(target = rpcname + '.h',
|
||||
source = y + '.x',
|
||||
rule = host_shell + '${RPCGEN} -h -o ${TGT} ${SRC}')
|
||||
|
||||
#
|
||||
# Route keywords
|
||||
#
|
||||
if 'RouteKeywords' in self.data:
|
||||
if bld.env.AUTO_REGEN:
|
||||
routekw = self.data['RouteKeywords']
|
||||
rkwname = routekw['files']['all']['default'][0]
|
||||
rkw_rule = host_shell + 'cat ${SRC} | ' + \
|
||||
'awk \'BEGIN { r = 0 } { if (NF == 1) ' + \
|
||||
'printf \\"#define\\\\tK_%%s\\\\t%%d\\\\n\\\\t{\\\\\\"%%s\\\\\\", K_%%s},\\\\n\\", ' + \
|
||||
'toupper($1), ++r, $1, toupper($1)}\' > ${TGT}'
|
||||
bld(target = rkwname + '.h',
|
||||
source = rkwname,
|
||||
rule = rkw_rule)
|
||||
|
||||
#
|
||||
# Lex
|
||||
#
|
||||
if 'lex' in self.data:
|
||||
lexes = self.data['lex']
|
||||
for l in sorted(lexes.keys()):
|
||||
lex = lexes[l]['all']['default']
|
||||
if 'cflags' in lex:
|
||||
lexDefines = [d[2:] for d in lex['cflags']]
|
||||
else:
|
||||
lexDefines = []
|
||||
if 'includes' in lex:
|
||||
lexIncludes = lex['includes']
|
||||
else:
|
||||
lexIncludes = []
|
||||
lex_rule = host_shell + '${LEX} -P ' + lex['sym'] + ' -t ${SRC} | ' + \
|
||||
'sed -e \'/YY_BUF_SIZE/s/16384/1024/\' > ${TGT}")'
|
||||
if bld.env.AUTO_REGEN:
|
||||
bld(target = lex['file'][:-2]+ '.c',
|
||||
source = lex['file'],
|
||||
rule = lex_rule)
|
||||
bld.objects(target = 'lex_%s' % (lex['sym']),
|
||||
features = 'c',
|
||||
cflags = cflags,
|
||||
includes = lexIncludes + includes,
|
||||
defines = defines + lexDefines,
|
||||
source = lex['file'][:-2] + '.c')
|
||||
libbsd_use += ['lex_%s' % (lex['sym'])]
|
||||
|
||||
#
|
||||
# Yacc
|
||||
#
|
||||
if 'yacc' in self.data:
|
||||
yaccs = self.data['yacc']
|
||||
for y in sorted(yaccs.keys()):
|
||||
yacc = yaccs[y]['all']['default']
|
||||
yaccFile = yacc['file']
|
||||
if yacc['sym'] is not None:
|
||||
yaccSym = yacc['sym']
|
||||
else:
|
||||
yaccSym = os.path.basename(yaccFile)[:-2]
|
||||
yaccHeader = '%s/%s' % (os.path.dirname(yaccFile), yacc['header'])
|
||||
if 'cflags' in yacc:
|
||||
yaccDefines = [d[2:] for d in yacc['cflags']]
|
||||
else:
|
||||
yaccDefines = []
|
||||
if 'includes' in yacc:
|
||||
yaccIncludes = yacc['includes']
|
||||
else:
|
||||
yaccIncludes = []
|
||||
yacc_rule = host_shell + '${YACC} -b ' + yaccSym + \
|
||||
' -d -p ' + yaccSym + ' ${SRC} && ' + \
|
||||
'sed -e \'/YY_BUF_SIZE/s/16384/1024/\' < ' + yaccSym + '.tab.c > ${TGT} && ' + \
|
||||
'rm -f ' + yaccSym + '.tab.c && mv ' + yaccSym + '.tab.h ' + yaccHeader
|
||||
if bld.env.AUTO_REGEN:
|
||||
bld(target = yaccFile[:-2] + '.c',
|
||||
source = yaccFile,
|
||||
rule = yacc_rule)
|
||||
bld.objects(target = 'yacc_%s' % (yaccSym),
|
||||
features = 'c',
|
||||
cflags = cflags,
|
||||
includes = yaccIncludes + includes,
|
||||
defines = defines + yaccDefines,
|
||||
source = yaccFile[:-2] + '.c')
|
||||
libbsd_use += ['yacc_%s' % (yaccSym)]
|
||||
|
||||
#
|
||||
# We have 'm' different sets of flags and there can be 'n' cpus
|
||||
# specific files for those flags.
|
||||
#
|
||||
objs = 0
|
||||
sources = sorted(self.data['sources'])
|
||||
if 'default' in sources:
|
||||
sources.remove('default')
|
||||
for flags in sources:
|
||||
objs += 1
|
||||
build = self.data['sources'][flags]
|
||||
target = 'objs%02d' % (objs)
|
||||
bld_sources = Builder._sourceList(bld, build['all'])
|
||||
archs = sorted(build)
|
||||
for i in ['all', 'cflags', 'includes']:
|
||||
if i in archs:
|
||||
archs.remove(i)
|
||||
for arch in archs:
|
||||
if bld.get_env()['RTEMS_ARCH'] == arch:
|
||||
bld_sources += Builder._sourceList(bld, build[arch])
|
||||
if 'cflags' in build:
|
||||
bld_defines = [d[2:] for d in build['cflags']]
|
||||
else:
|
||||
bld_defines = []
|
||||
if 'includes' in build:
|
||||
bld_includes = build['includes']
|
||||
else:
|
||||
bld_includes = []
|
||||
bld.objects(target = target,
|
||||
features = 'c',
|
||||
cflags = cflags,
|
||||
includes = sorted(bld_includes) + includes,
|
||||
defines = defines + sorted(bld_defines),
|
||||
source = bld_sources)
|
||||
libbsd_use += [target]
|
||||
|
||||
#
|
||||
# We hold the 'default' cflags set of files to the end to create the
|
||||
# static library with.
|
||||
#
|
||||
build = self.data['sources']['default']
|
||||
bld_sources = Builder._sourceList(bld, build['all'])
|
||||
archs = sorted(build)
|
||||
archs.remove('all')
|
||||
for arch in archs:
|
||||
if bld.get_env()['RTEMS_ARCH'] == arch:
|
||||
bld_sources += Builder._sourceList(bld, build[arch])
|
||||
bld.stlib(target = 'bsd',
|
||||
features = 'c cxx',
|
||||
cflags = cflags,
|
||||
cxxflags = cxxflags,
|
||||
includes = includes,
|
||||
defines = defines,
|
||||
source = bld_sources,
|
||||
use = libbsd_use)
|
||||
|
||||
#
|
||||
# Installs.
|
||||
#
|
||||
# Header file collector.
|
||||
#
|
||||
arch_lib_path = rtems.arch_bsp_lib_path(bld.env.RTEMS_VERSION,
|
||||
bld.env.RTEMS_ARCH_BSP)
|
||||
arch_inc_path = rtems.arch_bsp_include_path(bld.env.RTEMS_VERSION,
|
||||
bld.env.RTEMS_ARCH_BSP)
|
||||
|
||||
bld.install_files("${PREFIX}/" + arch_lib_path, ["libbsd.a"])
|
||||
|
||||
if 'header-paths' in config:
|
||||
headerPaths = config['header-paths']
|
||||
cpu = bld.get_env()['RTEMS_ARCH']
|
||||
if cpu == "i386":
|
||||
cpu = 'x86'
|
||||
for headers in headerPaths:
|
||||
# Get the dest path
|
||||
ipath = os.path.join(arch_inc_path, headers[2])
|
||||
start_dir = bld.path.find_dir(headers[0].replace('@CPU@', cpu))
|
||||
if start_dir != None:
|
||||
bld.install_files("${PREFIX}/" + ipath,
|
||||
start_dir.ant_glob(headers[1]),
|
||||
cwd = start_dir,
|
||||
relative_trick = True)
|
||||
|
||||
#
|
||||
# Tests
|
||||
#
|
||||
tests = self.data['tests']
|
||||
for testName in sorted(tests):
|
||||
test = self.data['tests'][testName]['all']
|
||||
test_source = []
|
||||
for cfg in test:
|
||||
build_test = True
|
||||
if cfg != 'default':
|
||||
for c in cfg.split(' '):
|
||||
if not bld.env['HAVE_%s' % (c)]:
|
||||
build_test = False
|
||||
break
|
||||
if build_test:
|
||||
test_sources = ['testsuite/%s/%s.c' % (testName, f) \
|
||||
for f in test[cfg]['files']]
|
||||
if build_test:
|
||||
bld.program(target = '%s.exe' % (testName),
|
||||
features = 'cprogram',
|
||||
cflags = cflags,
|
||||
includes = includes,
|
||||
source = test_sources,
|
||||
use = ['bsd'],
|
||||
lib = ['m', 'z'],
|
||||
install_path = None)
|
27
wscript
27
wscript
@ -41,13 +41,25 @@ except:
|
||||
import sys
|
||||
sys.exit(1)
|
||||
|
||||
import libbsd_waf
|
||||
import libbsd
|
||||
import waf_libbsd
|
||||
|
||||
builder = None
|
||||
|
||||
def create_builder():
|
||||
global builder
|
||||
if builder is None:
|
||||
builder = waf_libbsd.Builder()
|
||||
libbsd.load(builder)
|
||||
builder.generate(rtems_version)
|
||||
|
||||
def init(ctx):
|
||||
create_builder();
|
||||
rtems.init(ctx, version = rtems_version, long_commands = True)
|
||||
libbsd_waf.init(ctx)
|
||||
builder.init(ctx)
|
||||
|
||||
def options(opt):
|
||||
create_builder();
|
||||
rtems.options(opt)
|
||||
opt.add_option("--enable-auto-regen",
|
||||
action = "store_true",
|
||||
@ -73,18 +85,20 @@ def options(opt):
|
||||
default = "2",
|
||||
dest = "optimization",
|
||||
help = "Set optimization level to OPTIMIZATION (-On compiler flag). Default is 2 (-O2).")
|
||||
libbsd_waf.options(opt)
|
||||
builder.options(opt)
|
||||
|
||||
def bsp_configure(conf, arch_bsp):
|
||||
create_builder();
|
||||
conf.check(header_name = "dlfcn.h", features = "c")
|
||||
conf.check(header_name = "rtems/pci.h", features = "c", mandatory = False)
|
||||
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")
|
||||
libbsd_waf.bsp_configure(conf, arch_bsp)
|
||||
builder.bsp_configure(conf, arch_bsp)
|
||||
|
||||
def configure(conf):
|
||||
create_builder();
|
||||
if conf.options.auto_regen:
|
||||
conf.find_program("lex", mandatory = True)
|
||||
conf.find_program("rpcgen", mandatory = True)
|
||||
@ -95,8 +109,9 @@ def configure(conf):
|
||||
conf.env.FREEBSD_OPTIONS =conf.options.freebsd_options
|
||||
conf.env.OPTIMIZATION = conf.options.optimization
|
||||
rtems.configure(conf, bsp_configure)
|
||||
libbsd_waf.configure(conf)
|
||||
builder.configure(conf)
|
||||
|
||||
def build(bld):
|
||||
create_builder();
|
||||
rtems.build(bld)
|
||||
libbsd_waf.build(bld)
|
||||
builder.build(bld)
|
||||
|
Loading…
x
Reference in New Issue
Block a user