|
21 | 21 |
|
22 | 22 | Usage:
|
23 | 23 |
|
24 |
| - file_packager TARGET [--preload A [B..]] [--embed C [D..]] [--exclude E [F..]]] [--js-output=OUTPUT.js] [--no-force] [--use-preload-cache] [--indexedDB-name=EM_PRELOAD_CACHE] [--separate-metadata] [--lz4] [--use-preload-plugins] [--no-node] |
| 24 | + file_packager TARGET [--preload A [B..]] [--embed C [D..]] [--exclude E [F..]] [--js-output=OUTPUT.js] [--no-force] [--use-preload-cache] [--indexedDB-name=EM_PRELOAD_CACHE] [--separate-metadata] [--lz4] [--use-preload-plugins] [--no-node] [--help] |
25 | 25 |
|
26 | 26 | --preload ,
|
27 | 27 | --embed See emcc --help for more details on those options.
|
|
84 | 84 | sys.path.insert(0, __rootdir__)
|
85 | 85 |
|
86 | 86 | from tools import shared, utils, js_manipulation
|
| 87 | +from tools.response_file import substitute_response_files |
87 | 88 |
|
88 | 89 |
|
89 | 90 | DEBUG = os.environ.get('EMCC_DEBUG')
|
@@ -128,7 +129,6 @@ def __init__(self):
|
128 | 129 | self.use_preload_plugins = False
|
129 | 130 | self.support_node = True
|
130 | 131 | self.wasm64 = False
|
131 |
| - self.modularize = False |
132 | 132 |
|
133 | 133 |
|
134 | 134 | class DataFile:
|
@@ -158,8 +158,7 @@ def has_hidden_attribute(filepath):
|
158 | 158 | return False
|
159 | 159 |
|
160 | 160 | try:
|
161 |
| - attrs = ctypes.windll.kernel32.GetFileAttributesW( |
162 |
| - '%s' % filepath) |
| 161 | + attrs = ctypes.windll.kernel32.GetFileAttributesW(filepath) |
163 | 162 | assert attrs != -1
|
164 | 163 | result = bool(attrs & 2)
|
165 | 164 | except Exception:
|
@@ -319,8 +318,6 @@ def generate_object_file(data_files):
|
319 | 318 | # A list of triples of:
|
320 | 319 | # (file_name_ptr, file_data_size, file_data_ptr)
|
321 | 320 | # The list in null terminate with a single 0
|
322 |
| - .globl __emscripten_embedded_file_data |
323 |
| - .export_name __emscripten_embedded_file_data, __emscripten_embedded_file_data |
324 | 321 | .section .rodata.__emscripten_embedded_file_data,"",@
|
325 | 322 | __emscripten_embedded_file_data:
|
326 | 323 | .p2align {align}
|
@@ -365,16 +362,26 @@ def main(): # noqa: C901, PLR0912, PLR0915
|
365 | 362 | To revalidate these numbers, run `ruff check --select=C901,PLR091`.
|
366 | 363 | """
|
367 | 364 | if len(sys.argv) == 1:
|
368 |
| - err('''Usage: file_packager TARGET [--preload A [B..]] [--embed C [D..]] [--exclude E [F..]]] [--js-output=OUTPUT.js] [--no-force] [--use-preload-cache] [--indexedDB-name=EM_PRELOAD_CACHE] [--separate-metadata] [--lz4] [--use-preload-plugins] [--no-node] |
369 |
| - See the source for more details.''') |
| 365 | + err('''Usage: file_packager TARGET [--preload A [B..]] [--embed C [D..]] [--exclude E [F..]] [--js-output=OUTPUT.js] [--no-force] [--use-preload-cache] [--indexedDB-name=EM_PRELOAD_CACHE] [--separate-metadata] [--lz4] [--use-preload-plugins] [--no-node] [--help] |
| 366 | + Try 'file_packager --help' for more details.''') |
370 | 367 | return 1
|
371 | 368 |
|
372 |
| - data_target = sys.argv[1] |
| 369 | + # read response files very early on |
| 370 | + try: |
| 371 | + args = substitute_response_files(sys.argv[1:]) |
| 372 | + except OSError as e: |
| 373 | + shared.exit_with_error(e) |
| 374 | + |
| 375 | + if '--help' in args: |
| 376 | + print(__doc__.strip()) |
| 377 | + return 0 |
| 378 | + |
| 379 | + data_target = args[0] |
373 | 380 | data_files = []
|
374 | 381 | plugins = []
|
375 | 382 | leading = ''
|
376 | 383 |
|
377 |
| - for arg in sys.argv[2:]: |
| 384 | + for arg in args[1:]: |
378 | 385 | if arg == '--preload':
|
379 | 386 | leading = 'preload'
|
380 | 387 | elif arg == '--embed':
|
@@ -623,19 +630,19 @@ def generate_js(data_target, data_files, metadata):
|
623 | 630 | ret = '''
|
624 | 631 | var Module = typeof %(EXPORT_NAME)s != 'undefined' ? %(EXPORT_NAME)s : {};\n''' % {"EXPORT_NAME": options.export_name}
|
625 | 632 |
|
626 |
| - ret += ''' |
| 633 | + ret += ''' |
627 | 634 | Module['expectedDataFileDownloads'] ??= 0;
|
628 | 635 | Module['expectedDataFileDownloads']++;'''
|
629 | 636 |
|
630 | 637 | if not options.modularize:
|
631 |
| - ret += ''' |
| 638 | + ret += ''' |
632 | 639 | (() => {'''
|
633 | 640 |
|
634 |
| - ret += ''' |
635 |
| - // Do not attempt to redownload the virtual filesystem data when in a pthread or a Wasm Worker context. |
636 |
| - var isPthread = typeof ENVIRONMENT_IS_PTHREAD != 'undefined' && ENVIRONMENT_IS_PTHREAD; |
637 |
| - var isWasmWorker = typeof ENVIRONMENT_IS_WASM_WORKER != 'undefined' && ENVIRONMENT_IS_WASM_WORKER; |
638 |
| - if (isPthread || isWasmWorker) return;\n''' |
| 641 | + ret += ''' |
| 642 | + // Do not attempt to redownload the virtual filesystem data when in a pthread or a Wasm Worker context. |
| 643 | + var isPthread = typeof ENVIRONMENT_IS_PTHREAD != 'undefined' && ENVIRONMENT_IS_PTHREAD; |
| 644 | + var isWasmWorker = typeof ENVIRONMENT_IS_WASM_WORKER != 'undefined' && ENVIRONMENT_IS_WASM_WORKER; |
| 645 | + if (isPthread || isWasmWorker) return;\n''' |
639 | 646 |
|
640 | 647 | if options.support_node:
|
641 | 648 | ret += " var isNode = typeof process === 'object' && typeof process.versions === 'object' && typeof process.versions.node === 'string';\n"
|
@@ -816,13 +823,7 @@ def generate_js(data_target, data_files, metadata):
|
816 | 823 | return errback();
|
817 | 824 | }'''
|
818 | 825 | code += '''
|
819 |
| - var indexedDB; |
820 |
| - if (typeof window === 'object') { |
821 |
| - indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB; |
822 |
| - } else if (typeof location !== 'undefined') { |
823 |
| - // worker |
824 |
| - indexedDB = self.indexedDB; |
825 |
| - } else { |
| 826 | + if (typeof indexedDB == 'undefined') { |
826 | 827 | throw 'using IndexedDB to cache data can only be done on a web page or in a web worker';
|
827 | 828 | }
|
828 | 829 | try {
|
|
0 commit comments