waf: Add a config report

This commit is contained in:
Chris Johns 2020-09-01 16:55:06 +10:00
parent 93effa4b01
commit c8c03f73f1
2 changed files with 87 additions and 38 deletions

View File

@ -534,6 +534,16 @@ class BuildSystemFragmentComposer(object):
else:
self.includes = includes
def __str__(self):
return ''
def get_includes(self):
if None in self.includes:
incs = []
else:
incs = self.includes
return incs
def compose(self, path):
return ''
@ -542,11 +552,14 @@ class SourceFileFragmentComposer(BuildSystemFragmentComposer):
def __init__(self, cflags="default", includes=None):
self.cflags, self.includes = _cflagsIncludes(cflags, includes)
def _get_flags(self):
return self.cflags + self.get_includes()
def __str__(self):
return 'SF: ' + ' '.join(self._get_flags())
def compose(self, path):
if None in self.includes:
flags = self.cflags
else:
flags = self.cflags + self.includes
flags = self._get_flags()
return ['sources', flags,
('default', None)], [path], self.cflags, self.includes
@ -558,6 +571,12 @@ class SourceFileIfHeaderComposer(SourceFileFragmentComposer):
self.headers = headers
super(SourceFileIfHeaderComposer, self).__init__(cflags=cflags,
includes=includes)
def __str__(self):
incs = self.headers + self.get_includes
if len(incs) > 0:
return 'SFIH:' + ' '.join(incs)
else:
return ''
def compose(self, path):
r = SourceFileFragmentComposer.compose(self, path)
@ -586,6 +605,9 @@ class TestFragementComposer(BuildSystemFragmentComposer):
self.netTest = netTest
self.extraLibs = extraLibs
def __str__(self):
return 'TEST: ' + self.testName
def compose(self, path):
return ['tests', self.testName, ('default', None)], {
'configTest': self.configTest,
@ -714,10 +736,9 @@ class YaccFragmentComposer(BuildSystemFragmentComposer):
return ['yacc', path, ('default', None)], d
#
# File - a file in the source we move backwards and forwards.
#
class File(object):
'''A file of source we move backwards and forwards and build.'''
def __init__(self, path, pathComposer, forwardConverter, reverseConverter,
buildSystemComposer):
if verbose(verboseMoreDetail):
@ -734,6 +755,13 @@ class File(object):
self.reverseConverter = reverseConverter
self.buildSystemComposer = buildSystemComposer
def __str__(self):
out = self.path
bsc = str(self.buildSystemComposer)
if len(bsc) > 0:
out += ' (' + bsc + ')'
return out
def processSource(self, forward):
if forward:
if verbose(verboseDetail):
@ -751,10 +779,9 @@ class File(object):
self.pathComposer.composeLibBSDPath(self.path, ''))
#
# Module - logical group of related files we can perform actions on
#
class Module(object):
'''Logical group of related files we can perform actions on'''
def __init__(self, manager, name, enabled=True):
self.manager = manager
self.name = name
@ -763,6 +790,20 @@ class Module(object):
self.cpuDependentSourceFiles = {}
self.dependencies = []
def __str__(self):
out = [self.name + ': ' + self.conditionalOn]
if len(self.dependencies) > 0:
out += [' Deps: ' + str(len(self.dependencies))]
out += [' ' + type(d).__name__ for d in self.dependencies]
if len(self.files) > 0:
out += [' Files: ' + str(len(self.files))]
out += [' ' + str(f) for f in self.files]
if len(self.cpuDependentSourceFiles) > 0:
out += [' CPU Dep: ' + str(len(self.cpuDependentSourceFiles))]
for cpu in self.cpuDependentSourceFiles:
out += [' ' + cpu + ':' + str(f) for f in self.cpuDependentSourceFiles[cpu]]
return os.linesep.join(out)
def initCPUDependencies(self, cpu):
if cpu not in self.cpuDependentSourceFiles:
self.cpuDependentSourceFiles[cpu] = []
@ -776,15 +817,6 @@ class Module(object):
for f in files:
f.processSource(direction)
def addFiles(self,
newFiles,
buildSystemComposer=BuildSystemFragmentComposer()):
files = []
for newFile in newFiles:
assertFile(newFile)
files += [File(newFile, composers, buildSystemComposer)]
return files
def addFile(self, f):
self.files += [f]
@ -912,10 +944,9 @@ class Module(object):
self.dependencies += [dep]
#
# Manager - a collection of modules.
#
class ModuleManager(object):
'''A manager for a collection of modules.'''
def __init__(self):
self.modules = {}
self.generator = {}
@ -927,6 +958,12 @@ class ModuleManager(object):
raise KeyError('module %s not found' % (key))
return self.modules[key]
def __str__(self):
out = ['Modules: ' + str(len(self.modules)), '']
for m in sorted(self.modules):
out += [str(self.modules[m]), '']
return os.linesep.join(out)
def getAllModules(self):
if 'modules' in self.configuration:
return self.configuration['modules']

