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

Function setup_emscripten_env

ci/wasm_tools.py:70–151  ·  view source on GitHub ↗

Set up emscripten environment variables in the current process. Sets EMSCRIPTEN, EMSCRIPTEN_ROOT, EM_CONFIG, and adds emscripten bin directory to PATH. Only runs once per process. Returns: True if fast paths were resolved, False if falling back to wrappers.

()

Source from the content-addressed store, hash-verified

68
69
70def setup_emscripten_env() -> bool:
71 """
72 Set up emscripten environment variables in the current process.
73
74 Sets EMSCRIPTEN, EMSCRIPTEN_ROOT, EM_CONFIG, and adds emscripten bin
75 directory to PATH. Only runs once per process.
76
77 Returns:
78 True if fast paths were resolved, False if falling back to wrappers.
79 """
80 global _env_setup_done, _fast_emcc, _fast_emar, _fast_wasm_ld
81
82 if _env_setup_done:
83 return _fast_emcc is not None
84
85 _env_setup_done = True
86
87 try:
88 platform_name, arch = _get_platform_info()
89 is_windows = platform_name == "win"
90
91 home = Path.home()
92 install_dir = home / ".clang-tool-chain" / "emscripten" / platform_name / arch
93 emscripten_dir = install_dir / "emscripten"
94 config_path = install_dir / ".emscripten"
95 bin_dir = install_dir / "bin"
96
97 if not emscripten_dir.exists() or not config_path.exists():
98 return False
99
100 # Resolve tool paths
101 if is_windows:
102 emcc_path = emscripten_dir / "emcc.bat"
103 emar_path = emscripten_dir / "emar.bat"
104 wasm_ld_path = bin_dir / "wasm-ld.exe"
105 else:
106 emcc_path = emscripten_dir / "emcc"
107 emar_path = emscripten_dir / "emar"
108 wasm_ld_path = bin_dir / "wasm-ld"
109
110 if not emcc_path.exists() or not emar_path.exists():
111 return False
112
113 # Set up environment variables that emscripten needs
114 os.environ["EMSCRIPTEN"] = str(emscripten_dir)
115 os.environ["EMSCRIPTEN_ROOT"] = str(emscripten_dir)
116 os.environ["EM_CONFIG"] = str(config_path)
117
118 # Ensure emscripten uses the same Python as us
119 os.environ["EMSDK_PYTHON"] = sys.executable
120
121 # Skip emscripten sanity checks — we already validated tool existence above.
122 # Saves ~0.3s per emcc invocation (sanity check probes LLVM, node, etc.).
123 os.environ["EMCC_SKIP_SANITY_CHECK"] = "1"
124
125 # Add emscripten bin directory to PATH (for clang, node, etc.)
126 current_path = os.environ.get("PATH", "")
127 bin_dir_str = str(bin_dir)

Callers 4

get_wasm_ldFunction · 0.85
get_emccFunction · 0.85
get_emarFunction · 0.85
_load_emcc_moduleFunction · 0.85

Calls 2

_get_platform_infoFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected