Skip to content

Commit 7fffe91

Browse files
committed
revert file to the most actual version and apply changes
1 parent c4a9ea9 commit 7fffe91

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

tools/file_packager.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
2222
Usage:
2323
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]
2525
2626
--preload ,
2727
--embed See emcc --help for more details on those options.
@@ -129,7 +129,6 @@ def __init__(self):
129129
self.use_preload_plugins = False
130130
self.support_node = True
131131
self.wasm64 = False
132-
self.modularize = False
133132

134133

135134
class DataFile:
@@ -159,8 +158,7 @@ def has_hidden_attribute(filepath):
159158
return False
160159

161160
try:
162-
attrs = ctypes.windll.kernel32.GetFileAttributesW(
163-
'%s' % filepath)
161+
attrs = ctypes.windll.kernel32.GetFileAttributesW(filepath)
164162
assert attrs != -1
165163
result = bool(attrs & 2)
166164
except Exception:
@@ -320,8 +318,6 @@ def generate_object_file(data_files):
320318
# A list of triples of:
321319
# (file_name_ptr, file_data_size, file_data_ptr)
322320
# 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
325321
.section .rodata.__emscripten_embedded_file_data,"",@
326322
__emscripten_embedded_file_data:
327323
.p2align {align}
@@ -366,16 +362,26 @@ def main(): # noqa: C901, PLR0912, PLR0915
366362
To revalidate these numbers, run `ruff check --select=C901,PLR091`.
367363
"""
368364
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.''')
371367
return 1
372368

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]
374380
data_files = []
375381
plugins = []
376382
leading = ''
377383

378-
for arg in sys.argv[2:]:
384+
for arg in args[1:]:
379385
if arg == '--preload':
380386
leading = 'preload'
381387
elif arg == '--embed':
@@ -629,19 +635,19 @@ def generate_js(data_target, data_files, metadata):
629635
ret = '''
630636
var Module = typeof %(EXPORT_NAME)s != 'undefined' ? %(EXPORT_NAME)s : {};\n''' % {"EXPORT_NAME": options.export_name}
631637

632-
ret += '''
638+
ret += '''
633639
Module['expectedDataFileDownloads'] ??= 0;
634640
Module['expectedDataFileDownloads']++;'''
635641

636642
if not options.modularize:
637-
ret += '''
643+
ret += '''
638644
(() => {'''
639645

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'''
645651

646652
if options.support_node:
647653
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):
822828
return errback();
823829
}'''
824830
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') {
832832
throw 'using IndexedDB to cache data can only be done on a web page or in a web worker';
833833
}
834834
try {

0 commit comments

Comments
 (0)