diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-11-09 14:46:06 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-11-09 14:46:06 -0800 |
commit | 473ab54aafafd37d0115490c1cbcb5cdbed6f21b (patch) | |
tree | a9230993d6ed92e2abec31fa76b04bbd8d84b57c | |
parent | 6c9ebaf5768ee64aa4946dfd29ac48abac4a1df0 (diff) | |
parent | 23d8911d25700c246093849dac35377dc21a233f (diff) |
Merge pull request #1772 from juj/fix_test_asm_pgo_windows
Fix test_asm_pgo on Windows.
-rw-r--r-- | tools/response_file.py | 6 | ||||
-rw-r--r-- | tools/shared.py | 21 |
2 files changed, 16 insertions, 11 deletions
diff --git a/tools/response_file.py b/tools/response_file.py index f19cf8af..7f916752 100644 --- a/tools/response_file.py +++ b/tools/response_file.py @@ -1,4 +1,5 @@ import tempfile, os, sys, shlex +import shared # Routes the given cmdline param list in args into a new response file and returns the filename to it. # The returned filename has a suffix '.rsp'. @@ -9,6 +10,11 @@ def create_response_file(args, directory): args = map(lambda p: p.replace('\\', '\\\\').replace('"', '\\"'), args) response_fd.write('"' + '" "'.join(args) + '"') response_fd.close() + + # Register the created .rsp file to be automatically cleaned up once this process finishes, so that + # caller does not have to remember to do it. + shared.configuration.get_temp_files().note(response_filename) + return response_filename # Reads a response file, and returns the list of cmdline params found in the file. diff --git a/tools/shared.py b/tools/shared.py index d38aef4c..78d7e54e 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -3,7 +3,7 @@ from subprocess import Popen, PIPE, STDOUT from tempfile import mkstemp from distutils.spawn import find_executable import jsrun, cache, tempfiles -from response_file import create_response_file +import response_file import logging, platform def listify(x): @@ -41,8 +41,8 @@ class WindowsPopen: # emscripten.py supports reading args from a response file instead of cmdline. # Use .rsp to avoid cmdline length limitations on Windows. if len(args) >= 2 and args[1].endswith("emscripten.py"): - self.response_filename = create_response_file(args[2:], TEMP_DIR) - args = args[0:2] + ['@' + self.response_filename] + response_filename = response_file.create_response_file(args[2:], TEMP_DIR) + args = args[0:2] + ['@' + response_filename] try: # Call the process with fixed streams. @@ -78,13 +78,6 @@ class WindowsPopen: def kill(self): return self.process.kill() - def __del__(self): - try: - # Clean up the temporary response file that was used to spawn this process, so that we don't leave temp files around. - tempfiles.try_delete(self.response_filename) - except: - pass # Mute all exceptions in dtor, particularly if we didn't use a response file, self.response_filename doesn't exist. - __rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) def path_from_root(*pathelems): return os.path.join(__rootpath__, *pathelems) @@ -1214,7 +1207,13 @@ class Building: # Run Emscripten Settings.RELOOPER = Cache.get_path('relooper.js') settings = Settings.serialize() - compiler_output = jsrun.timeout_run(Popen([PYTHON, EMSCRIPTEN, filename + ('.o.ll' if append_ext else ''), '-o', filename + '.o.js'] + settings + extra_args, stdout=PIPE), None, 'Compiling') + args = settings + extra_args + if WINDOWS: + args = ['@' + response_file.create_response_file(args, TEMP_DIR)] + cmdline = [PYTHON, EMSCRIPTEN, filename + ('.o.ll' if append_ext else ''), '-o', filename + '.o.js'] + args + if jsrun.TRACK_PROCESS_SPAWNS: + logging.info('Executing emscripten.py compiler with cmdline "' + ' '.join(cmdline) + '"') + compiler_output = jsrun.timeout_run(Popen(cmdline, stdout=PIPE), None, 'Compiling') #print compiler_output # Detect compilation crashes and errors |