aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-10-21 17:36:03 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-10-21 17:36:03 -0700
commite0c3cd79dbfb4b1f5230b9a1589a3b1bedaa387d (patch)
treece9ef8d214397381dfaacf87b5440744ae794514
parent60e3202da0db59b42a6702c96b06f3899dbf09f2 (diff)
add file handling code from --preload-file etc. in a pre-js, so that it will be able to start network access as early as possible
-rwxr-xr-xemcc9
-rw-r--r--tools/file_packager.py2
2 files changed, 5 insertions, 6 deletions
diff --git a/emcc b/emcc
index 2aa223db..4222caa3 100755
--- a/emcc
+++ b/emcc
@@ -1654,7 +1654,7 @@ try:
# Embed and preload files
if len(preload_files) + len(embed_files) > 0:
logging.debug('setting up files')
- file_args = []
+ file_args = ['--pre-run']
if len(preload_files) > 0:
file_args.append('--preload')
file_args += preload_files
@@ -1665,11 +1665,8 @@ try:
file_args += ['--compress', Compression.encoder, Compression.decoder, Compression.js_name]
if use_preload_cache:
file_args.append('--use-preload-cache')
- code = execute([shared.PYTHON, shared.FILE_PACKAGER, unsuffixed(target) + '.data'] + file_args, stdout=PIPE)[0]
- src = open(final).read().replace('// {{PRE_RUN_ADDITIONS}}', '// {{PRE_RUN_ADDITIONS}}\n' + code)
- final += '.files.js'
- open(final, 'w').write(src)
- if DEBUG: save_intermediate('files')
+ file_code = execute([shared.PYTHON, shared.FILE_PACKAGER, unsuffixed(target) + '.data'] + file_args, stdout=PIPE)[0]
+ pre_js = file_code + pre_js
# Apply pre and postjs files
if pre_js or post_js:
diff --git a/tools/file_packager.py b/tools/file_packager.py
index ea314be7..1180870b 100644
--- a/tools/file_packager.py
+++ b/tools/file_packager.py
@@ -15,6 +15,8 @@ Usage:
--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.)
--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