View File

@ -47,6 +47,7 @@ import libbsd
isForward = True
isEarlyExit = False
statsReport = False
isConfig = False
def usage():
print("freebsd-to-rtems.py [args]")
@ -59,14 +60,15 @@ def usage():
print(" -R|--reverse default origin -> LibBSD, reverse that")
print(" -r|--rtems LibBSD directory (default: '.')")
print(" -f|--freebsd FreeBSD origin directory (default: 'freebsd-org')")
print(" -c|--config Output the configuration then exit")
print(" -v|--verbose enable verbose output mode")
# Parse the arguments
def parseArguments():
global isForward, isEarlyExit, statsReport
global isForward, isEarlyExit, statsReport, isConfig
try:
opts, args = getopt.getopt(sys.argv[1:],
"?hdDembSRr:f:v",
"?hdDembSRr:f:cv",
[ "help",
"help",
"dry-run"
@ -78,6 +80,7 @@ def parseArguments():
"stats"
"rtems="
"freebsd="
"config"
"verbose" ])
except getopt.GetoptError as err:
# print help information and exit:
@ -104,6 +107,8 @@ def parseArguments():
builder.LIBBSD_DIR = a
elif o in ("-f", "--freebsd"):
builder.FreeBSD_DIR = a
elif o in ("-c", "--config"):
isConfig = True
else:
assert False, "unhandled option"
@ -127,24 +132,31 @@ def wasDirectorySet(desc, path):
print("error:" + desc + " Directory (" + path + ") does not exist")
sys.exit(2)
# Were directories specified?
wasDirectorySet( "LibBSD", builder.LIBBSD_DIR )
wasDirectorySet( "FreeBSD", builder.FreeBSD_DIR )
# Are we generating or reverting?
if isForward == True:
print("Forward from", builder.FreeBSD_DIR, "into", builder.LIBBSD_DIR)
else:
print("Reverting from", builder.LIBBSD_DIR)
if isEarlyExit == True:
print("Early exit at user request")
sys.exit(0)
try:
if not isConfig:
# Were directories specified?
wasDirectorySet( "LibBSD", builder.LIBBSD_DIR )
wasDirectorySet( "FreeBSD", builder.FreeBSD_DIR )
# Are we generating or reverting?
if isForward == True:
print("Forward from", builder.FreeBSD_DIR, "into", builder.LIBBSD_DIR)
else:
print("Reverting from", builder.LIBBSD_DIR)
if isEarlyExit == True:
print("Early exit at user request")
sys.exit(0)
build = builder.ModuleManager()
libbsd.load(build)
build.generateBuild(only_enabled=False)
if isConfig:
print()
print(build)
sys.exit(0)
build.processSource(isForward)
builder.changedFileSummary(statsReport)
except IOError as ioe: