| 
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.  | 
@@ -129,7 +129,6 @@ def __init__(self):  | 
129 | 129 |     self.use_preload_plugins = False  | 
130 | 130 |     self.support_node = True  | 
131 | 131 |     self.wasm64 = False  | 
132 |  | -    self.modularize = False  | 
133 | 132 | 
 
  | 
134 | 133 | 
 
  | 
135 | 134 | class DataFile:  | 
@@ -159,8 +158,7 @@ def has_hidden_attribute(filepath):  | 
159 | 158 |     return False  | 
160 | 159 | 
 
  | 
161 | 160 |   try:  | 
162 |  | -    attrs = ctypes.windll.kernel32.GetFileAttributesW(  | 
163 |  | -        '%s' % filepath)  | 
 | 161 | +    attrs = ctypes.windll.kernel32.GetFileAttributesW(filepath)  | 
164 | 162 |     assert attrs != -1  | 
165 | 163 |     result = bool(attrs & 2)  | 
166 | 164 |   except Exception:  | 
@@ -320,8 +318,6 @@ def generate_object_file(data_files):  | 
320 | 318 |       # A list of triples of:  | 
321 | 319 |       # (file_name_ptr, file_data_size, file_data_ptr)  | 
322 | 320 |       # The list in null terminate with a single 0  | 
323 |  | -      .globl __emscripten_embedded_file_data  | 
324 |  | -      .export_name __emscripten_embedded_file_data, __emscripten_embedded_file_data  | 
325 | 321 |       .section .rodata.__emscripten_embedded_file_data,"",@  | 
326 | 322 |       __emscripten_embedded_file_data:  | 
327 | 323 |       .p2align {align}  | 
@@ -366,16 +362,26 @@ def main():  # noqa: C901, PLR0912, PLR0915  | 
366 | 362 |   To revalidate these numbers, run `ruff check --select=C901,PLR091`.  | 
367 | 363 |   """  | 
368 | 364 |   if len(sys.argv) == 1:  | 
369 |  | -    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]  | 
370 |  | -  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.''')  | 
371 | 367 |     return 1  | 
372 | 368 | 
 
  | 
373 |  | -  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]  | 
374 | 380 |   data_files = []  | 
375 | 381 |   plugins = []  | 
376 | 382 |   leading = ''  | 
377 | 383 | 
 
  | 
378 |  | -  for arg in sys.argv[2:]:  | 
 | 384 | +  for arg in args[1:]:  | 
379 | 385 |     if arg == '--preload':  | 
380 | 386 |       leading = 'preload'  | 
381 | 387 |     elif arg == '--embed':  | 
@@ -629,19 +635,19 @@ def generate_js(data_target, data_files, metadata):  | 
629 | 635 |       ret = '''  | 
630 | 636 |   var Module = typeof %(EXPORT_NAME)s != 'undefined' ? %(EXPORT_NAME)s : {};\n''' % {"EXPORT_NAME": options.export_name}  | 
631 | 637 | 
 
  | 
632 |  | -  ret +=  '''  | 
 | 638 | +  ret += '''  | 
633 | 639 |   Module['expectedDataFileDownloads'] ??= 0;  | 
634 | 640 |   Module['expectedDataFileDownloads']++;'''  | 
635 | 641 | 
 
  | 
636 | 642 |   if not options.modularize:  | 
637 |  | -    ret +=  '''  | 
 | 643 | +    ret += '''  | 
638 | 644 |   (() => {'''  | 
639 | 645 | 
 
  | 
640 |  | -  ret +=  '''  | 
641 |  | -  // Do not attempt to redownload the virtual filesystem data when in a pthread or a Wasm Worker context.  | 
642 |  | -  var isPthread = typeof ENVIRONMENT_IS_PTHREAD != 'undefined' && ENVIRONMENT_IS_PTHREAD;  | 
643 |  | -  var isWasmWorker = typeof ENVIRONMENT_IS_WASM_WORKER != 'undefined' && ENVIRONMENT_IS_WASM_WORKER;  | 
644 |  | -  if (isPthread || isWasmWorker) return;\n'''  | 
 | 646 | +  ret += '''  | 
 | 647 | +    // Do not attempt to redownload the virtual filesystem data when in a pthread or a Wasm Worker context.  | 
 | 648 | +    var isPthread = typeof ENVIRONMENT_IS_PTHREAD != 'undefined' && ENVIRONMENT_IS_PTHREAD;  | 
 | 649 | +    var isWasmWorker = typeof ENVIRONMENT_IS_WASM_WORKER != 'undefined' && ENVIRONMENT_IS_WASM_WORKER;  | 
 | 650 | +    if (isPthread || isWasmWorker) return;\n'''  | 
645 | 651 | 
 
  | 
646 | 652 |   if options.support_node:  | 
647 | 653 |     ret += "    var isNode = typeof process === 'object' && typeof process.versions === 'object' && typeof process.versions.node === 'string';\n"  | 
@@ -822,13 +828,7 @@ def generate_js(data_target, data_files, metadata):  | 
822 | 828 |               return errback();  | 
823 | 829 |             }'''  | 
824 | 830 |       code += '''  | 
825 |  | -          var indexedDB;  | 
826 |  | -          if (typeof window === 'object') {  | 
827 |  | -            indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;  | 
828 |  | -          } else if (typeof location !== 'undefined') {  | 
829 |  | -            // worker  | 
830 |  | -            indexedDB = self.indexedDB;  | 
831 |  | -          } else {  | 
 | 831 | +          if (typeof indexedDB == 'undefined') {  | 
832 | 832 |             throw 'using IndexedDB to cache data can only be done on a web page or in a web worker';  | 
833 | 833 |           }  | 
834 | 834 |           try {  | 
 | 
0 commit comments