aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-10-22 11:41:25 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-10-22 11:41:25 -0700
commitb040c0d6d4896017b1af268d0c89b7575cf3b343 (patch)
tree622af474d68bd6a19082b4f67e417b38b5857ded
parentafc0d5e5cc216043345c3cc6b51af6f0a0772308 (diff)
remove --pre-run option in file packager, handle all that automatically
-rw-r--r--src/postamble.js7
-rw-r--r--tools/file_packager.py31
2 files changed, 15 insertions, 23 deletions
diff --git a/src/postamble.js b/src/postamble.js
index d64fb220..63495914 100644
--- a/src/postamble.js
+++ b/src/postamble.js
@@ -33,12 +33,11 @@ ExitStatus.prototype.constructor = ExitStatus;
var initialStackTop;
var preloadStartTime = null;
var calledMain = false;
-var calledRun = false;
dependenciesFulfilled = function runCaller() {
// If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false)
- if (!calledRun && shouldRunNow) run();
- if (!calledRun) dependenciesFulfilled = runCaller; // try this again later, after new deps are fulfilled
+ if (!Module['calledRun'] && shouldRunNow) run();
+ if (!Module['calledRun']) dependenciesFulfilled = runCaller; // try this again later, after new deps are fulfilled
}
Module['callMain'] = Module.callMain = function callMain(args) {
@@ -128,7 +127,7 @@ function run(args) {
preMain();
- calledRun = true;
+ Module['calledRun'] = true;
if (Module['_main'] && shouldRunNow) {
Module['callMain'](args);
}
diff --git a/tools/file_packager.py b/tools/file_packager.py
index 397e5a57..0696e4da 100644
--- a/tools/file_packager.py
+++ b/tools/file_packager.py
@@ -11,12 +11,7 @@ data downloads.
Usage:
- file_packager.py TARGET [--preload A [B..]] [--embed C [D..]] [--compress COMPRESSION_DATA] [--pre-run] [--crunch[=X]] [--js-output=OUTPUT.js] [--no-force]
-
- --pre-run Will generate wrapper code that does preloading in Module.preRun. This is necessary if you add this
- code before the main file has been loading, which includes necessary components like addRunDependency.
- (This is how emcc --preload-file etc. work, i.e., it is the normal mode of operation. However, for
- data loaded later, say using emscripten_async_load_script, you do not need --pre-run.)
+ file_packager.py TARGET [--preload A [B..]] [--embed C [D..]] [--compress COMPRESSION_DATA] [--crunch[=X]] [--js-output=OUTPUT.js] [--no-force]
--crunch=X Will compress dxt files to crn with quality level X. The crunch commandline tool must be present
and CRUNCH should be defined in ~/.emscripten that points to it. JS crunch decompressing code will
@@ -48,7 +43,7 @@ from shared import Compression, execute, suffix, unsuffixed
from subprocess import Popen, PIPE, STDOUT
if len(sys.argv) == 1:
- print '''Usage: file_packager.py TARGET [--preload A...] [--embed B...] [--compress COMPRESSION_DATA] [--pre-run] [--crunch[=X]] [--js-output=OUTPUT.js] [--no-force] [--use-preload-cache]
+ print '''Usage: file_packager.py TARGET [--preload A...] [--embed B...] [--compress COMPRESSION_DATA] [--crunch[=X]] [--js-output=OUTPUT.js] [--no-force] [--use-preload-cache]
See the source for more details.'''
sys.exit(0)
@@ -71,7 +66,6 @@ in_preload = False
in_embed = False
has_preloaded = False
in_compress = 0
-pre_run = False
crunch = 0
plugins = []
jsoutput = None
@@ -93,11 +87,6 @@ for arg in sys.argv[1:]:
in_compress = 1
in_preload = False
in_embed = False
- elif arg == '--pre-run':
- pre_run = True
- in_preload = False
- in_embed = False
- in_compress = 0
elif arg == '--no-force':
force = False
elif arg == '--use-preload-cache':
@@ -637,16 +626,20 @@ if has_preloaded:
fetchRemotePackage(REMOTE_PACKAGE_NAME, processPackageData, handleError);
'''
-if pre_run:
- ret += '''
+ret += '''
if (typeof Module == 'undefined') Module = {};
if (!Module['preRun']) Module['preRun'] = [];
- Module["preRun"].push(function() {
+ function runWithFS() {
'''
ret += code
-
-if pre_run:
- ret += ' });\n'
+ret += '''
+ }
+ if (Module['calledRun']) {
+ runWithFS();
+ } else {
+ Module["preRun"].push(runWithFS); // FS is not initialized yet, wait for it
+ }
+'''
if crunch:
ret += '''