When compiling a simple WebAudio program, typescript type generation fails to register runtime exports.
In fact, it fails as soon as I use -sAUDIO_WORKLET. I used a simple main function that only returns 0 to ensure that I was making any mistake.
Failing command line in full:em++ -O3 -DNDEBUG -pthread -sAUDIO_WORKLET -sWASM_WORKERS --emit-tsd ClientTypes.d.ts {ALL OBJECT FILES...} -o Release/Client.js -lembind
Error:
Traceback (most recent call last):
File "/home/ptah/Tools/emsdk/upstream/emscripten/em++.py", line 15, in <module>
sys.exit(emcc.main(sys.argv))
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/contextlib.py", line 81, in inner
return func(*args, **kwds)
^^^^^^^^^^^^^^^^^^^
File "/home/ptah/Tools/emsdk/upstream/emscripten/emcc.py", line 1583, in main
ret = run(args)
^^^^^^^^^
File "/home/ptah/Tools/emsdk/upstream/emscripten/emcc.py", line 648, in run
return link.run(linker_inputs, options, state, newargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ptah/Tools/emsdk/upstream/emscripten/tools/link.py", line 3102, in run
phase_post_link(options, state, wasm_target, wasm_target, target, js_syms)
File "/usr/lib/python3.11/contextlib.py", line 81, in inner
return func(*args, **kwds)
^^^^^^^^^^^^^^^^^^^
File "/home/ptah/Tools/emsdk/upstream/emscripten/tools/link.py", line 1877, in phase_post_link
phase_emit_tsd(options, wasm_target, state.js_target, js_syms, metadata)
File "/usr/lib/python3.11/contextlib.py", line 81, in inner
return func(*args, **kwds)
^^^^^^^^^^^^^^^^^^^
File "/home/ptah/Tools/emsdk/upstream/emscripten/tools/link.py", line 1966, in phase_emit_tsd
all_tsd = emscripten.create_tsd(metadata, embind_tsd)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ptah/Tools/emsdk/upstream/emscripten/tools/emscripten.py", line 638, in create_tsd
out += create_tsd_exported_runtime_methods(metadata)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ptah/Tools/emsdk/upstream/emscripten/tools/emscripten.py", line 620, in create_tsd_exported_runtime_methods
js_doc += f'{definition["docs"]}\nRuntimeExports[\'{name}\'] = \n{definition["snippet"]};\n'
Failing code:emscripten.py
def create_tsd_exported_runtime_methods(metadata):
# Use the TypeScript compiler to generate defintions for all of the runtime
# exports. The JS from the library any JS docs are included in the file used
# for generation.
js_doc = 'var RuntimeExports = {};'
for name in settings.EXPORTED_RUNTIME_METHODS:
if name in metadata.library_definitions:
definition = metadata.library_definitions[name]
print(definition) # I added this print to check what happens
js_doc += f'{definition["docs"]}\nRuntimeExports[\'{name}\'] = \n{definition["snippet"]};\n'
else:
js_doc += f'/** @type {{any}} */RuntimeExports[\'{name}\'];\n'
js_doc_file = in_temp('jsdoc.js')
tsc_output_file = in_temp('jsdoc.d.ts')
utils.write_file(js_doc_file, js_doc)
if shutil.which('tsc'):
tsc = ['tsc']
else:
tsc = shared.get_npm_cmd('tsc')
cmd = tsc + ['--outFile', tsc_output_file, '--declaration', '--emitDeclarationOnly', '--allowJs', js_doc_file]
shared.check_call(cmd, cwd=path_from_root())
return utils.read_file(tsc_output_file)
The added print(definition) shows few definitions before the error is thrown:
When compiling a simple WebAudio program, typescript type generation fails to register runtime exports. In fact, it fails as soon as I use
-sAUDIO_WORKLET
. I used a simple main function that only returns 0 to ensure that I was making any mistake.Version of emscripten/emsdk:
Failing command line in full:
em++ -O3 -DNDEBUG -pthread -sAUDIO_WORKLET -sWASM_WORKERS --emit-tsd ClientTypes.d.ts {ALL OBJECT FILES...} -o Release/Client.js -lembind
Error:
Failing code:
emscripten.py
The added
print(definition)
shows few definitions before the error is thrown:Any help would be greatly appreciated, thank you !