Fix LZ4 file packaging support when MODULARIZE=1 (#13161)

This is based on work by @mdboom in #7107
This commit is contained in:
Dexter Chua 2021-01-09 06:43:35 +08:00 коммит произвёл GitHub
Родитель 5dc63ff777
Коммит dd827d65d2
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 15 добавлений и 2 удалений

Просмотреть файл

@ -533,4 +533,5 @@ a license to everyone to use it as detailed in LICENSE.)
* Aleksey Kliger <aleksey@lambdageek.org> (copyright owned by Microsoft, Inc.)
* Nicolas Ollinger <nopid@free.fr>
* Michael R. Crusoe <crusoe@debian.org>
* Dexter Chua <dec41@srcf.net>
* Thomas Ballinger <thomasballinger@gmail.com>

Просмотреть файл

@ -1148,6 +1148,9 @@ There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR P
# we also do not support standalone mode in fastcomp.
shared.Settings.STANDALONE_WASM = 1
if shared.Settings.LZ4:
shared.Settings.EXPORTED_RUNTIME_METHODS += ['LZ4']
if shared.Settings.WASM2C:
# wasm2c only makes sense with standalone wasm - there will be no JS,
# just wasm and then C

9
tests/test_browser.py поставляемый
Просмотреть файл

@ -1383,6 +1383,15 @@ keydown(100);keyup(100); // trigger the end
self.btest(os.path.join('fs', 'test_lz4fs.cpp'), '2', args=['--pre-js', 'files.js', '-s', 'LZ4=1', '-s', 'FORCE_FILESYSTEM'])
print(' opts')
self.btest(os.path.join('fs', 'test_lz4fs.cpp'), '2', args=['--pre-js', 'files.js', '-s', 'LZ4=1', '-s', 'FORCE_FILESYSTEM', '-O2'])
print(' modularize')
self.compile_btest([path_from_root('tests', 'fs', 'test_lz4fs.cpp'), '--pre-js', 'files.js', '-s', 'LZ4=1', '-s', 'FORCE_FILESYSTEM', '-s', 'MODULARIZE=1'])
create_test_file('a.html', '''
<script src="a.out.js"></script>
<script>
Module()
</script>
''')
self.run_browser('a.html', '.', '/report_result?2')
# load the data into LZ4FS manually at runtime. This means we compress on the client. This is generally not recommended
print('manual')

Просмотреть файл

@ -514,8 +514,8 @@ def main():
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 });
assert(typeof Module.LZ4 === 'object', 'LZ4 not present - was your app build with -s LZ4=1 ?');
Module.LZ4.loadPackage({ 'metadata': metadata, 'compressedData': compressedData });
Module['removeRunDependency']('datafile_%s');
''' % (meta, shared.JS.escape_for_js_string(data_target))