Parse the wasm-ld command from emcc verbose stderr output. emcc with EMCC_VERBOSE=1 prints subprocess commands as: /path/to/wasm-ld.exe arg1 arg2 ...
(stderr_text: str)
| 1227 | |
| 1228 | |
| 1229 | def _parse_wasm_ld_from_verbose(stderr_text: str) -> list[str] | None: |
| 1230 | """Parse the wasm-ld command from emcc verbose stderr output. |
| 1231 | |
| 1232 | emcc with EMCC_VERBOSE=1 prints subprocess commands as: |
| 1233 | /path/to/wasm-ld.exe arg1 arg2 ... |
| 1234 | """ |
| 1235 | import shlex |
| 1236 | import sys |
| 1237 | |
| 1238 | # On Windows, use posix=False so backslash paths aren't treated as escape chars. |
| 1239 | # posix=False preserves literal quotes in tokens — strip them afterwards. |
| 1240 | posix = sys.platform != "win32" |
| 1241 | |
| 1242 | for line in stderr_text.splitlines(): |
| 1243 | stripped = line.strip() |
| 1244 | if not stripped: |
| 1245 | continue |
| 1246 | # emcc verbose output prefixes commands with a space |
| 1247 | if "wasm-ld" in stripped.split()[0] if stripped.split() else False: |
| 1248 | try: |
| 1249 | tokens = shlex.split(stripped, posix=posix) |
| 1250 | if not posix: |
| 1251 | # posix=False keeps outer quotes on tokens — strip them |
| 1252 | tokens = [t.strip("'\"") for t in tokens] |
| 1253 | return tokens |
| 1254 | except ValueError: |
| 1255 | continue |
| 1256 | return None |
| 1257 | |
| 1258 | |
| 1259 | def _link_cache_key(library_archive: Path) -> str: |
no outgoing calls
no test coverage detected