aboutsummaryrefslogtreecommitdiff
path: root/tools/shared.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/shared.py')
-rw-r--r--tools/shared.py36
1 files changed, 24 insertions, 12 deletions
diff --git a/tools/shared.py b/tools/shared.py
index 72f4868e..6b5ad835 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -2,6 +2,7 @@ import shutil, time, os, sys, json, tempfile, copy, shlex, atexit, subprocess, h
from subprocess import Popen, PIPE, STDOUT
from tempfile import mkstemp
import jsrun, cache, tempfiles
+from response_file import create_response_file
def listify(x):
if type(x) is not list: return [x]
@@ -34,9 +35,15 @@ class WindowsPopen:
self.stdout_ = PIPE
if self.stderr_ == None:
self.stderr_ = PIPE
-
- # Call the process with fixed streams.
+
+ # 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]
+
try:
+ # Call the process with fixed streams.
self.process = subprocess.Popen(args, bufsize, executable, self.stdin_, self.stdout_, self.stderr_, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags)
except Exception, e:
print >> sys.stderr, '\nsubprocess.Popen(args=%s) failed! Exception %s\n' % (' '.join(args), str(e))
@@ -67,6 +74,13 @@ 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.
# Install our replacement Popen handler if we are running on Windows to avoid python spawn process function.
if os.name == 'nt':
@@ -385,13 +399,10 @@ try:
except:
COMPILER_OPTS = []
# Force a simple, standard target as much as possible: target 32-bit linux, and disable various flags that hint at other platforms
-# -fno-ms-compatibility is passed, since on Windows, Clang enables a 'MS compatibility mode' by default, that disables char16_t and char32_t
-# to be MSVC header -compatible. This would cause build errors in libcxx file __config.
-# -fno-delayed-template-parsing is needed on Windows due to http://llvm.org/PR15651
-COMPILER_OPTS = COMPILER_OPTS + ['-m32', '-U__i386__', '-U__x86_64__', '-U__i386', '-U__x86_64', '-Ui386', '-Ux86_64', '-U__SSE__', '-U__SSE2__', '-U__MMX__',
- '-UX87_DOUBLE_ROUNDING', '-UHAVE_GCC_ASM_FOR_X87', '-DEMSCRIPTEN', '-U__STRICT_ANSI__', '-U__CYGWIN__',
- '-D__STDC__', '-Xclang', '-triple=i386-pc-linux-gnu', '-D__IEEE_LITTLE_ENDIAN', '-fno-math-errno',
- '-fno-ms-compatibility', '-fno-delayed-template-parsing']
+COMPILER_OPTS = COMPILER_OPTS + ['-m32', '-U__i386__', '-U__i386', '-Ui386',
+ '-U__SSE__', '-U__SSE_MATH__', '-U__SSE2__', '-U__SSE2_MATH__', '-U__MMX__',
+ '-DEMSCRIPTEN', '-U__STRICT_ANSI__',
+ '-target', 'i386-pc-linux-gnu', '-D__IEEE_LITTLE_ENDIAN', '-fno-math-errno']
USE_EMSDK = not os.environ.get('EMMAKEN_NO_SDK')
@@ -553,6 +564,7 @@ class Settings:
@classmethod
def apply_opt_level(self, opt_level, noisy=False):
if opt_level >= 1:
+ Settings.ASM_JS = 1
Settings.ASSERTIONS = 0
Settings.DISABLE_EXCEPTION_CATCHING = 1
Settings.EMIT_GENERATED_FUNCTIONS = 1
@@ -718,13 +730,13 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e
basename = os.path.basename(f)
cache[cache_name].append((basename, open(f, 'rb').read()))
break
- except:
+ except Exception, e:
if i > 0:
# Due to the ugly hack above our best guess is to output the first run
with open_make_err(0) as ferr:
for line in ferr:
sys.stderr.write(line)
- raise Exception('could not build library ' + name)
+ raise Exception('could not build library ' + name + ' due to exception ' + str(e))
if old_dir:
os.chdir(old_dir)
return generated_libs
@@ -1151,7 +1163,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e
Building.emcc(os.path.join('relooper', 'Relooper.cpp'), ['-I' + os.path.join('relooper'), '--post-js',
os.path.join('relooper', 'emscripten', 'glue.js'),
'--memory-init-file', '0',
- '-s', 'TOTAL_MEMORY=52428800',
+ '-s', 'TOTAL_MEMORY=67108864',
'-s', 'EXPORTED_FUNCTIONS=["_rl_set_output_buffer","_rl_make_output_buffer","_rl_new_block","_rl_delete_block","_rl_block_add_branch_to","_rl_new_relooper","_rl_delete_relooper","_rl_relooper_add_block","_rl_relooper_calculate","_rl_relooper_render", "_rl_set_asm_js_mode"]',
'-s', 'DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=["memcpy", "memset", "malloc", "free", "puts"]',
'-s', 'RELOOPER="' + relooper + '"',