MCPcopy Create free account
hub / github.com/FastLED/FastLED / run_emcc

Function run_emcc

ci/wasm_tools.py:278–319  ·  view source on GitHub ↗

Run emcc with the given args, trying in-process first, falling back to subprocess. Args: args: Command-line arguments (WITHOUT the 'emcc' prefix — just flags and files). cwd: Working directory for the invocation. Returns: Process return code (0 = success).

(args: list[str], cwd: Optional[str] = None)

Source from the content-addressed store, hash-verified

276
277
278def run_emcc(args: list[str], cwd: Optional[str] = None) -> int:
279 """Run emcc with the given args, trying in-process first, falling back to subprocess.
280
281 Args:
282 args: Command-line arguments (WITHOUT the 'emcc' prefix — just flags and files).
283 cwd: Working directory for the invocation.
284
285 Returns:
286 Process return code (0 = success).
287 """
288 # Verify the EMCC_WASM_LD patch is applied to the bundled emscripten
289 # install. This was previously in _render_wasm_cross_file (called on every
290 # warm build) — moved here in 2026-05 so the cost is paid only when emcc.py
291 # is actually about to be imported in-process. On clang-tool-chain >=1.5.5
292 # with a settled install, this is a ~1 ms marker-file stat; on older or
293 # freshly-extracted installs it does the full check.
294 #
295 # Lazy import to avoid the wasm_build <-> wasm_tools circular dep.
296 from ci.wasm_build import _ensure_emscripten_wasm_ld_patch
297
298 _ensure_emscripten_wasm_ld_patch()
299
300 mod = _load_emcc_module()
301 if mod is not None:
302 # In-process invocation — save/restore global state
303 old_argv = sys.argv
304 old_cwd = os.getcwd()
305 try:
306 sys.argv = ["emcc"] + args
307 if cwd:
308 os.chdir(cwd)
309 return mod.main(sys.argv) # type: ignore[union-attr]
310 except SystemExit as e:
311 return e.code if isinstance(e.code, int) else 1
312 finally:
313 sys.argv = old_argv
314 os.chdir(old_cwd)
315
316 # Fallback: subprocess
317 emcc = get_emcc()
318 result = subprocess.run([emcc] + args, cwd=cwd)
319 return result.returncode

Callers 1

build_sketch_pchFunction · 0.90

Calls 4

_load_emcc_moduleFunction · 0.85
get_emccFunction · 0.85
runMethod · 0.45

Tested by

no test coverage detected