Skip to content

Commit 2747b2a

Browse files
authored
[tsgen] Preserve user ENVIRONMENT during TS generation. (#26049)
During TS generation we forced the environment to node only which doesn't work with some preprocessor guards, such as in libworkerfs.js. Instead of forcing node only, append node so the guards still pass. Fixes #26046
1 parent 57ca8ad commit 2747b2a

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

test/test_other.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3590,6 +3590,7 @@ def test_embind_tsgen_end_to_end(self, opts, tsc_opts):
35903590
'3': [['-sWASM=0'], 'embind_tsgen_ignore_3.d.ts'],
35913591
'4': [['-fsanitize=undefined', '-gsource-map'], 'embind_tsgen_ignore_3.d.ts'],
35923592
'5': [['-sASYNCIFY'], 'embind_tsgen_ignore_3.d.ts'],
3593+
'6': [['-sENVIRONMENT=worker', '-lworkerfs.js'], 'embind_tsgen.d.ts'],
35933594
})
35943595
def test_embind_tsgen_ignore(self, extra_args, expected_ts_file):
35953596
create_file('fail.js', 'assert(false);')

tools/link.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2011,7 +2011,8 @@ def run_embind_gen(options, wasm_target, js_syms, extra_settings):
20112011
settings.PRE_JS_FILES = []
20122012
settings.POST_JS_FILES = []
20132013
# Force node since that is where the tool runs.
2014-
settings.ENVIRONMENT = ['node']
2014+
if 'node' not in settings.ENVIRONMENT:
2015+
settings.ENVIRONMENT.append('node')
20152016
settings.MINIMAL_RUNTIME = 0
20162017
# Required function to trigger TS generation.
20172018
settings.DEFAULT_LIBRARY_FUNCS_TO_INCLUDE += ['$callRuntimeCallbacks', '$addRunDependency', '$removeRunDependency']

0 commit comments

Comments
 (0)