aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-03-10 13:08:23 -0700
committerAlon Zakai <alonzakai@gmail.com>2014-03-10 13:24:37 -0700
commit54b0f19d9e8130de16053b0915d114c346c99f17 (patch)
treec4e90ccb7192af726cd292e228e3a0e715b4b86a
parent501fdd709bbab7b2c11639f5a1df45123193b69b (diff)
forward CLOSURE_COMPILER to settings, and use that to avoid a closure-specific workaround for Module detection; fixes #2209
-rwxr-xr-xemcc7
-rw-r--r--src/settings.js1
-rw-r--r--src/shell.js4
3 files changed, 9 insertions, 3 deletions
diff --git a/emcc b/emcc
index de782071..0454b3b8 100755
--- a/emcc
+++ b/emcc
@@ -1034,9 +1034,6 @@ try:
if DEBUG: start_time = time.time() # done after parsing arguments, which might affect debug state
- if closure:
- assert os.path.exists(shared.CLOSURE_COMPILER), logging.error('fatal: Closure compiler (%s) does not exist', shared.CLOSURE_COMPILER)
-
for i in range(len(newargs)):
if newargs[i] == '-s':
if is_minus_s_for_emcc(newargs, i):
@@ -1252,6 +1249,10 @@ try:
logging.warning('disabling closure because debug info was requested')
closure = False
+ if closure:
+ shared.Settings.CLOSURE_COMPILER = 1
+ assert os.path.exists(shared.CLOSURE_COMPILER), logging.error('fatal: Closure compiler (%s) does not exist', shared.CLOSURE_COMPILER)
+
assert shared.LLVM_TARGET in shared.COMPILER_OPTS
if shared.LLVM_TARGET == 'i386-pc-linux-gnu':
shared.Settings.TARGET_X86 = 1
diff --git a/src/settings.js b/src/settings.js
index 02f6c8b5..1c41676d 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -133,6 +133,7 @@ var PRECISE_F32 = 0; // 0: Use JS numbers for floating-point values. These are 6
// therefore recommended.
var SIMD = 0; // Whether to emit SIMD code ( https://github.com/johnmccutchan/ecmascript_simd )
+var CLOSURE_COMPILER = 0; // Whether closure compiling is being run on this output
var CLOSURE_ANNOTATIONS = 0; // If set, the generated code will be annotated for the closure
// compiler. This potentially lets closure optimize the code better.
diff --git a/src/shell.js b/src/shell.js
index 65f7b923..e1c0eb54 100644
--- a/src/shell.js
+++ b/src/shell.js
@@ -14,7 +14,11 @@
// before the code. Then that object will be used in the code, and you
// can continue to use Module afterwards as well.
var Module;
+#if CLOSURE_COMPILER
if (!Module) Module = eval('(function() { try { return {{{ EXPORT_NAME }}} || {} } catch(e) { return {} } })()');
+#else
+if (!Module) Module = (typeof {{{ EXPORT_NAME }}} !== 'undefined' ? {{{ EXPORT_NAME }}} : null) || {};
+#endif
// Sometimes an existing Module object exists with properties
// meant to overwrite the default module functionality. Here