waf: Refector the builder to work with Python3 and UTF-8 source files.

Python 3 requires better UTF-8 handling of files and FreeBSD has UTF-8
characters in some files.

Refactor builder.py to clean up the code and remove the need to have
a temporary file. Update other scripts to use the new code.
This commit is contained in:
Chris Johns
2016-04-27 12:03:17 +10:00
parent 5b93cc84b4
commit f1fcdba863
3 changed files with 232 additions and 156 deletions

View File

@@ -87,7 +87,7 @@ def parseArguments():
sys.exit(2)
for o, a in opts:
if o in ("-v", "--verbose"):
builder.isVerbose = True
builder.verboseLevel += 1
elif o in ("-h", "--help", "-?"):
usage()
sys.exit()
@@ -110,13 +110,14 @@ def parseArguments():
parseArguments()
print("Verbose: " + ("no", "yes")[builder.isVerbose])
print("Dry Run: " + ("no", "yes")[builder.isDryRun])
print("Diff Mode Enabled: " + ("no", "yes")[builder.isDiffMode])
print("Only Generate Build Scripts: " + ("no", "yes")[isOnlyBuildScripts])
print("RTEMS Libbsd Directory: " + builder.RTEMS_DIR)
print("FreeBSD SVN Directory: " + builder.FreeBSD_DIR)
print("Direction: " + ("reverse", "forward")[isForward])
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("RTEMS Libbsd Directory: %s" % (builder.RTEMS_DIR))
print("FreeBSD SVN Directory: %s" % (builder.FreeBSD_DIR))
print("Direction: %s" % (("reverse", "forward")[isForward]))
# Check directory argument was set and exist
def wasDirectorySet(desc, path):
@@ -147,16 +148,14 @@ if isEarlyExit == True:
try:
waf_gen = waf_generator.ModuleManager()
libbsd.sources(waf_gen)
# Perform the actual file manipulation
if isForward:
if not isOnlyBuildScripts:
waf_gen.copyFromFreeBSDToRTEMS()
waf_gen.generate(libbsd.rtems_version())
else:
waf_gen.copyFromRTEMSToFreeBSD()
if not isOnlyBuildScripts:
waf_gen.processSource(isForward)
waf_gen.generate(libbsd.rtems_version())
builder.changedFileSummary()
except IOError as ioe:
print('error: %s' % (ioe))
print('error: %s' % (str(ioe)))
except builder.error as be:
print('error: %s' % (be))
except KeyboardInterrupt:
print('user abort')