diff options
author | Lars Schneider <lars.schneider@autodesk.com> | 2012-09-25 14:44:54 +0200 |
---|---|---|
committer | Lars Schneider <lars.schneider@autodesk.com> | 2012-09-26 19:30:19 +0200 |
commit | 0c33345f226af403d15f5f83811488aead85b71b (patch) | |
tree | cc1787e201bb3184fb901500e94175f22d322c6a /emcc | |
parent | c74da50989604747e3174429d0538f668b4ff7e7 (diff) |
Add emcc option "--split <size>" to split javascript file.
Splits the resulting javascript file into pieces to ease debugging.
This option only works if Javascript is generated (target -o <name>.js).
Files with function declarations must be loaded before main file upon execution.
Without "-g" option:
Creates files with function declarations up to the given size with the suffix "_functions.partxxx.js" and a main file with the suffix ".js".
With "-g" option:
Recreates the directory structure of the C source files and stores function declarations in their respective C files with the suffix ".js". If such a file exceeds the given size, files with the suffix ".partxxx.js" are created. The main file resides in the base directory and has the suffix ".js".
Diffstat (limited to 'emcc')
-rwxr-xr-x | emcc | 38 |
1 files changed, 36 insertions, 2 deletions
@@ -268,6 +268,27 @@ Options that are modified or new in %s include: will not minify the code (closure does that) + --split <size> Splits the resulting javascript file into pieces + to ease debugging. This option only works if + Javascript is generated (target -o <name>.js). + Files with function declarations must be loaded + before main file upon execution. + + Without "-g" option: + Creates files with function declarations up + to the given size with the suffix + "_functions.partxxx.js" and a main file with + the suffix ".js". + + With "-g" option: + Recreates the directory structure of the C + source files and stores function declarations + in their respective C files with the suffix + ".js". If such a file exceeds the given size, + files with the suffix ".partxxx.js" are created. + The main file resides in the base directory and + has the suffix ".js". + --ignore-dynamic-linking Normally emcc will treat dynamic linking like static linking, by linking in the code from the dynamic library. This fails if the same @@ -471,6 +492,7 @@ try: pre_js = '' post_js = '' minify_whitespace = None + split_js_file = None preload_files = [] embed_files = [] compression = None @@ -527,6 +549,11 @@ try: minify_whitespace = int(newargs[i+1]) newargs[i] = '' newargs[i+1] = '' + elif newargs[i].startswith('--split'): + check_bad_eq(newargs[i]) + split_js_file = int(newargs[i+1]) + newargs[i] = '' + newargs[i+1] = '' elif newargs[i].startswith('--embed-file'): check_bad_eq(newargs[i]) embed_files.append(newargs[i+1]) @@ -601,6 +628,9 @@ try: newargs[i+1] = '' newargs = [ arg for arg in newargs if arg is not '' ] + if split_js_file: + settings_changes.append("PRINT_SPLIT_FILE_MARKER=1") + # Find input files input_files = [] @@ -1071,8 +1101,12 @@ try: html.close() else: - # copy final JS to output - shutil.move(final, target) + if split_js_file: + from tools.split import split_javascript_file + split_javascript_file(final, unsuffixed(target), split_js_file) + else: + # copy final JS to output + shutil.move(final, target) finally: if not TEMP_DIR: |