MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / module_export_name_substitution

Function module_export_name_substitution

tools/link.py:2478–2494  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2476
2477
2478def module_export_name_substitution():
2479 assert not settings.MODULARIZE
2480 global final_js
2481 logger.debug(f'Private module export name substitution with {settings.EXPORT_NAME}')
2482 src = read_file(final_js)
2483 final_js += '.module_export_name_substitution.js'
2484 if settings.MINIMAL_RUNTIME and not settings.ENVIRONMENT_MAY_BE_NODE and not settings.ENVIRONMENT_MAY_BE_SHELL and not settings.ENVIRONMENT_MAY_BE_AUDIO_WORKLET:
2485 # On the web, with MINIMAL_RUNTIME, the Module object is always provided
2486 # via the shell html in order to provide the .asm.js/.wasm content.
2487 replacement = settings.EXPORT_NAME
2488 else:
2489 replacement = "typeof %(EXPORT_NAME)s != 'undefined' ? %(EXPORT_NAME)s : {}" % {"EXPORT_NAME": settings.EXPORT_NAME}
2490 new_src = re.sub(r'{\s*[\'"]?__EMSCRIPTEN_PRIVATE_MODULE_EXPORT_NAME_SUBSTITUTION__[\'"]?:\s*1\s*}', replacement, src)
2491 assert new_src != src, 'Unable to find Closure syntax __EMSCRIPTEN_PRIVATE_MODULE_EXPORT_NAME_SUBSTITUTION__ in source!'
2492 write_file(final_js, new_src)
2493 shared.get_temp_files().note(final_js)
2494 save_intermediate('module_export_name_substitution')
2495
2496
2497def generate_traditional_runtime_html(target, options, js_target, wasm_target):

Callers 1

phase_final_emittingFunction · 0.85

Calls 4

noteMethod · 0.80
read_fileFunction · 0.70
write_fileFunction · 0.70
save_intermediateFunction · 0.70

Tested by

no test coverage detected