Skip to content

Commit

Permalink
Use nullish assignment in file_packager.py. NFC (emscripten-core#22805)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 authored Oct 31, 2024
1 parent 9ae9322 commit 0bf241c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
7 changes: 6 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@ See docs/process.md for more on how version tagging works.
3.1.71 (in development)
-----------------------
- LLVM's `-Wnontrivial-memaccess` warning has been updated to also warn about
passing non-trivially-copyable destrination parameter to `memcpy`,
passing non-trivially-copyable destination parameter to `memcpy`,
`memset` and similar functions for which it is a documented undefined
behavior (#22798). See https://github.com/llvm/llvm-project/pull/111434
- The automatic fallback to `$HOME/.emscripten_cache` when the emscripten
directory is read-only was removed. This automatic behaviour could cause
confusion. Anyone who really wants to use `$HOME/.emscripten_cache` can
still do so either via an environment variable (`EMCC_CACHE`) or via a config
file setting `CACHE`.
- The standalone `file_packager.py` tool now outputs modern JS (specifically it
includes nullish assignment). If you use this output directly and you want
to support older browsers you may need to transpile it. If you use
`file_packager` via emcc the output will be transpiled as part of the emcc
output. (#22805)

3.1.70 - 10/25/24
-----------------
Expand Down
13 changes: 4 additions & 9 deletions tools/file_packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,10 +607,7 @@ def generate_js(data_target, data_files, metadata):
var Module = typeof %(EXPORT_NAME)s != 'undefined' ? %(EXPORT_NAME)s : {};\n''' % {"EXPORT_NAME": options.export_name}

ret += '''
if (!Module['expectedDataFileDownloads']) {
Module['expectedDataFileDownloads'] = 0;
}
Module['expectedDataFileDownloads'] ??= 0;
Module['expectedDataFileDownloads']++;
(() => {
// Do not attempt to redownload the virtual filesystem data when in a pthread or a Wasm Worker context.
Expand Down Expand Up @@ -1033,7 +1030,7 @@ def generate_js(data_target, data_files, metadata):
# we need to find the datafile in the same dir as the html file

code += '''
if (!Module['preloadResults']) Module['preloadResults'] = {};\n'''
Module['preloadResults'] ??= {};\n'''

if options.use_preload_cache:
code += '''
Expand Down Expand Up @@ -1099,8 +1096,7 @@ def generate_js(data_target, data_files, metadata):
if (Module['calledRun']) {
runWithFS(Module);
} else {
if (!Module['preRun']) Module['preRun'] = [];
Module["preRun"].push(runWithFS); // FS is not initialized yet, wait for it
(Module['preRun'] ??= []).push(runWithFS); // FS is not initialized yet, wait for it
}\n'''

if options.separate_metadata:
Expand Down Expand Up @@ -1139,8 +1135,7 @@ def generate_js(data_target, data_files, metadata):
if (Module['calledRun']) {
runMetaWithFS();
} else {
if (!Module['preRun']) Module['preRun'] = [];
Module["preRun"].push(runMetaWithFS);
(Module['preRun'] ??= []).push(runMetaWithFS);
}\n''' % {'node_support_code': node_support_code, 'metadata_file': os.path.basename(options.jsoutput + '.metadata')}
else:
ret += '''
Expand Down

0 comments on commit 0bf241c

Please sign in to comment.