diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-02-26 16:08:29 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-02-26 16:08:29 -0800 |
commit | 58af9770c7e38daedfd8f088995a4657f835fd68 (patch) | |
tree | 490a057a37db9c5e303e472f83dd5cb372969897 | |
parent | 2f5e6f993e1b1a446331520b4dc2d5b19d597371 (diff) | |
parent | 7c8e4eb469dac56b6bc3bbd979ed2245e0cecfbe (diff) |
Merge pull request #877 from vvuk/response-files
Add response file support to emscripten
-rw-r--r-- | AUTHORS | 1 | ||||
-rwxr-xr-x | emcc | 22 | ||||
-rw-r--r-- | tools/shared.py | 20 |
3 files changed, 42 insertions, 1 deletions
@@ -50,4 +50,5 @@ a license to everyone to use it as detailed in LICENSE.) * Bruce Mitchener, Jr. <bruce.mitchener@gmail.com> * Michael Bishop <mbtyke@gmail.com> * Roger Braun <roger@rogerbraun.net> +* Vladimir Vukicevic <vladimir@pobox.com> (copyright owned by Mozilla Foundation) @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# -*- Mode: python -*- ''' emcc - compiler helper script @@ -118,6 +119,27 @@ if len(sys.argv) == 1: print 'emcc: no input files' exit(1) +# read response files very early on +response_file = True +while response_file: + response_file = None + for index in range(1, len(sys.argv)): + if sys.argv[index][0] == '@': + # found one, loop again next time + response_file = sys.argv[index][1:] + if not os.path.exists(response_file): + print >>sys.stderr, 'emcc: error: Response file not found: %s' % response_file + exit(1) + + response_fd = open(response_file, 'r') + extra_args = shlex.split(response_fd.read()) + response_fd.close() + + # slice in extra_args in place of the response file arg + sys.argv[index:index+1] = extra_args + #if DEBUG: print >>sys.stderr, "Expanded response file: " + " | ".join(sys.argv) + break + if sys.argv[1] == '--version': revision = '(unknown revision)' here = os.getcwd() diff --git a/tools/shared.py b/tools/shared.py index c8c09617..6cd28401 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -812,7 +812,25 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e # Finish link actual_files = unique_ordered(actual_files) # tolerate people trying to link a.so a.so etc. if DEBUG: print >>sys.stderr, 'emcc: llvm-linking:', actual_files - output = Popen([LLVM_LINK] + actual_files + ['-o', target], stdout=PIPE).communicate()[0] + + # check for too-long command line + linkcmd = [LLVM_LINK] + actual_files + ['-o', target] + # 8k is a bit of an arbitrary limit, but a reasonable one + # for max command line size before we use a respose file + responseFile = None + if len(" ".join(linkcmd)) > 8192: + [responseFD, responseFile] = mkstemp(suffix='.response', dir=TEMP_DIR) + responseFH = os.fdopen(responseFD, 'w') + for arg in actual_files: + responseFH.write(arg + "\n") + responseFH.close() + linkcmd = [LLVM_LINK, "@" + responseFile, '-o', target] + + output = Popen(linkcmd, stdout=PIPE).communicate()[0] + + if responseFile: + os.unlink(responseFile) + assert os.path.exists(target) and (output is None or 'Could not open input file' not in output), 'Linking error: ' + output for temp_dir in temp_dirs: try_delete(temp_dir) |