Parse the clang command from emcc verbose stderr output. emcc with EMCC_VERBOSE=1 prints subprocess commands to stderr. We look for the clang invocation that has -c (compile mode).
(stderr_text: str)
| 973 | |
| 974 | |
| 975 | def _parse_clang_from_verbose(stderr_text: str) -> list[str] | None: |
| 976 | """Parse the clang command from emcc verbose stderr output. |
| 977 | |
| 978 | emcc with EMCC_VERBOSE=1 prints subprocess commands to stderr. |
| 979 | We look for the clang invocation that has -c (compile mode). |
| 980 | """ |
| 981 | import shlex |
| 982 | import sys |
| 983 | |
| 984 | # On Windows, use posix=False so backslash paths aren't treated as escape chars. |
| 985 | # posix=False preserves literal quotes in tokens — strip them afterwards. |
| 986 | posix = sys.platform != "win32" |
| 987 | |
| 988 | for line in stderr_text.splitlines(): |
| 989 | stripped = line.strip() |
| 990 | if not stripped: |
| 991 | continue |
| 992 | parts = stripped.split() |
| 993 | if parts and "clang" in parts[0].lower() and "-c" in parts: |
| 994 | try: |
| 995 | tokens = shlex.split(stripped, posix=posix) |
| 996 | if not posix: |
| 997 | # posix=False keeps outer quotes on tokens — strip them |
| 998 | tokens = [t.strip("'\"") for t in tokens] |
| 999 | return tokens |
| 1000 | except ValueError: |
| 1001 | continue |
| 1002 | return None |
| 1003 | |
| 1004 | |
| 1005 | def _compile_cache_key(emcc_args: list[str]) -> str: |
no outgoing calls
no test coverage detected