Skip to content

Commit 1960782

Browse files
authored
embind: Ignore more options during TS generation and force node environment. (#20242)
All of these options can potentially conflict with TS generation.
1 parent 13d01f5 commit 1960782

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

emcc.py

+10
Original file line numberDiff line numberDiff line change
@@ -1853,6 +1853,16 @@ def phase_linker_setup(options, state, newargs):
18531853
# Ignore -sMODULARIZE which could otherwise effect how we run the module
18541854
# to generate the bindings.
18551855
settings.MODULARIZE = False
1856+
# Don't include any custom user JS or files.
1857+
options.pre_js = []
1858+
options.post_js = []
1859+
options.extern_pre_js = []
1860+
options.extern_post_js = []
1861+
options.use_preload_cache = False
1862+
options.preload_files = []
1863+
options.embed_files = []
1864+
# Force node since that is where the tool runs.
1865+
settings.ENVIRONMENT = 'node'
18561866

18571867
# options.output_file is the user-specified one, target is what we will generate
18581868
if options.output_file:

test/test_other.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -2919,13 +2919,22 @@ def test_jspi_add_function(self):
29192919
self.do_runf(test_file('other/test_jspi_add_function.c'), 'done')
29202920

29212921
def test_embind_tsgen(self):
2922+
create_file('fail.js', 'assert(false);')
29222923
# These extra arguments are not related to TS binding generation but we want to
29232924
# verify that they do not interfere with it.
29242925
extra_args = ['-o',
29252926
'out.html',
29262927
'-sMODULARIZE',
29272928
'-sALLOW_MEMORY_GROWTH=1',
2928-
'-sMAXIMUM_MEMORY=4GB']
2929+
'-sMAXIMUM_MEMORY=4GB',
2930+
'--pre-js', 'fail.js',
2931+
'--post-js', 'fail.js',
2932+
'--extern-pre-js', 'fail.js',
2933+
'--extern-post-js', 'fail.js',
2934+
'-sENVIRONMENT=worker',
2935+
'--use-preload-cache',
2936+
'--preload-file', 'fail.js',
2937+
'--embed-file', 'fail.js']
29292938
self.run_process([EMCC, test_file('other/embind_tsgen.cpp'),
29302939
'-lembind', '--embind-emit-tsd', 'embind_tsgen.d.ts'] + extra_args)
29312940
actual = read_file('embind_tsgen.d.ts')

0 commit comments

Comments
 (0)