scons: file removed from python3

Change-Id: I95794fec5cc9c6e72c9ae53f586052be71436c87
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/26249
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>
This commit is contained in:
Giacomo Travaglini
2020-03-02 15:08:41 +00:00
parent 10b4842407
commit bb95aa14c6
3 changed files with 11 additions and 10 deletions

View File

@@ -1014,9 +1014,8 @@ export_vars += ['USE_FENV', 'TARGET_ISA', 'TARGET_GPU_ISA', 'CP_ANNOTATE',
# value of the variable.
def build_config_file(target, source, env):
(variable, value) = [s.get_contents() for s in source]
f = file(str(target[0]), 'w')
print('#define', variable, value, file=f)
f.close()
with open(str(target[0]), 'w') as f:
print('#define', variable, value, file=f)
return None
# Combine the two functions into a scons Action object.

View File

@@ -284,7 +284,8 @@ def Blob(blob_path, symbol):
cpp_path = path_noext + '.cc'
hpp_path = path_noext + '.hh'
def embedBlob(target, source, env):
data = file(str(source[0]), 'r').read()
with open(str(source[0]), 'rb') as f:
data = f.read()
cpp_code = code_formatter()
hpp_code = code_formatter()
blobToCpp(data, symbol, cpp_code, hpp_code, namespace='Blobs')
@@ -767,7 +768,8 @@ class DictImporter(object):
mod.__path__ = source.modpath
mod.__file__ = source.abspath
exec file(source.abspath, 'r') in mod.__dict__
compiled = compile(open(source.abspath).read(), source.abspath, 'exec')
exec(compiled, mod.__dict__)
return mod
@@ -850,7 +852,8 @@ PySource('m5', 'python/m5/defines.py')
def makeInfoPyFile(target, source, env):
code = code_formatter()
for src in source:
data = ''.join(file(src.srcnode().abspath, 'r').xreadlines())
with open(src.srcnode().abspath, 'r') as f:
data = ''.join(f)
code('$src = ${{repr(data)}}')
code.write(str(target[0]))

View File

@@ -99,10 +99,9 @@ def do_embed_text(target, source, env):
generated_dir = Dir('protocol')
def MakeIncludeAction(target, source, env):
f = file(str(target[0]), 'w')
for s in source:
print('#include "%s"' % str(s.abspath), file=f)
f.close()
with open(str(target[0]), 'w') as f:
for s in source:
print('#include "%s"' % str(s.abspath), file=f)
def MakeInclude(source):
target = generated_dir.File(basename(source))