aboutsummaryrefslogtreecommitdiff
path: root/tools/shared.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/shared.py')
-rw-r--r--tools/shared.py71
1 files changed, 46 insertions, 25 deletions
diff --git a/tools/shared.py b/tools/shared.py
index 25455ff6..25c17688 100644
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -200,29 +200,33 @@ def check_node_version():
# we re-check sanity when the settings are changed)
# We also re-check sanity and clear the cache when the version changes
-EMSCRIPTEN_VERSION = '1.3.8'
+EMSCRIPTEN_VERSION = '1.4.1'
+
+def generate_sanity():
+ return EMSCRIPTEN_VERSION + '|' + LLVM_TARGET
def check_sanity(force=False):
try:
- if not force:
- if not CONFIG_FILE:
- return # config stored directly in EM_CONFIG => skip sanity checks
+ reason = None
+ if not CONFIG_FILE:
+ if not force: return # config stored directly in EM_CONFIG => skip sanity checks
+ else:
settings_mtime = os.stat(CONFIG_FILE).st_mtime
sanity_file = CONFIG_FILE + '_sanity'
- reason = 'unknown'
- try:
- sanity_mtime = os.stat(sanity_file).st_mtime
- if sanity_mtime <= settings_mtime:
- reason = 'settings file has changed'
- else:
- sanity_version = open(sanity_file).read()
- if sanity_version != EMSCRIPTEN_VERSION:
- reason = 'version bump'
+ if os.path.exists(sanity_file):
+ try:
+ sanity_mtime = os.stat(sanity_file).st_mtime
+ if sanity_mtime <= settings_mtime:
+ reason = 'settings file has changed'
else:
- return # all is well
- except:
- pass
-
+ sanity_data = open(sanity_file).read()
+ if sanity_data != generate_sanity():
+ reason = 'system change: %s vs %s' % (generate_sanity(), sanity_data)
+ else:
+ if not force: return # all is well
+ except Exception, e:
+ reason = 'unknown: ' + str(e)
+ if reason:
print >> sys.stderr, '(Emscripten: %s, clearing cache)' % reason
Cache.erase()
@@ -263,7 +267,7 @@ def check_sanity(force=False):
if not force:
# Only create/update this file if the sanity check succeeded, i.e., we got here
f = open(sanity_file, 'w')
- f.write(EMSCRIPTEN_VERSION)
+ f.write(generate_sanity())
f.close()
except Exception, e:
@@ -395,6 +399,9 @@ except:
# Additional compiler options
+# Target choice. Must be synced with src/settings.js (TARGET_*)
+LLVM_TARGET = os.environ.get('EMCC_LLVM_TARGET') or 'i386-pc-linux-gnu' # 'le32-unknown-nacl'
+
try:
COMPILER_OPTS # Can be set in EM_CONFIG, optionally
except:
@@ -403,7 +410,8 @@ except:
COMPILER_OPTS = COMPILER_OPTS + ['-m32', '-U__i386__', '-U__i386', '-Ui386',
'-U__SSE__', '-U__SSE_MATH__', '-U__SSE2__', '-U__SSE2_MATH__', '-U__MMX__',
'-DEMSCRIPTEN', '-D__EMSCRIPTEN__', '-U__STRICT_ANSI__',
- '-target', 'i386-pc-linux-gnu', '-D__IEEE_LITTLE_ENDIAN', '-fno-math-errno']
+ '-D__IEEE_LITTLE_ENDIAN', '-fno-math-errno',
+ '-target', LLVM_TARGET]
USE_EMSDK = not os.environ.get('EMMAKEN_NO_SDK')
@@ -658,11 +666,14 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e
if 'cmake' in args[0]:
args = Building.handle_CMake_toolchain(args, env)
try:
- Popen(args, stdout=stdout, stderr=stderr, env=env).communicate()
+ process = Popen(args, stdout=stdout, stderr=stderr, env=env)
+ process.communicate()
except Exception, e:
print >> sys.stderr, 'Error: Exception thrown when invoking Popen in configure with args: "%s"!' % ' '.join(args)
raise
del env['EMMAKEN_JUST_CONFIGURE']
+ if process.returncode is not 0:
+ raise subprocess.CalledProcessError(cmd=args, returncode=process.returncode)
@staticmethod
def make(args, stdout=None, stderr=None, env=None):
@@ -673,10 +684,14 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e
sys.exit(1)
#args += ['VERBOSE=1']
try:
- Popen(args, stdout=stdout, stderr=stderr, env=env).communicate()
+ process = Popen(args, stdout=stdout, stderr=stderr, env=env)
+ process.communicate()
except Exception, e:
print >> sys.stderr, 'Error: Exception thrown when invoking Popen in make with args: "%s"!' % ' '.join(args)
raise
+ if process.returncode is not 0:
+ raise subprocess.CalledProcessError(cmd=args, returncode=process.returncode)
+
@staticmethod
def build_library(name, build_dir, output_dir, generated_libs, configure=['sh', './configure'], configure_args=[], make=['make'], make_args=['-j', '2'], cache=None, cache_name=None, copy_project=False, env_init={}, source_dir=None, native=False):
@@ -711,8 +726,11 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e
for k, v in env_init.iteritems():
env[k] = v
if configure: # Useful in debugging sometimes to comment this out (and the lines below up to and including the |link| call)
- Building.configure(configure + configure_args, stdout=open(os.path.join(project_dir, 'configure_'), 'w'),
- stderr=open(os.path.join(project_dir, 'configure_err'), 'w'), env=env)
+ try:
+ Building.configure(configure + configure_args, stdout=open(os.path.join(project_dir, 'configure_'), 'w'),
+ stderr=open(os.path.join(project_dir, 'configure_err'), 'w'), env=env)
+ except subprocess.CalledProcessError, e:
+ pass # Ignore exit code != 0
def open_make_out(i, mode='r'):
return open(os.path.join(project_dir, 'make_' + str(i)), mode)
@@ -722,8 +740,11 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e
for i in range(2): # FIXME: Sad workaround for some build systems that need to be run twice to succeed (e.g. poppler)
with open_make_out(i, 'w') as make_out:
with open_make_err(i, 'w') as make_err:
- Building.make(make + make_args, stdout=make_out,
- stderr=make_err, env=env)
+ try:
+ Building.make(make + make_args, stdout=make_out,
+ stderr=make_err, env=env)
+ except subprocess.CalledProcessError, e:
+ pass # Ignore exit code != 0
try:
if cache is not None:
cache[cache_name] = []