waf: Reformat to PEP8 using yapf

This commit is contained in:
Chris Johns 2020-09-01 14:01:14 +10:00
parent d2d3fabf30
commit 7afbccd8d7
3 changed files with 515 additions and 354 deletions

View File

@ -1,5 +1,8 @@
# # SPDX-License-Identifier: BSD-2-Clause
# Copyright (c) 2015-2016 Chris Johns <chrisj@rtems.org>. All rights reserved. '''Manage the libbsd build configuration data.
'''
# Copyright (c) 2015, 2020 Chris Johns <chrisj@rtems.org>. All rights reserved.
# #
# Copyright (c) 2009, 2017 embedded brains GmbH. All rights reserved. # Copyright (c) 2009, 2017 embedded brains GmbH. All rights reserved.
# #
@ -9,8 +12,6 @@
# Germany # Germany
# <info@embedded-brains.de> # <info@embedded-brains.de>
# #
# Copyright (c) 2012 OAR Corporation. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions # modification, are permitted provided that the following conditions
# are met: # are met:
@ -20,19 +21,17 @@
# notice, this list of conditions and the following disclaimer in the # notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution. # documentation and/or other materials provided with the distribution.
# #
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
# FreeBSD: http://svn.freebsd.org/base/releng/8.2/sys (revision 222485)
from __future__ import print_function from __future__ import print_function
@ -60,13 +59,14 @@ filesTotal = 0
filesTotalLines = 0 filesTotalLines = 0
filesTotalInserts = 0 filesTotalInserts = 0
filesTotalDeletes = 0 filesTotalDeletes = 0
diffDetails = { } diffDetails = {}
verboseInfo = 1 verboseInfo = 1
verboseDetail = 2 verboseDetail = 2
verboseMoreDetail = 3 verboseMoreDetail = 3
verboseDebug = 4 verboseDebug = 4
def _cflagsIncludes(cflags, includes): def _cflagsIncludes(cflags, includes):
if type(cflags) is not list: if type(cflags) is not list:
if cflags is not None: if cflags is not None:
@ -81,10 +81,12 @@ def _cflagsIncludes(cflags, includes):
_includes = includes _includes = includes
return _cflags, _includes return _cflags, _includes
def verbose(level = verboseInfo):
def verbose(level=verboseInfo):
return verboseLevel >= level return verboseLevel >= level
def changedFileSummary(statsReport = False):
def changedFileSummary(statsReport=False):
global filesTotal, filesTotalLines, filesTotalInserts, filesTotalDeletes global filesTotal, filesTotalLines, filesTotalInserts, filesTotalDeletes
@ -107,18 +109,25 @@ def changedFileSummary(statsReport = False):
# #
# Sort by opacity. # Sort by opacity.
# #
ordered_diffs = sorted(diffDetails.items(), key = lambda diff: diff[1].opacity, reverse = True) ordered_diffs = sorted(diffDetails.items(),
key=lambda diff: diff[1].opacity,
reverse=True)
for f in ordered_diffs: for f in ordered_diffs:
print(' %s' % (diffDetails[f[0]].status())) print(' %s' % (diffDetails[f[0]].status()))
def readFile(name): def readFile(name):
try: try:
contents = codecs.open(name, mode = 'r', encoding = 'utf-8', errors = 'ignore').read() contents = codecs.open(name,
mode='r',
encoding='utf-8',
errors='ignore').read()
except UnicodeDecodeError as ude: except UnicodeDecodeError as ude:
print('error: reading: %s: %s' % (name, ude)) print('error: reading: %s: %s' % (name, ude))
sys.exit(1) sys.exit(1)
return contents return contents
def writeFile(name, contents): def writeFile(name, contents):
path = os.path.dirname(name) path = os.path.dirname(name)
if not os.path.exists(path): if not os.path.exists(path):
@ -128,11 +137,13 @@ def writeFile(name, contents):
print('error: cannot create directory: %s: %s' % (path, oe)) print('error: cannot create directory: %s: %s' % (path, oe))
sys.exit(1) sys.exit(1)
try: try:
codecs.open(name, mode = 'w', encoding = 'utf-8', errors = 'ignore').write(contents) codecs.open(name, mode='w', encoding='utf-8',
errors='ignore').write(contents)
except UnicodeDecodeError as ude: except UnicodeDecodeError as ude:
print('error: write: %s: %s' % (name, ude)) print('error: write: %s: %s' % (name, ude))
sys.exit(1) sys.exit(1)
# #
# A builder error. # A builder error.
# #
@ -140,11 +151,14 @@ class error(Exception):
"""Base class for exceptions.""" """Base class for exceptions."""
def __init__(self, msg): def __init__(self, msg):
self.msg = 'error: %s' % (msg) self.msg = 'error: %s' % (msg)
def set_output(self, msg): def set_output(self, msg):
self.msg = msg self.msg = msg
def __str__(self): def __str__(self):
return self.msg return self.msg
# #
# Diff Record # Diff Record
# #
@ -158,7 +172,8 @@ class diffRecord:
self.inserts = inserts self.inserts = inserts
self.deletes = deletes self.deletes = deletes
self.changes = inserts + deletes self.changes = inserts + deletes
self.opacity = (float(self.changes) / (self.lines + self.changes)) * 100.0 self.opacity = (float(self.changes) /
(self.lines + self.changes)) * 100.0
def __repr__(self): def __repr__(self):
return self.src return self.src
@ -167,36 +182,50 @@ class diffRecord:
return 'opacity:%5.1f%% edits:%4d (+):%-4d (-):%-4d %s' % \ return 'opacity:%5.1f%% edits:%4d (+):%-4d (-):%-4d %s' % \
(self.opacity, self.changes, self.inserts, self.deletes, self.src) (self.opacity, self.changes, self.inserts, self.deletes, self.src)
# #
# This stuff needs to move to libbsd.py. # This stuff needs to move to libbsd.py.
# #
# Move target dependent files under a machine directory # Move target dependent files under a machine directory
def mapCPUDependentPath(path): def mapCPUDependentPath(path):
return path.replace("include/", "include/machine/") return path.replace("include/", "include/machine/")
def fixIncludes(data): def fixIncludes(data):
data = re.sub('#include <sys/resource.h>', '#include <rtems/bsd/sys/resource.h>', data) data = re.sub('#include <sys/resource.h>',
data = re.sub('#include <sys/unistd.h>', '#include <rtems/bsd/sys/unistd.h>', data) '#include <rtems/bsd/sys/resource.h>', data)
data = re.sub('#include <sys/unistd.h>',
'#include <rtems/bsd/sys/unistd.h>', data)
return data return data
# revert fixing the include paths inside a C or .h file # revert fixing the include paths inside a C or .h file
def revertFixIncludes(data): def revertFixIncludes(data):
data = re.sub('#include <rtems/bsd/', '#include <', data) data = re.sub('#include <rtems/bsd/', '#include <', data)
data = re.sub('#include <util.h>', '#include <rtems/bsd/util.h>', data) data = re.sub('#include <util.h>', '#include <rtems/bsd/util.h>', data)
data = re.sub('#include <bsd.h>', '#include <rtems/bsd/bsd.h>', data) data = re.sub('#include <bsd.h>', '#include <rtems/bsd/bsd.h>', data)
data = re.sub('#include <zerocopy.h>', '#include <rtems/bsd/zerocopy.h>', data) data = re.sub('#include <zerocopy.h>', '#include <rtems/bsd/zerocopy.h>',
data = re.sub('#include <modules.h>', '#include <rtems/bsd/modules.h>', data) data)
data = re.sub('#include <modules.h>', '#include <rtems/bsd/modules.h>',
data)
return data return data
# fix include paths inside a C or .h file # fix include paths inside a C or .h file
def fixLocalIncludes(data): def fixLocalIncludes(data):
data = re.sub('#include "opt_([^"]*)"', '#include <rtems/bsd/local/opt_\\1>', data) data = re.sub('#include "opt_([^"]*)"',
data = re.sub('#include "([^"]*)_if.h"', '#include <rtems/bsd/local/\\1_if.h>', data) '#include <rtems/bsd/local/opt_\\1>', data)
data = re.sub('#include "miidevs([^"]*)"', '#include <rtems/bsd/local/miidevs\\1>', data) data = re.sub('#include "([^"]*)_if.h"',
data = re.sub('#include "usbdevs([^"]*)"', '#include <rtems/bsd/local/usbdevs\\1>', data) '#include <rtems/bsd/local/\\1_if.h>', data)
data = re.sub('#include "miidevs([^"]*)"',
'#include <rtems/bsd/local/miidevs\\1>', data)
data = re.sub('#include "usbdevs([^"]*)"',
'#include <rtems/bsd/local/usbdevs\\1>', data)
return data return data
# revert fixing the include paths inside a C or .h file # revert fixing the include paths inside a C or .h file
def revertFixLocalIncludes(data): def revertFixLocalIncludes(data):
data = re.sub('#include <rtems/bsd/local/([^>]*)>', '#include "\\1"', data) data = re.sub('#include <rtems/bsd/local/([^>]*)>', '#include "\\1"', data)
@ -211,42 +240,48 @@ def assertHeaderFile(path):
print("*** Move it to a C source file list") print("*** Move it to a C source file list")
sys.exit(2) sys.exit(2)
def assertSourceFile(path): def assertSourceFile(path):
if path[-2:] != '.c' and path[-2:] != '.S' and path[-3:] != '.cc': if path[-2:] != '.c' and path[-2:] != '.S' and path[-3:] != '.cc':
print("*** " + path + " does not end in .c, .cc or .S") print("*** " + path + " does not end in .c, .cc or .S")
print("*** Move it to a header file list") print("*** Move it to a header file list")
sys.exit(2) sys.exit(2)
def assertHeaderOrSourceFile(path): def assertHeaderOrSourceFile(path):
if path[-2] != '.' or (path[-1] != 'h' and path[-1] != 'c'): if path[-2] != '.' or (path[-1] != 'h' and path[-1] != 'c'):
print("*** " + path + " does not end in .h or .c") print("*** " + path + " does not end in .h or .c")
print("*** Move it to another list") print("*** Move it to another list")
sys.exit(2) sys.exit(2)
def diffSource(dstLines, srcLines, src, dst): def diffSource(dstLines, srcLines, src, dst):
global filesTotal, filesTotalLines, filesTotalInserts, filesTotalDeletes global filesTotal, filesTotalLines, filesTotalInserts, filesTotalDeletes
# #
# Diff, note there is no line termination on each string. Expand the # Diff, note there is no line termination on each string. Expand the
# generator to list because the generator is not reusable. # generator to list because the generator is not reusable.
# #
diff = list(difflib.unified_diff(dstLines, diff = list(
difflib.unified_diff(dstLines,
srcLines, srcLines,
fromfile = src, fromfile=src,
tofile = dst, tofile=dst,
n = 5, n=5,
lineterm = '')) lineterm=''))
inserts = 0 inserts = 0
deletes = 0 deletes = 0
if len(diff) > 0: if len(diff) > 0:
if src in diffDetails and \ if src in diffDetails and \
diffDetails[src].dst != dst and diffDetails[src].diff != diff: diffDetails[src].dst != dst and diffDetails[src].diff != diff:
raise error('repeated diff of file different: src:%s dst:%s' % (src, dst)) raise error('repeated diff of file different: src:%s dst:%s' %
(src, dst))
for l in diff: for l in diff:
if l[0] == '-': if l[0] == '-':
deletes += 1 deletes += 1
elif l[0] == '+': elif l[0] == '+':
inserts += 1 inserts += 1
diffDetails[src] = diffRecord(src, dst, srcLines, diff, inserts, deletes) diffDetails[src] = diffRecord(src, dst, srcLines, diff, inserts,
deletes)
# #
# Count the total files, lines and the level of changes. # Count the total files, lines and the level of changes.
@ -258,6 +293,7 @@ def diffSource(dstLines, srcLines, src, dst):
return diff return diff
# #
# Converters provide a way to alter the various types of code. The conversion # Converters provide a way to alter the various types of code. The conversion
# process filters a file as it is copies from the source path to the # process filters a file as it is copies from the source path to the
@ -265,8 +301,12 @@ def diffSource(dstLines, srcLines, src, dst):
# source. # source.
# #
class Converter(object): class Converter(object):
def convert(self,
def convert(self, src, dst, hasSource = True, sourceFilter = None, srcContents = None): src,
dst,
hasSource=True,
sourceFilter=None,
srcContents=None):
global filesProcessed, filesProcessedCount global filesProcessed, filesProcessedCount
@ -337,10 +377,12 @@ class Converter(object):
for l in diff: for l in diff:
print(l) print(l)
class NoConverter(Converter): class NoConverter(Converter):
def convert(self, src, dst, hasSource = True, sourceFilter = None): def convert(self, src, dst, hasSource=True, sourceFilter=None):
return '/* EMPTY */\n' return '/* EMPTY */\n'
class FromFreeBSDToRTEMSHeaderConverter(Converter): class FromFreeBSDToRTEMSHeaderConverter(Converter):
def sourceFilter(self, data): def sourceFilter(self, data):
data = fixLocalIncludes(data) data = fixLocalIncludes(data)
@ -349,7 +391,8 @@ class FromFreeBSDToRTEMSHeaderConverter(Converter):
def convert(self, src, dst): def convert(self, src, dst):
sconverter = super(FromFreeBSDToRTEMSHeaderConverter, self) sconverter = super(FromFreeBSDToRTEMSHeaderConverter, self)
sconverter.convert(src, dst, sourceFilter = self.sourceFilter) sconverter.convert(src, dst, sourceFilter=self.sourceFilter)
class FromFreeBSDToRTEMSUserSpaceHeaderConverter(Converter): class FromFreeBSDToRTEMSUserSpaceHeaderConverter(Converter):
def sourceFilter(self, data): def sourceFilter(self, data):
@ -358,7 +401,8 @@ class FromFreeBSDToRTEMSUserSpaceHeaderConverter(Converter):
def convert(self, src, dst): def convert(self, src, dst):
sconverter = super(FromFreeBSDToRTEMSUserSpaceHeaderConverter, self) sconverter = super(FromFreeBSDToRTEMSUserSpaceHeaderConverter, self)
sconverter.convert(src, dst, sourceFilter = self.sourceFilter) sconverter.convert(src, dst, sourceFilter=self.sourceFilter)
class FromFreeBSDToRTEMSSourceConverter(Converter): class FromFreeBSDToRTEMSSourceConverter(Converter):
def sourceFilter(self, data): def sourceFilter(self, data):
@ -369,7 +413,8 @@ class FromFreeBSDToRTEMSSourceConverter(Converter):
def convert(self, src, dst): def convert(self, src, dst):
sconverter = super(FromFreeBSDToRTEMSSourceConverter, self) sconverter = super(FromFreeBSDToRTEMSSourceConverter, self)
sconverter.convert(src, dst, sourceFilter = self.sourceFilter) sconverter.convert(src, dst, sourceFilter=self.sourceFilter)
class FromFreeBSDToRTEMSUserSpaceSourceConverter(Converter): class FromFreeBSDToRTEMSUserSpaceSourceConverter(Converter):
def sourceFilter(self, data): def sourceFilter(self, data):
@ -379,7 +424,8 @@ class FromFreeBSDToRTEMSUserSpaceSourceConverter(Converter):
def convert(self, src, dst): def convert(self, src, dst):
sconverter = super(FromFreeBSDToRTEMSUserSpaceSourceConverter, self) sconverter = super(FromFreeBSDToRTEMSUserSpaceSourceConverter, self)
sconverter.convert(src, dst, sourceFilter = self.sourceFilter) sconverter.convert(src, dst, sourceFilter=self.sourceFilter)
class FromRTEMSToFreeBSDHeaderConverter(Converter): class FromRTEMSToFreeBSDHeaderConverter(Converter):
def sourceFilter(self, data): def sourceFilter(self, data):
@ -389,19 +435,29 @@ class FromRTEMSToFreeBSDHeaderConverter(Converter):
def convert(self, src, dst): def convert(self, src, dst):
sconverter = super(FromRTEMSToFreeBSDHeaderConverter, self) sconverter = super(FromRTEMSToFreeBSDHeaderConverter, self)
sconverter.convert(src, dst, hasSource = False, sourceFilter = self.sourceFilter) sconverter.convert(src,
dst,
hasSource=False,
sourceFilter=self.sourceFilter)
class FromRTEMSToFreeBSDSourceConverter(Converter): class FromRTEMSToFreeBSDSourceConverter(Converter):
def sourceFilter(self, data): def sourceFilter(self, data):
data = re.sub('#include <machine/rtems-bsd-kernel-space.h>\n\n', '', data) data = re.sub('#include <machine/rtems-bsd-kernel-space.h>\n\n', '',
data = re.sub('#include <machine/rtems-bsd-user-space.h>\n\n', '', data) data)
data = re.sub('#include <machine/rtems-bsd-user-space.h>\n\n', '',
data)
data = revertFixLocalIncludes(data) data = revertFixLocalIncludes(data)
data = revertFixIncludes(data) data = revertFixIncludes(data)
return data return data
def convert(self, src, dst): def convert(self, src, dst):
sconverter = super(FromRTEMSToFreeBSDSourceConverter, self) sconverter = super(FromRTEMSToFreeBSDSourceConverter, self)
sconverter.convert(src, dst, hasSource = False, sourceFilter = self.sourceFilter) sconverter.convert(src,
dst,
hasSource=False,
sourceFilter=self.sourceFilter)
# #
# Compose a path based for the various parts of the source tree. # Compose a path based for the various parts of the source tree.
@ -413,6 +469,7 @@ class PathComposer(object):
def composeLibBSDPath(self, path, prefix): def composeLibBSDPath(self, path, prefix):
return os.path.join(prefix, path) return os.path.join(prefix, path)
class FreeBSDPathComposer(PathComposer): class FreeBSDPathComposer(PathComposer):
def composeOriginPath(self, path): def composeOriginPath(self, path):
return os.path.join(FreeBSD_DIR, path) return os.path.join(FreeBSD_DIR, path)
@ -420,6 +477,7 @@ class FreeBSDPathComposer(PathComposer):
def composeLibBSDPath(self, path, prefix): def composeLibBSDPath(self, path, prefix):
return os.path.join(prefix, 'freebsd', path) return os.path.join(prefix, 'freebsd', path)
class RTEMSPathComposer(PathComposer): class RTEMSPathComposer(PathComposer):
def composeOriginPath(self, path): def composeOriginPath(self, path):
return path return path
@ -427,6 +485,7 @@ class RTEMSPathComposer(PathComposer):
def composeLibBSDPath(self, path, prefix): def composeLibBSDPath(self, path, prefix):
return os.path.join(prefix, 'rtemsbsd', path) return os.path.join(prefix, 'rtemsbsd', path)
class LinuxPathComposer(PathComposer): class LinuxPathComposer(PathComposer):
def composeOriginPath(self, path): def composeOriginPath(self, path):
return path return path
@ -434,36 +493,45 @@ class LinuxPathComposer(PathComposer):
def composeLibBSDPath(self, path, prefix): def composeLibBSDPath(self, path, prefix):
return os.path.join(prefix, 'linux', path) return os.path.join(prefix, 'linux', path)
class CPUDependentFreeBSDPathComposer(FreeBSDPathComposer): class CPUDependentFreeBSDPathComposer(FreeBSDPathComposer):
def composeLibBSDPath(self, path, prefix): def composeLibBSDPath(self, path, prefix):
path = super(CPUDependentFreeBSDPathComposer, self).composeLibBSDPath(path, prefix) path = super(CPUDependentFreeBSDPathComposer,
self).composeLibBSDPath(path, prefix)
path = mapCPUDependentPath(path) path = mapCPUDependentPath(path)
return path return path
class CPUDependentRTEMSPathComposer(RTEMSPathComposer): class CPUDependentRTEMSPathComposer(RTEMSPathComposer):
def composeLibBSDPath(self, path, prefix): def composeLibBSDPath(self, path, prefix):
path = super(CPUDependentRTEMSPathComposer, self).composeLibBSDPath(path, prefix) path = super(CPUDependentRTEMSPathComposer,
self).composeLibBSDPath(path, prefix)
path = mapCPUDependentPath(path) path = mapCPUDependentPath(path)
return path return path
class CPUDependentLinuxPathComposer(LinuxPathComposer): class CPUDependentLinuxPathComposer(LinuxPathComposer):
def composeLibBSDPath(self, path, prefix): def composeLibBSDPath(self, path, prefix):
path = super(CPUDependentLinuxPathComposer, self).composeLibBSDPath(path, prefix) path = super(CPUDependentLinuxPathComposer,
self).composeLibBSDPath(path, prefix)
path = mapCPUDependentPath(path) path = mapCPUDependentPath(path)
return path return path
class TargetSourceCPUDependentPathComposer(CPUDependentFreeBSDPathComposer): class TargetSourceCPUDependentPathComposer(CPUDependentFreeBSDPathComposer):
def __init__(self, targetCPU, sourceCPU): def __init__(self, targetCPU, sourceCPU):
self.targetCPU = targetCPU self.targetCPU = targetCPU
self.sourceCPU = sourceCPU self.sourceCPU = sourceCPU
def composeLibBSDPath(self, path, prefix): def composeLibBSDPath(self, path, prefix):
path = super(TargetSourceCPUDependentPathComposer, self).composeLibBSDPath(path, prefix) path = super(TargetSourceCPUDependentPathComposer,
self).composeLibBSDPath(path, prefix)
path = path.replace(self.sourceCPU, self.targetCPU) path = path.replace(self.sourceCPU, self.targetCPU)
return path return path
class BuildSystemFragmentComposer(object): class BuildSystemFragmentComposer(object):
def __init__(self, includes = None): def __init__(self, includes=None):
if type(includes) is not list: if type(includes) is not list:
self.includes = [includes] self.includes = [includes]
else: else:
@ -472,9 +540,9 @@ class BuildSystemFragmentComposer(object):
def compose(self, path): def compose(self, path):
return '' return ''
class SourceFileFragmentComposer(BuildSystemFragmentComposer):
def __init__(self, cflags = "default", includes = None): class SourceFileFragmentComposer(BuildSystemFragmentComposer):
def __init__(self, cflags="default", includes=None):
self.cflags, self.includes = _cflagsIncludes(cflags, includes) self.cflags, self.includes = _cflagsIncludes(cflags, includes)
def compose(self, path): def compose(self, path):
@ -482,15 +550,17 @@ class SourceFileFragmentComposer(BuildSystemFragmentComposer):
flags = self.cflags flags = self.cflags
else: else:
flags = self.cflags + self.includes flags = self.cflags + self.includes
return ['sources', flags, ('default', None)], [path], self.cflags, self.includes return ['sources', flags,
('default', None)], [path], self.cflags, self.includes
class SourceFileIfHeaderComposer(SourceFileFragmentComposer): class SourceFileIfHeaderComposer(SourceFileFragmentComposer):
def __init__(self, headers, cflags="default", includes=None):
def __init__(self, headers, cflags = "default", includes = None):
if headers is not list: if headers is not list:
headers = [headers] headers = [headers]
self.headers = headers self.headers = headers
super(SourceFileIfHeaderComposer, self).__init__(cflags = cflags, includes = includes) super(SourceFileIfHeaderComposer, self).__init__(cflags=cflags,
includes=includes)
def compose(self, path): def compose(self, path):
r = SourceFileFragmentComposer.compose(self, path) r = SourceFileFragmentComposer.compose(self, path)
@ -503,9 +573,15 @@ class SourceFileIfHeaderComposer(SourceFileFragmentComposer):
r[0][2] = (define_keys.strip(), self.headers) r[0][2] = (define_keys.strip(), self.headers)
return r return r
class TestFragementComposer(BuildSystemFragmentComposer):
def __init__(self, testName, fileFragments, configTest = None, runTest = True, netTest = False, extraLibs = []): class TestFragementComposer(BuildSystemFragmentComposer):
def __init__(self,
testName,
fileFragments,
configTest=None,
runTest=True,
netTest=False,
extraLibs=[]):
self.testName = testName self.testName = testName
self.fileFragments = fileFragments self.fileFragments = fileFragments
self.configTest = configTest self.configTest = configTest
@ -514,21 +590,32 @@ class TestFragementComposer(BuildSystemFragmentComposer):
self.extraLibs = extraLibs self.extraLibs = extraLibs
def compose(self, path): def compose(self, path):
return ['tests', self.testName, ('default', None)], { 'configTest': self.configTest, return ['tests', self.testName, ('default', None)], {
'configTest': self.configTest,
'files': self.fileFragments, 'files': self.fileFragments,
'run': self.runTest, 'run': self.runTest,
'net': self.netTest, 'net': self.netTest,
'libs': self.extraLibs} 'libs': self.extraLibs
}
class TestIfHeaderComposer(TestFragementComposer): class TestIfHeaderComposer(TestFragementComposer):
def __init__(self,
def __init__(self, testName, headers, fileFragments, runTest = True, netTest = False, extraLibs = []): testName,
headers,
fileFragments,
runTest=True,
netTest=False,
extraLibs=[]):
if headers is not list: if headers is not list:
headers = [headers] headers = [headers]
self.headers = headers self.headers = headers
super(TestIfHeaderComposer, self).__init__(testName, fileFragments, 'header', super(TestIfHeaderComposer, self).__init__(testName,
runTest = runTest, netTest = netTest, fileFragments,
extraLibs = extraLibs) 'header',
runTest=runTest,
netTest=netTest,
extraLibs=extraLibs)
def compose(self, path): def compose(self, path):
r = TestFragementComposer.compose(self, path) r = TestFragementComposer.compose(self, path)
@ -541,15 +628,24 @@ class TestIfHeaderComposer(TestFragementComposer):
r[0][2] = (define_keys.strip(), self.headers) r[0][2] = (define_keys.strip(), self.headers)
return r return r
class TestIfLibraryComposer(TestFragementComposer):
def __init__(self, testName, libraries, fileFragments, runTest = True, netTest = False, extraLibs = []): class TestIfLibraryComposer(TestFragementComposer):
def __init__(self,
testName,
libraries,
fileFragments,
runTest=True,
netTest=False,
extraLibs=[]):
if libraries is not list: if libraries is not list:
libraries = [libraries] libraries = [libraries]
self.libraries = libraries self.libraries = libraries
super(TestIfLibraryComposer, self).__init__(testName, fileFragments, 'library', super(TestIfLibraryComposer, self).__init__(testName,
runTest = runTest, netTest = netTest, fileFragments,
extraLibs = extraLibs) 'library',
runTest=runTest,
netTest=netTest,
extraLibs=extraLibs)
def compose(self, path): def compose(self, path):
r = TestFragementComposer.compose(self, path) r = TestFragementComposer.compose(self, path)
@ -562,65 +658,71 @@ class TestIfLibraryComposer(TestFragementComposer):
r[0][2] = (define_keys.strip(), self.libraries) r[0][2] = (define_keys.strip(), self.libraries)
return r return r
class KVMSymbolsFragmentComposer(BuildSystemFragmentComposer):
class KVMSymbolsFragmentComposer(BuildSystemFragmentComposer):
def compose(self, path): def compose(self, path):
return ['KVMSymbols', 'files', ('default', None)], [path], self.includes return ['KVMSymbols', 'files',
('default', None)], [path], self.includes
class RPCGENFragmentComposer(BuildSystemFragmentComposer): class RPCGENFragmentComposer(BuildSystemFragmentComposer):
def compose(self, path): def compose(self, path):
return ['RPCGen', 'files', ('default', None)], [path] return ['RPCGen', 'files', ('default', None)], [path]
class RouteKeywordsFragmentComposer(BuildSystemFragmentComposer):
class RouteKeywordsFragmentComposer(BuildSystemFragmentComposer):
def compose(self, path): def compose(self, path):
return ['RouteKeywords', 'files', ('default', None)], [path] return ['RouteKeywords', 'files', ('default', None)], [path]
class LexFragmentComposer(BuildSystemFragmentComposer):
def __init__(self, sym, dep, cflags = None, includes = None, build = True): class LexFragmentComposer(BuildSystemFragmentComposer):
def __init__(self, sym, dep, cflags=None, includes=None, build=True):
self.sym = sym self.sym = sym
self.dep = dep self.dep = dep
self.cflags, self.includes = _cflagsIncludes(cflags, includes) self.cflags, self.includes = _cflagsIncludes(cflags, includes)
self.build = build self.build = build
def compose(self, path): def compose(self, path):
d = { 'file': path, d = {
'file': path,
'sym': self.sym, 'sym': self.sym,
'dep': self.dep, 'dep': self.dep,
'build': self.build } 'build': self.build
}
if None not in self.cflags: if None not in self.cflags:
d['cflags'] = self.cflags d['cflags'] = self.cflags
if None not in self.includes: if None not in self.includes:
d['includes'] = self.includes d['includes'] = self.includes
return ['lex', path, ('default', None)], d return ['lex', path, ('default', None)], d
class YaccFragmentComposer(BuildSystemFragmentComposer):
def __init__(self, sym, header, cflags = None, includes = None, build = True): class YaccFragmentComposer(BuildSystemFragmentComposer):
def __init__(self, sym, header, cflags=None, includes=None, build=True):
self.sym = sym self.sym = sym
self.header = header self.header = header
self.cflags, self.includes = _cflagsIncludes(cflags, includes) self.cflags, self.includes = _cflagsIncludes(cflags, includes)
self.build = build self.build = build
def compose(self, path): def compose(self, path):
d = { 'file': path, d = {
'file': path,
'sym': self.sym, 'sym': self.sym,
'header': self.header, 'header': self.header,
'build': self.build } 'build': self.build
}
if None not in self.cflags: if None not in self.cflags:
d['cflags'] = self.cflags d['cflags'] = self.cflags
if None not in self.includes: if None not in self.includes:
d['includes'] = self.includes d['includes'] = self.includes
return ['yacc', path, ('default', None)], d return ['yacc', path, ('default', None)], d
# #
# File - a file in the source we move backwards and forwards. # File - a file in the source we move backwards and forwards.
# #
class File(object): class File(object):
def __init__(self, path, pathComposer, def __init__(self, path, pathComposer, forwardConverter, reverseConverter,
forwardConverter, reverseConverter, buildSystemComposer): buildSystemComposer):
if verbose(verboseMoreDetail): if verbose(verboseMoreDetail):
print("FILE: %-50s F:%-45s R:%-45s" % \ print("FILE: %-50s F:%-45s R:%-45s" % \
(path, (path,
@ -629,7 +731,8 @@ class File(object):
self.path = path self.path = path
self.pathComposer = pathComposer self.pathComposer = pathComposer
self.originPath = self.pathComposer.composeOriginPath(self.path) self.originPath = self.pathComposer.composeOriginPath(self.path)
self.libbsdPath = self.pathComposer.composeLibBSDPath(self.path, LIBBSD_DIR) self.libbsdPath = self.pathComposer.composeLibBSDPath(
self.path, LIBBSD_DIR)
self.forwardConverter = forwardConverter self.forwardConverter = forwardConverter
self.reverseConverter = reverseConverter self.reverseConverter = reverseConverter
self.buildSystemComposer = buildSystemComposer self.buildSystemComposer = buildSystemComposer
@ -637,7 +740,8 @@ class File(object):
def processSource(self, forward): def processSource(self, forward):
if forward: if forward:
if verbose(verboseDetail): if verbose(verboseDetail):
print("process source: %s => %s" % (self.originPath, self.libbsdPath)) print("process source: %s => %s" %
(self.originPath, self.libbsdPath))
self.forwardConverter.convert(self.originPath, self.libbsdPath) self.forwardConverter.convert(self.originPath, self.libbsdPath)
else: else:
if verbose(verboseDetail): if verbose(verboseDetail):
@ -646,13 +750,15 @@ class File(object):
self.reverseConverter.convert(self.libbsdPath, self.originPath) self.reverseConverter.convert(self.libbsdPath, self.originPath)
def getFragment(self): def getFragment(self):
return self.buildSystemComposer.compose(self.pathComposer.composeLibBSDPath(self.path, '')) return self.buildSystemComposer.compose(
self.pathComposer.composeLibBSDPath(self.path, ''))
# #
# Module - logical group of related files we can perform actions on # Module - logical group of related files we can perform actions on
# #
class Module(object): class Module(object):
def __init__(self, manager, name, enabled = True): def __init__(self, manager, name, enabled=True):
self.manager = manager self.manager = manager
self.name = name self.name = name
self.conditionalOn = "none" self.conditionalOn = "none"
@ -673,7 +779,9 @@ class Module(object):
for f in files: for f in files:
f.processSource(direction) f.processSource(direction)
def addFiles(self, newFiles, buildSystemComposer = BuildSystemFragmentComposer()): def addFiles(self,
newFiles,
buildSystemComposer=BuildSystemFragmentComposer()):
files = [] files = []
for newFile in newFiles: for newFile in newFiles:
assertFile(newFile) assertFile(newFile)
@ -683,14 +791,20 @@ class Module(object):
def addFile(self, f): def addFile(self, f):
self.files += [f] self.files += [f]
def addFiles(self, newFiles, def addFiles(self,
pathComposer, forwardConverter, reverseConverter, newFiles,
assertFile, buildSystemComposer = BuildSystemFragmentComposer()): pathComposer,
forwardConverter,
reverseConverter,
assertFile,
buildSystemComposer=BuildSystemFragmentComposer()):
files = [] files = []
for newFile in newFiles: for newFile in newFiles:
assertFile(newFile) assertFile(newFile)
files += [File(newFile, pathComposer, forwardConverter, files += [
reverseConverter, buildSystemComposer)] File(newFile, pathComposer, forwardConverter, reverseConverter,
buildSystemComposer)
]
return files return files
def addPlainTextFile(self, files): def addPlainTextFile(self, files):
@ -699,71 +813,75 @@ class Module(object):
Converter(), assertNothing) Converter(), assertNothing)
def addKernelSpaceHeaderFiles(self, files): def addKernelSpaceHeaderFiles(self, files):
self.files += self.addFiles(files, self.files += self.addFiles(files, FreeBSDPathComposer(),
FreeBSDPathComposer(), FromFreeBSDToRTEMSHeaderConverter(), FromFreeBSDToRTEMSHeaderConverter(),
FromRTEMSToFreeBSDHeaderConverter(), assertHeaderOrSourceFile) FromRTEMSToFreeBSDHeaderConverter(),
assertHeaderOrSourceFile)
def addUserSpaceHeaderFiles(self, files): def addUserSpaceHeaderFiles(self, files):
self.files += self.addFiles(files, self.files += self.addFiles(
FreeBSDPathComposer(), FromFreeBSDToRTEMSUserSpaceHeaderConverter(), files, FreeBSDPathComposer(),
FromFreeBSDToRTEMSUserSpaceHeaderConverter(),
FromRTEMSToFreeBSDHeaderConverter(), assertHeaderFile) FromRTEMSToFreeBSDHeaderConverter(), assertHeaderFile)
def addRTEMSHeaderFiles(self, files): def addRTEMSHeaderFiles(self, files):
self.files += self.addFiles(files, RTEMSPathComposer(), self.files += self.addFiles(files, RTEMSPathComposer(), NoConverter(),
NoConverter(), NoConverter(), assertHeaderFile) NoConverter(), assertHeaderFile)
def addLinuxHeaderFiles(self, files): def addLinuxHeaderFiles(self, files):
self.files += self.addFiles(files, self.files += self.addFiles(files, PathComposer(), NoConverter(),
PathComposer(), NoConverter(),
NoConverter(), assertHeaderFile) NoConverter(), assertHeaderFile)
def addCPUDependentFreeBSDHeaderFiles(self, files): def addCPUDependentFreeBSDHeaderFiles(self, files):
self.files += self.addFiles(files, self.files += self.addFiles(files, CPUDependentFreeBSDPathComposer(),
CPUDependentFreeBSDPathComposer(), FromFreeBSDToRTEMSHeaderConverter(), FromFreeBSDToRTEMSHeaderConverter(),
FromRTEMSToFreeBSDHeaderConverter(), assertHeaderFile) FromRTEMSToFreeBSDHeaderConverter(),
assertHeaderFile)
def addCPUDependentLinuxHeaderFiles(self, files): def addCPUDependentLinuxHeaderFiles(self, files):
self.files += self.addFiles(files, self.files += self.addFiles(files, CPUDependentLinuxPathComposer(),
CPUDependentLinuxPathComposer(), NoConverter(), NoConverter(), NoConverter(),
NoConverter(), assertHeaderFile) assertHeaderFile)
def addTargetSourceCPUDependentHeaderFiles(self, targetCPUs, sourceCPU, files): def addTargetSourceCPUDependentHeaderFiles(self, targetCPUs, sourceCPU,
files):
for cpu in targetCPUs: for cpu in targetCPUs:
self.files += self.addFiles(files, self.files += self.addFiles(
TargetSourceCPUDependentPathComposer(cpu, sourceCPU), files, TargetSourceCPUDependentPathComposer(cpu, sourceCPU),
FromFreeBSDToRTEMSHeaderConverter(), FromFreeBSDToRTEMSHeaderConverter(), NoConverter(),
NoConverter(), assertHeaderFile) assertHeaderFile)
def addSourceFiles(self, files, sourceFileFragmentComposer): def addSourceFiles(self, files, sourceFileFragmentComposer):
self.files += self.addFiles(files, self.files += self.addFiles(files, PathComposer(), NoConverter(),
PathComposer(), NoConverter(), NoConverter(), assertSourceFile, NoConverter(), assertSourceFile,
sourceFileFragmentComposer) sourceFileFragmentComposer)
def addKernelSpaceSourceFiles(self, files, sourceFileFragmentComposer): def addKernelSpaceSourceFiles(self, files, sourceFileFragmentComposer):
self.files += self.addFiles(files, self.files += self.addFiles(files, FreeBSDPathComposer(),
FreeBSDPathComposer(), FromFreeBSDToRTEMSSourceConverter(), FromFreeBSDToRTEMSSourceConverter(),
FromRTEMSToFreeBSDSourceConverter(), assertSourceFile, FromRTEMSToFreeBSDSourceConverter(),
assertSourceFile,
sourceFileFragmentComposer) sourceFileFragmentComposer)
def addUserSpaceSourceFiles(self, files, sourceFileFragmentComposer): def addUserSpaceSourceFiles(self, files, sourceFileFragmentComposer):
self.files += self.addFiles(files, self.files += self.addFiles(
FreeBSDPathComposer(), files, FreeBSDPathComposer(),
FromFreeBSDToRTEMSUserSpaceSourceConverter(), FromFreeBSDToRTEMSUserSpaceSourceConverter(),
FromRTEMSToFreeBSDSourceConverter(), assertSourceFile, FromRTEMSToFreeBSDSourceConverter(), assertSourceFile,
sourceFileFragmentComposer) sourceFileFragmentComposer)
def addRTEMSSourceFiles(self, files, sourceFileFragmentComposer): def addRTEMSSourceFiles(self, files, sourceFileFragmentComposer):
self.files += self.addFiles(files, self.files += self.addFiles(files, RTEMSPathComposer(), NoConverter(),
RTEMSPathComposer(), NoConverter(), NoConverter(),
assertSourceFile, sourceFileFragmentComposer)
def addLinuxSourceFiles(self, files, sourceFileFragmentComposer):
self.files += self.addFiles(files,
PathComposer(), NoConverter(),
NoConverter(), assertSourceFile, NoConverter(), assertSourceFile,
sourceFileFragmentComposer) sourceFileFragmentComposer)
def addCPUDependentFreeBSDSourceFiles(self, cpus, files, sourceFileFragmentComposer): def addLinuxSourceFiles(self, files, sourceFileFragmentComposer):
self.files += self.addFiles(files, PathComposer(), NoConverter(),
NoConverter(), assertSourceFile,
sourceFileFragmentComposer)
def addCPUDependentFreeBSDSourceFiles(self, cpus, files,
sourceFileFragmentComposer):
for cpu in cpus: for cpu in cpus:
self.initCPUDependencies(cpu) self.initCPUDependencies(cpu)
self.cpuDependentSourceFiles[cpu] += \ self.cpuDependentSourceFiles[cpu] += \
@ -772,7 +890,8 @@ class Module(object):
FromRTEMSToFreeBSDSourceConverter(), assertSourceFile, FromRTEMSToFreeBSDSourceConverter(), assertSourceFile,
sourceFileFragmentComposer) sourceFileFragmentComposer)
def addCPUDependentRTEMSSourceFiles(self, cpus, files, sourceFileFragmentComposer): def addCPUDependentRTEMSSourceFiles(self, cpus, files,
sourceFileFragmentComposer):
for cpu in cpus: for cpu in cpus:
self.initCPUDependencies(cpu) self.initCPUDependencies(cpu)
self.cpuDependentSourceFiles[cpu] += \ self.cpuDependentSourceFiles[cpu] += \
@ -781,7 +900,8 @@ class Module(object):
NoConverter(), assertSourceFile, NoConverter(), assertSourceFile,
sourceFileFragmentComposer) sourceFileFragmentComposer)
def addCPUDependentLinuxSourceFiles(self, cpus, files, sourceFileFragmentComposer): def addCPUDependentLinuxSourceFiles(self, cpus, files,
sourceFileFragmentComposer):
for cpu in cpus: for cpu in cpus:
self.initCPUDependencies(cpu) self.initCPUDependencies(cpu)
self.cpuDependentSourceFiles[cpu] += \ self.cpuDependentSourceFiles[cpu] += \
@ -791,13 +911,15 @@ class Module(object):
sourceFileFragmentComposer) sourceFileFragmentComposer)
def addTest(self, testFragementComposer): def addTest(self, testFragementComposer):
self.files += [File(testFragementComposer.testName, self.files += [
PathComposer(), NoConverter(), NoConverter(), File(testFragementComposer.testName, PathComposer(), NoConverter(),
testFragementComposer)] NoConverter(), testFragementComposer)
]
def addDependency(self, dep): def addDependency(self, dep):
self.dependencies += [dep] self.dependencies += [dep]
# #
# Manager - a collection of modules. # Manager - a collection of modules.
# #
@ -858,9 +980,12 @@ class ModuleManager(object):
def setGenerators(self): def setGenerators(self):
self.generator['convert'] = Converter self.generator['convert'] = Converter
self.generator['no-convert'] = NoConverter self.generator['no-convert'] = NoConverter
self.generator['from-FreeBSD-to-RTEMS-UserSpaceSourceConverter'] = FromFreeBSDToRTEMSUserSpaceSourceConverter self.generator[
self.generator['from-RTEMS-To-FreeBSD-SourceConverter'] = FromRTEMSToFreeBSDSourceConverter 'from-FreeBSD-to-RTEMS-UserSpaceSourceConverter'] = FromFreeBSDToRTEMSUserSpaceSourceConverter
self.generator['buildSystemFragmentComposer'] = BuildSystemFragmentComposer self.generator[
'from-RTEMS-To-FreeBSD-SourceConverter'] = FromRTEMSToFreeBSDSourceConverter
self.generator[
'buildSystemFragmentComposer'] = BuildSystemFragmentComposer
self.generator['file'] = File self.generator['file'] = File
@ -868,7 +993,8 @@ class ModuleManager(object):
self.generator['freebsd-path'] = FreeBSDPathComposer self.generator['freebsd-path'] = FreeBSDPathComposer
self.generator['rtems-path'] = RTEMSPathComposer self.generator['rtems-path'] = RTEMSPathComposer
self.generator['cpu-path'] = CPUDependentFreeBSDPathComposer self.generator['cpu-path'] = CPUDependentFreeBSDPathComposer
self.generator['target-src-cpu--path'] = TargetSourceCPUDependentPathComposer self.generator[
'target-src-cpu--path'] = TargetSourceCPUDependentPathComposer
self.generator['source'] = SourceFileFragmentComposer self.generator['source'] = SourceFileFragmentComposer
self.generator['test'] = TestFragementComposer self.generator['test'] = TestFragementComposer

View File

@ -1,7 +1,10 @@
# SPDX-License-Identifier: BSD-2-Clause
'''LibBSD build configuration to waf integration module.
'''
# Copyright (c) 2015, 2020 Chris Johns <chrisj@rtems.org>. All rights reserved.
# #
# Copyright (c) 2015-2018 Chris Johns <chrisj@rtems.org>. All rights reserved. # Copyright (c) 2009, 2015 embedded brains GmbH. All rights reserved.
#
# Copyright (c) 2009-2015 embedded brains GmbH. All rights reserved.
# #
# embedded brains GmbH # embedded brains GmbH
# Dornierstr. 4 # Dornierstr. 4
@ -20,19 +23,20 @@
# notice, this list of conditions and the following disclaimer in the # notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution. # documentation and/or other materials provided with the distribution.
# #
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
from __future__ import print_function from __future__ import print_function
# Python 3 does no longer know the basestring class. Catch that. # Python 3 does no longer know the basestring class. Catch that.
try: try:
basestring basestring
@ -55,12 +59,12 @@ if windows:
else: else:
host_shell = '' host_shell = ''
# #
# The waf builder for libbsd. # The waf builder for libbsd.
# #
class Builder(builder.ModuleManager): class Builder(builder.ModuleManager):
def __init__(self, trace=False):
def __init__(self, trace = False):
super(Builder, self).__init__() super(Builder, self).__init__()
self.trace = trace self.trace = trace
self.data = {} self.data = {}
@ -82,7 +86,6 @@ class Builder(builder.ModuleManager):
return sources return sources
def generate(self, rtems_version): def generate(self, rtems_version):
def _dataInsert(data, cpu, frag): def _dataInsert(data, cpu, frag):
# #
# The default handler returns an empty string. Skip it. # The default handler returns an empty string. Skip it.
@ -104,14 +107,14 @@ class Builder(builder.ModuleManager):
d[p] = {} d[p] = {}
d = d[p] d = d[p]
if cpu not in d: if cpu not in d:
d[cpu] = { } d[cpu] = {}
config = frag[0][2][0] config = frag[0][2][0]
if config != 'default': if config != 'default':
if 'configure' not in data: if 'configure' not in data:
data['configure'] = { } data['configure'] = {}
configTest = frag[1]['configTest'] configTest = frag[1]['configTest']
if configTest not in data['configure']: if configTest not in data['configure']:
data['configure'][configTest] = { } data['configure'][configTest] = {}
data['configure'][configTest][config] = frag[0][2][1] data['configure'][configTest][config] = frag[0][2][1]
if type(frag[1]) is list: if type(frag[1]) is list:
if config not in d[cpu]: if config not in d[cpu]:
@ -156,20 +159,19 @@ class Builder(builder.ModuleManager):
for cfg in self.data['configure'][configTest]: for cfg in self.data['configure'][configTest]:
if configTest == 'header': if configTest == 'header':
for h in self.data['configure'][configTest][cfg]: for h in self.data['configure'][configTest][cfg]:
conf.check(header_name = h, conf.check(header_name=h,
features = "c", features="c",
includes = conf.env.IFLAGS, includes=conf.env.IFLAGS,
mandatory = False) mandatory=False)
elif configTest == 'library': elif configTest == 'library':
for l in self.data['configure'][configTest][cfg]: for l in self.data['configure'][configTest][cfg]:
conf.check_cc(lib = l, conf.check_cc(lib=l,
fragment = rtems.test_application(), fragment=rtems.test_application(),
execute = False, execute=False,
mandatory = False) mandatory=False)
else: else:
bld.fatal('invalid config test: %s' % (configTest)) bld.fatal('invalid config test: %s' % (configTest))
def build(self, bld): def build(self, bld):
# #
# Localize the config. # Localize the config.
@ -231,16 +233,17 @@ class Builder(builder.ModuleManager):
# Network test configuration # Network test configuration
# #
if not os.path.exists(bld.env.NET_CONFIG): if not os.path.exists(bld.env.NET_CONFIG):
bld.fatal('network configuraiton \'%s\' not found' % (bld.env.NET_CONFIG)) bld.fatal('network configuraiton \'%s\' not found' %
tags = [ 'NET_CFG_INTERFACE_0', (bld.env.NET_CONFIG))
'NET_CFG_SELF_IP', tags = [
'NET_CFG_NETMASK', 'NET_CFG_INTERFACE_0', 'NET_CFG_SELF_IP', 'NET_CFG_NETMASK',
'NET_CFG_PEER_IP', 'NET_CFG_PEER_IP', 'NET_CFG_GATEWAY_IP'
'NET_CFG_GATEWAY_IP' ] ]
try: try:
net_cfg_lines = open(bld.env.NET_CONFIG).readlines() net_cfg_lines = open(bld.env.NET_CONFIG).readlines()
except: except:
bld.fatal('network configuraiton \'%s\' read failed' % (bld.env.NET_CONFIG)) bld.fatal('network configuraiton \'%s\' read failed' %
(bld.env.NET_CONFIG))
lc = 0 lc = 0
sed = 'sed ' sed = 'sed '
for l in net_cfg_lines: for l in net_cfg_lines:
@ -255,10 +258,10 @@ class Builder(builder.ModuleManager):
for t in tags: for t in tags:
if lhs == t: if lhs == t:
sed += "-e 's/@%s@/%s/' " % (t, rhs) sed += "-e 's/@%s@/%s/' " % (t, rhs)
bld(target = "testsuite/include/rtems/bsd/test/network-config.h", bld(target="testsuite/include/rtems/bsd/test/network-config.h",
source = "testsuite/include/rtems/bsd/test/network-config.h.in", source="testsuite/include/rtems/bsd/test/network-config.h.in",
rule = sed + " < ${SRC} > ${TGT}", rule=sed + " < ${SRC} > ${TGT}",
update_outputs = True) update_outputs=True)
# #
# Add a copy rule for all headers where the install path and the source # Add a copy rule for all headers where the install path and the source
@ -266,7 +269,8 @@ class Builder(builder.ModuleManager):
# #
if 'header-paths' in config: if 'header-paths' in config:
header_build_copy_paths = [ header_build_copy_paths = [
hp for hp in config['header-paths'] if hp[2] != '' and not hp[0].endswith(hp[2]) hp for hp in config['header-paths']
if hp[2] != '' and not hp[0].endswith(hp[2])
] ]
for headers in header_build_copy_paths: for headers in header_build_copy_paths:
target = os.path.join(buildinclude, headers[2]) target = os.path.join(buildinclude, headers[2])
@ -274,10 +278,10 @@ class Builder(builder.ModuleManager):
for header in start_dir.ant_glob(headers[1]): for header in start_dir.ant_glob(headers[1]):
relsourcepath = header.path_from(start_dir) relsourcepath = header.path_from(start_dir)
targetheader = os.path.join(target, relsourcepath) targetheader = os.path.join(target, relsourcepath)
bld(features = 'subst', bld(features='subst',
target = targetheader, target=targetheader,
source = header, source=header,
is_copy = True) is_copy=True)
# #
# Generate a header that contains information about enabled modules # Generate a header that contains information about enabled modules
@ -296,12 +300,13 @@ class Builder(builder.ModuleManager):
output += '#define RTEMS_BSD_MODULE_{} 1\n'.format(modname) output += '#define RTEMS_BSD_MODULE_{} 1\n'.format(modname)
output += '#endif /* RTEMS_BSD_MODULES_H */\n' output += '#endif /* RTEMS_BSD_MODULES_H */\n'
self.outputs[0].write(output) self.outputs[0].write(output)
modules_h_file_with_path = os.path.join(buildinclude, modules_h_file_with_path = os.path.join(buildinclude,
module_header_path, module_header_path,
module_header_name) module_header_name)
bld(rule = rtems_libbsd_modules_h_gen, bld(rule=rtems_libbsd_modules_h_gen,
target = modules_h_file_with_path, target=modules_h_file_with_path,
before = ['c', 'cxx']) before=['c', 'cxx'])
# #
# Add the specific rule based builders # Add the specific rule based builders
@ -316,15 +321,15 @@ class Builder(builder.ModuleManager):
kvmsymbols_includes = kvmsymbols['files']['includes'] kvmsymbols_includes = kvmsymbols['files']['includes']
else: else:
kvmsymbols_includes = [] kvmsymbols_includes = []
bld(target = kvmsymbols['files']['all']['default'][0], bld(target=kvmsymbols['files']['all']['default'][0],
source = 'rtemsbsd/rtems/generate_kvm_symbols', source='rtemsbsd/rtems/generate_kvm_symbols',
rule = host_shell + './${SRC} > ${TGT}', rule=host_shell + './${SRC} > ${TGT}',
update_outputs = True) update_outputs=True)
bld.objects(target = 'kvmsymbols', bld.objects(target='kvmsymbols',
features = 'c', features='c',
cflags = cflags, cflags=cflags,
includes = kvmsymbols_includes + includes, includes=kvmsymbols_includes + includes,
source = kvmsymbols['files']['all']['default'][0]) source=kvmsymbols['files']['all']['default'][0])
libbsd_use += ["kvmsymbols"] libbsd_use += ["kvmsymbols"]
bld.add_group() bld.add_group()
@ -336,9 +341,9 @@ class Builder(builder.ModuleManager):
if bld.env.AUTO_REGEN: if bld.env.AUTO_REGEN:
rpcgen = self.data['RPCGen'] rpcgen = self.data['RPCGen']
rpcname = rpcgen['files']['all']['default'][0][:-2] rpcname = rpcgen['files']['all']['default'][0][:-2]
bld(target = rpcname + '.h', bld(target=rpcname + '.h',
source = rpcname + '.x', source=rpcname + '.x',
rule = host_shell + '${RPCGEN} -h -o ${TGT} ${SRC}') rule=host_shell + '${RPCGEN} -h -o ${TGT} ${SRC}')
# #
# Route keywords # Route keywords
@ -351,9 +356,7 @@ class Builder(builder.ModuleManager):
"awk 'BEGIN { r = 0 } { if (NF == 1) " + \ "awk 'BEGIN { r = 0 } { if (NF == 1) " + \
"printf \"#define\\tK_%%s\\t%%d\\n\\t{\\\"%%s\\\", K_%%s},\\n\", " + \ "printf \"#define\\tK_%%s\\t%%d\\n\\t{\\\"%%s\\\", K_%%s},\\n\", " + \
"toupper($1), ++r, $1, toupper($1)}' > ${TGT}" "toupper($1), ++r, $1, toupper($1)}' > ${TGT}"
bld(target = rkwname + '.h', bld(target=rkwname + '.h', source=rkwname, rule=rkw_rule)
source = rkwname,
rule = rkw_rule)
# #
# Lex # Lex
@ -373,16 +376,16 @@ class Builder(builder.ModuleManager):
lex_rule = host_shell + '${LEX} -P ' + lex['sym'] + ' -t ${SRC} | ' + \ lex_rule = host_shell + '${LEX} -P ' + lex['sym'] + ' -t ${SRC} | ' + \
'sed -e \'/YY_BUF_SIZE/s/16384/1024/\' > ${TGT}' 'sed -e \'/YY_BUF_SIZE/s/16384/1024/\' > ${TGT}'
if bld.env.AUTO_REGEN: if bld.env.AUTO_REGEN:
bld(target = lex['file'][:-2]+ '.c', bld(target=lex['file'][:-2] + '.c',
source = lex['file'], source=lex['file'],
rule = lex_rule) rule=lex_rule)
if lex['build']: if lex['build']:
bld.objects(target = 'lex_%s' % (lex['sym']), bld.objects(target='lex_%s' % (lex['sym']),
features = 'c', features='c',
cflags = cflags, cflags=cflags,
includes = lexIncludes + includes, includes=lexIncludes + includes,
defines = defines + lexDefines, defines=defines + lexDefines,
source = lex['file'][:-2] + '.c') source=lex['file'][:-2] + '.c')
libbsd_use += ['lex_%s' % (lex['sym'])] libbsd_use += ['lex_%s' % (lex['sym'])]
# #
@ -397,7 +400,8 @@ class Builder(builder.ModuleManager):
yaccSym = yacc['sym'] yaccSym = yacc['sym']
else: else:
yaccSym = os.path.basename(yaccFile)[:-2] yaccSym = os.path.basename(yaccFile)[:-2]
yaccHeader = '%s/%s' % (os.path.dirname(yaccFile), yacc['header']) yaccHeader = '%s/%s' % (os.path.dirname(yaccFile),
yacc['header'])
if 'cflags' in yacc: if 'cflags' in yacc:
yaccDefines = [d[2:] for d in yacc['cflags']] yaccDefines = [d[2:] for d in yacc['cflags']]
else: else:
@ -408,19 +412,20 @@ class Builder(builder.ModuleManager):
yaccIncludes = [] yaccIncludes = []
yacc_rule = host_shell + '${YACC} -b ' + yaccSym + \ yacc_rule = host_shell + '${YACC} -b ' + yaccSym + \
' -d -p ' + yaccSym + ' ${SRC} && ' + \ ' -d -p ' + yaccSym + ' ${SRC} && ' + \
'sed -e \'/YY_BUF_SIZE/s/16384/1024/\' < ' + yaccSym + '.tab.c > ${TGT} && ' + \ 'sed -e \'/YY_BUF_SIZE/s/16384/1024/\' < ' + \
yaccSym + '.tab.c > ${TGT} && ' + \
'rm -f ' + yaccSym + '.tab.c && mv ' + yaccSym + '.tab.h ' + yaccHeader 'rm -f ' + yaccSym + '.tab.c && mv ' + yaccSym + '.tab.h ' + yaccHeader
if bld.env.AUTO_REGEN: if bld.env.AUTO_REGEN:
bld(target = yaccFile[:-2] + '.c', bld(target=yaccFile[:-2] + '.c',
source = yaccFile, source=yaccFile,
rule = yacc_rule) rule=yacc_rule)
if yacc['build']: if yacc['build']:
bld.objects(target = 'yacc_%s' % (yaccSym), bld.objects(target='yacc_%s' % (yaccSym),
features = 'c', features='c',
cflags = cflags, cflags=cflags,
includes = yaccIncludes + includes, includes=yaccIncludes + includes,
defines = defines + yaccDefines, defines=defines + yaccDefines,
source = yaccFile[:-2] + '.c') source=yaccFile[:-2] + '.c')
libbsd_use += ['yacc_%s' % (yaccSym)] libbsd_use += ['yacc_%s' % (yaccSym)]
# #
@ -443,12 +448,12 @@ class Builder(builder.ModuleManager):
for arch in archs: for arch in archs:
if bld.get_env()['RTEMS_ARCH'] == arch: if bld.get_env()['RTEMS_ARCH'] == arch:
bld_sources += Builder._sourceList(bld, build[arch]) bld_sources += Builder._sourceList(bld, build[arch])
bld.objects(target = target, bld.objects(target=target,
features = 'c', features='c',
cflags = cflags + sorted(build.get('cflags', [])), cflags=cflags + sorted(build.get('cflags', [])),
includes = sorted(build.get('includes', [])) + includes, includes=sorted(build.get('includes', [])) + includes,
defines = defines, defines=defines,
source = bld_sources) source=bld_sources)
libbsd_use += [target] libbsd_use += [target]
# #
@ -462,14 +467,14 @@ class Builder(builder.ModuleManager):
for arch in archs: for arch in archs:
if bld.get_env()['RTEMS_ARCH'] == arch: if bld.get_env()['RTEMS_ARCH'] == arch:
bld_sources += Builder._sourceList(bld, build[arch]) bld_sources += Builder._sourceList(bld, build[arch])
bld.stlib(target = 'bsd', bld.stlib(target='bsd',
features = 'c cxx', features='c cxx',
cflags = cflags, cflags=cflags,
cxxflags = cxxflags, cxxflags=cxxflags,
includes = includes, includes=includes,
defines = defines, defines=defines,
source = bld_sources, source=bld_sources,
use = libbsd_use) use=libbsd_use)
# #
# Installs. # Installs.
@ -495,13 +500,13 @@ class Builder(builder.ModuleManager):
if start_dir != None: if start_dir != None:
bld.install_files("${PREFIX}/" + ipath, bld.install_files("${PREFIX}/" + ipath,
start_dir.ant_glob(headers[1]), start_dir.ant_glob(headers[1]),
cwd = start_dir, cwd=start_dir,
relative_trick = True) relative_trick=True)
bld.install_files(os.path.join("${PREFIX}", arch_inc_path, bld.install_files(os.path.join("${PREFIX}", arch_inc_path,
module_header_path), module_header_path),
modules_h_file_with_path, modules_h_file_with_path,
cwd = bld.path) cwd=bld.path)
# #
# Tests # Tests
@ -525,11 +530,11 @@ class Builder(builder.ModuleManager):
for f in test[cfg]['files']] for f in test[cfg]['files']]
libs = test[cfg]['libs'] + libs libs = test[cfg]['libs'] + libs
if build_test: if build_test:
bld.program(target = '%s.exe' % (testName), bld.program(target='%s.exe' % (testName),
features = 'cprogram', features='cprogram',
cflags = cflags, cflags=cflags,
includes = includes, includes=includes,
source = test_sources, source=test_sources,
use = ['bsd'], use=['bsd'],
lib = libs, lib=libs,
install_path = None) install_path=None)

136
wscript
View File

@ -1,6 +1,10 @@
# # SPDX-License-Identifier: BSD-2-Clause
# RTEMS Project (https://www.rtems.org/) '''RTEMS LibBSD is a transparent source build of the FreeBSD kernel
# source for RTEMS.
To use see README.waf shipped with this file.
'''
# Copyright (c) 2015-2016 Chris Johns <chrisj@rtems.org>. All rights reserved. # Copyright (c) 2015-2016 Chris Johns <chrisj@rtems.org>. All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -12,17 +16,17 @@
# notice, this list of conditions and the following disclaimer in the # notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution. # documentation and/or other materials provided with the distribution.
# #
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
# #
# RTEMS LibBSD is a transparent source build of the FreeBSD kernel source for RTEMS. # RTEMS LibBSD is a transparent source build of the FreeBSD kernel source for RTEMS.
@ -57,6 +61,7 @@ builders = {}
BUILDSET_DIR = "buildset" BUILDSET_DIR = "buildset"
BUILDSET_DEFAULT = "buildset/default.ini" BUILDSET_DEFAULT = "buildset/default.ini"
def load_ini(conf, f): def load_ini(conf, f):
ini = configparser.ConfigParser() ini = configparser.ConfigParser()
ini.read(f) ini.read(f)
@ -73,8 +78,9 @@ def load_ini(conf, f):
elif os.path.isfile(os.path.join(BUILDSET_DIR, extends)): elif os.path.isfile(os.path.join(BUILDSET_DIR, extends)):
extendfile = os.path.join(BUILDSET_DIR, extends) extendfile = os.path.join(BUILDSET_DIR, extends)
else: else:
conf.fatal("'{}': Invalid file given for general/extends:'{}'" conf.fatal(
.format(f, extends)) "'{}': Invalid file given for general/extends:'{}'".format(
f, extends))
base = load_ini(conf, extendfile) base = load_ini(conf, extendfile)
for s in ini.sections(): for s in ini.sections():
if not base.has_section(s): if not base.has_section(s):
@ -85,6 +91,7 @@ def load_ini(conf, f):
ini = base ini = base
return ini return ini
def load_config(conf, f): def load_config(conf, f):
ini = load_ini(conf, f) ini = load_ini(conf, f)
config = {} config = {}
@ -100,6 +107,7 @@ def load_config(conf, f):
config['modules-enabled'].append(mod) config['modules-enabled'].append(mod)
return config return config
def update_builders(ctx, buildset_opt): def update_builders(ctx, buildset_opt):
global builders global builders
builders = {} builders = {}
@ -111,7 +119,7 @@ def update_builders(ctx, buildset_opt):
if os.path.isdir(bs): if os.path.isdir(bs):
for f in os.listdir(bs): for f in os.listdir(bs):
if f[-4:] == ".ini": if f[-4:] == ".ini":
buildsets += [os.path.join(bs,f)] buildsets += [os.path.join(bs, f)]
else: else:
for f in bs.split(','): for f in bs.split(','):
buildsets += [f] buildsets += [f]
@ -123,7 +131,8 @@ def update_builders(ctx, buildset_opt):
bsname = bsconfig['name'] bsname = bsconfig['name']
builder.updateConfiguration(bsconfig) builder.updateConfiguration(bsconfig)
builder.generate(rtems_version) builder.generate(rtems_version)
builders[bsname]=builder builders[bsname] = builder
def bsp_init(ctx, env, contexts): def bsp_init(ctx, env, contexts):
# This function generates the builders and adds build-xxx, clean-xxx and # This function generates the builders and adds build-xxx, clean-xxx and
@ -143,6 +152,7 @@ def bsp_init(ctx, env, contexts):
for y in contexts: for y in contexts:
newcmd = y.cmd + '-' + builder newcmd = y.cmd + '-' + builder
newvariant = y.variant + '-' + builder newvariant = y.variant + '-' + builder
class context(y): class context(y):
cmd = str(newcmd) cmd = str(newcmd)
variant = str(newvariant) variant = str(newvariant)
@ -158,49 +168,66 @@ def bsp_init(ctx, env, contexts):
commands += [str(cmd)] commands += [str(cmd)]
waflib.Options.commands = commands waflib.Options.commands = commands
def init(ctx): def init(ctx):
rtems.init(ctx, version = rtems_version, long_commands = True, rtems.init(ctx,
bsp_init = bsp_init) version=rtems_version,
long_commands=True,
bsp_init=bsp_init)
def options(opt): def options(opt):
rtems.options(opt) rtems.options(opt)
opt.add_option("--enable-auto-regen", opt.add_option("--enable-auto-regen",
action = "store_true", action="store_true",
default = False, default=False,
dest = "auto_regen", dest="auto_regen",
help = "Enable auto-regeneration of LEX, RPC and YACC files.") help="Enable auto-regeneration of LEX, RPC and YACC files.")
opt.add_option("--enable-warnings", opt.add_option("--enable-warnings",
action = "store_true", action="store_true",
default = False, default=False,
dest = "warnings", dest="warnings",
help = "Enable all warnings. The default is quiet builds.") help="Enable all warnings. The default is quiet builds.")
opt.add_option("--net-test-config", opt.add_option("--net-test-config",
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", opt.add_option("--freebsd-options",
action = "store", action="store",
default = "", default="",
dest = "freebsd_options", dest="freebsd_options",
help = "Set FreeBSD options (developer option).") help="Set FreeBSD options (developer option).")
opt.add_option("--optimization", opt.add_option(
action = "store", "--optimization",
default = "2", action="store",
dest = "optimization", default="2",
help = "Set optimization level to OPTIMIZATION (-On compiler flag). Default is 2 (-O2).") dest="optimization",
opt.add_option("--buildset", help=
action = "append", "Set optimization level to OPTIMIZATION (-On compiler flag). Default is 2 (-O2)."
default = [], )
dest = "buildset", opt.add_option(
help = "Select build sets to build. If set to a directory, all .ini file in this directory will be used.") "--buildset",
action="append",
default=[],
dest="buildset",
help=
"Select build sets to build. If set to a directory," \
" all .ini file in this directory will be used."
)
def bsp_configure(conf, arch_bsp): def bsp_configure(conf, arch_bsp):
conf.check(header_name = "dlfcn.h", features = "c") conf.check(header_name="dlfcn.h", features="c")
conf.check(header_name = "rtems/pci.h", features = "c", mandatory = False) conf.check(header_name="rtems/pci.h", features="c", mandatory=False)
if not rtems.check_posix(conf): if not rtems.check_posix(conf):
conf.fatal("RTEMS kernel POSIX support is disabled; configure RTEMS with --enable-posix") conf.fatal(
"RTEMS kernel POSIX support is disabled; configure RTEMS with --enable-posix"
)
if rtems.check_networking(conf): if rtems.check_networking(conf):
conf.fatal("RTEMS kernel contains the old network support; configure RTEMS with --disable-networking") conf.fatal(
"RTEMS kernel contains the old network support;" \
" configure RTEMS with --disable-networking"
)
env = conf.env.derive() env = conf.env.derive()
for builder in builders: for builder in builders:
ab = conf.env.RTEMS_ARCH_BSP ab = conf.env.RTEMS_ARCH_BSP
@ -210,15 +237,16 @@ def bsp_configure(conf, arch_bsp):
builders[builder].bsp_configure(conf, arch_bsp) builders[builder].bsp_configure(conf, arch_bsp)
conf.setenv(ab) conf.setenv(ab)
def configure(conf): def configure(conf):
if conf.options.auto_regen: if conf.options.auto_regen:
conf.find_program("lex", mandatory = True) conf.find_program("lex", mandatory=True)
conf.find_program("rpcgen", mandatory = True) conf.find_program("rpcgen", mandatory=True)
conf.find_program("yacc", mandatory = True) conf.find_program("yacc", mandatory=True)
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 conf.env.FREEBSD_OPTIONS = conf.options.freebsd_options
conf.env.OPTIMIZATION = conf.options.optimization conf.env.OPTIMIZATION = conf.options.optimization
conf.env.BUILDSET = conf.options.buildset conf.env.BUILDSET = conf.options.buildset
if len(conf.env.BUILDSET) == 0: if len(conf.env.BUILDSET) == 0:
@ -226,9 +254,11 @@ def configure(conf):
update_builders(conf, conf.env.BUILDSET) update_builders(conf, conf.env.BUILDSET)
rtems.configure(conf, bsp_configure) rtems.configure(conf, bsp_configure)
def test(bld): def test(bld):
rtems.test_uninstall(bld) rtems.test_uninstall(bld)
def build(bld): def build(bld):
rtems.build(bld) rtems.build(bld)
builders[bld.libbsd_buildset_name].build(bld) builders[bld.libbsd_buildset_name].build(bld)