Created
November 15, 2019 12:46
-
-
Save MarcosCobena/0e2ebd948fd51c868693f9655f527928 to your computer and use it in GitHub Desktop.
Patch to make file_packager.py work standalone (Emscripten master 04d13b99d0630496139fa8f424c62aad65588c7b)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- ../Repositorios/mono/sdks/builds/toolchains/emsdk/upstream/emscripten/tools/file_packager.py 2019-11-06 18:50:40.000000000 +0100 | |
| +++ file_packager.py 2019-11-15 11:26:57.394870824 +0100 | |
| @@ -69,13 +69,13 @@ | |
| sys.path.insert(1, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | |
| -from tools.toolchain_profiler import ToolchainProfiler | |
| -if __name__ == '__main__': | |
| - ToolchainProfiler.record_process_start() | |
| - | |
| import posixpath | |
| -from tools import shared | |
| -from tools.jsrun import run_js | |
| + | |
| +# Taken from shared.py | |
| +def escape_for_js_string(s): | |
| + s = s.replace('\\', '/').replace("'", "\\'").replace('"', '\\"') | |
| + return s | |
| + | |
| from subprocess import PIPE | |
| import fnmatch | |
| import json | |
| @@ -516,24 +516,12 @@ | |
| } | |
| ''' | |
| use_data += (" Module['removeRunDependency']('datafile_%s');\n" | |
| - % shared.JS.escape_for_js_string(data_target)) | |
| + % escape_for_js_string(data_target)) | |
| else: | |
| # LZ4FS usage | |
| - temp = data_target + '.orig' | |
| - shutil.move(data_target, temp) | |
| - meta = run_js(shared.path_from_root('tools', 'lz4-compress.js'), | |
| - shared.NODE_JS, | |
| - [shared.path_from_root('src', 'mini-lz4.js'), | |
| - temp, data_target], stdout=PIPE) | |
| - os.unlink(temp) | |
| - use_data = ''' | |
| - var compressedData = %s; | |
| - compressedData['data'] = byteArray; | |
| - assert(typeof LZ4 === 'object', 'LZ4 not present - was your app build with -s LZ4=1 ?'); | |
| - LZ4.loadPackage({ 'metadata': metadata, 'compressedData': compressedData }); | |
| - Module['removeRunDependency']('datafile_%s'); | |
| - ''' % (meta, shared.JS.escape_for_js_string(data_target)) | |
| + print('Error: LZ4 is intentionally disabled; please refer to a complete Emscripten\'s file_packager.py') | |
| + sys.exit(1) | |
| package_uuid = uuid.uuid4() | |
| package_name = data_target | |
| @@ -556,8 +544,8 @@ | |
| err('warning: you defined Module.locateFilePackage, that has been renamed to Module.locateFile (using your locateFilePackage for now)'); | |
| } | |
| var REMOTE_PACKAGE_NAME = Module['locateFile'] ? Module['locateFile'](REMOTE_PACKAGE_BASE, '') : REMOTE_PACKAGE_BASE; | |
| - ''' % (shared.JS.escape_for_js_string(data_target), | |
| - shared.JS.escape_for_js_string(remote_package_name)) | |
| + ''' % (escape_for_js_string(data_target), | |
| + escape_for_js_string(remote_package_name)) | |
| metadata['remote_package_size'] = remote_package_size | |
| metadata['package_uuid'] = str(package_uuid) | |
| ret += ''' | |
| @@ -784,7 +772,7 @@ | |
| %s | |
| }; | |
| Module['addRunDependency']('datafile_%s'); | |
| - ''' % (use_data, shared.JS.escape_for_js_string(data_target)) | |
| + ''' % (use_data, escape_for_js_string(data_target)) | |
| # use basename because from the browser's point of view, | |
| # we need to find the datafile in the same dir as the html file | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment