-
-
Notifications
You must be signed in to change notification settings - Fork 22.4k
[Web] Include emscripten headers by default #105800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
[Web] Include emscripten headers by default #105800
Conversation
So, the goal is to get this include path into the I wonder if there's a way to get Emscripten to give us the its include paths without the user having to specify them? ChatGPT gave me this which seems to work:
|
Yeah I agree we should set this automatically and not require passing it on the command line. A correct (current) Emscripten setup should have |
Not necessarily. You can setup it to work directly from the emscripten-core/emscripten repo. |
0e40f5b
to
657945b
Compare
emscripten_include_path
option## 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]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the new logic, in order to include automatically the right headers to the build.
Currently, developing using Emscripten for the Web platform is kinda a pain. As Emscripten uses by default it's own patched and new headers, the IDEs usually don't know what to do with Emscripten code because including manually those headers is not required.
This code compiles with Emscripten even if clangd complains.
So this PR adds a new option:emscripten_include_path
. When added, this path will be included as an include path in the compilation.Edit: This PR now detects and adds the include path automatically, based on the detected binary.
See how great it looks?
Note
If you're using emsdk:
(not needed anymore)scons platform=web emscripten_include_path=<emsdk path>/upstream/emscripten/cache/sysroot/include
If you're using directly emscripten:
(not needed anymore)scons platform=web emscripten_include_path=<emscripten path>/cache/sysroot/include