瀏覽代碼

[Web] Include emscripten headers by default

Adam Scott 4 月之前
父節點
當前提交
b0e472c8e4
共有 1 個文件被更改,包括 9 次插入0 次删除
  1. 9 0
      platform/web/detect.py

+ 9 - 0
platform/web/detect.py

@@ -1,5 +1,6 @@
 import os
 import os
 import sys
 import sys
+from pathlib import Path
 from typing import TYPE_CHECKING
 from typing import TYPE_CHECKING
 
 
 from emscripten_helpers import (
 from emscripten_helpers import (
@@ -112,6 +113,14 @@ def configure(env: "SConsEnvironment"):
         print_error("Initial memory must be a valid integer")
         print_error("Initial memory must be a valid integer")
         sys.exit(255)
         sys.exit(255)
 
 
+    # Add Emscripten to the included paths (for compile_commands.json completion)
+    emcc_path = Path(str(WhereIs("emcc")))
+    while emcc_path.is_symlink():
+        # For some reason, mypy trips on `Path.readlink` not being defined, somehow.
+        emcc_path = emcc_path.readlink()  # type: ignore[attr-defined]
+    emscripten_include_path = emcc_path.parent.joinpath("cache", "sysroot", "include")
+    env.Append(CPPPATH=[emscripten_include_path])
+
     ## Build type
     ## Build type
 
 
     if env.debug_features:
     if env.debug_features: