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

@@ -147,20 +147,9 @@ class ModuleManager(builder.ModuleManager):
self.script += line + os.linesep
def write(self):
try:
out = tempfile.NamedTemporaryFile(delete = False)
try:
out.write(bytes(self.script, sys.stdin.encoding))
except:
out.write(self.script)
out.close()
wscript = builder.RTEMS_DIR + '/libbsd_waf.py'
builder.processIfDifferent(out.name, wscript, "libbsd_waf.py")
finally:
try:
os.remove(out.name)
except:
pass
name = os.path.join(builder.RTEMS_DIR, 'libbsd_waf.py')
converter = builder.Converter()
converter.convert(name, name, src_contents = self.script)
def setGenerators(self):
self.generator['convert'] = builder.Converter