emscripten-core / emscripten-core/emscripten

How should external tools find emscripten?

Open
#9,685 19 comments 2 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

There are several external tools that want to be able to run emscripten (usually in order to run emcc/em++, etc). The ones that I know about are:

- cmake : https://github.com/emscripten-core/emscripten/blob/ea3209ae0427a8223e7ff108f84b55d05986b8e1/cmake/Modules/Platform/Emscripten.cmake#L63
- scons : https://github.com/emscripten-core/emscripten/blob/ea3209ae0427a8223e7ff108f84b55d05986b8e1/tools/scons/site_scons/site_tools/emscripten/emscripten.py#L15
- qtcreator: https://github.com/qt-creator/qt-creator/blob/ab36004fdc92ed0bc20d141d61c31237fbbfd8e4/src/plugins/webassembly/webassemblytoolchain.cpp#L65

The method that both scons used to use, and the qtcreator is currently using is to open the `~/.emscripten` config file (which is in python format) and somehow parse out the value of `EMSCRIPTEN_ROOT` and use that.

Note that the `EMSCRIPTEN_ROOT` key is completely useless for emscripten itself since emcc and all the other tools in emscripten already know where they are when they are run. In fact the presence of this key can be confusing and contradictory (what does it mean if you run emcc and the EMSCRIPTEN_ROOT points to a different place?).

The method that cmake uses is to look for the `EMSCRIPTEN` environment variable. The scons tools were changed to be purely environment-variable-based a while back: #7249. It now looks for `EMSCRIPTEN_ROOT` in the environment.

qtcreator looks like its parsing the config file as an ini file, which I guess works in many cases.

As part of #9543 I would like to avoid having external tools try to parse the emscripten config file.

We should pick a single, recommended way to locate emscripten and implement that in all the tools. The options I see are:

1. Look for `$EMSCRIPTEN` to `$EMSCRIPTEN_ROOT` in the environment.
2. Look for `emcc` in the $PATH environment.
4. Create a new `~/.emscripten_root` file that contains just a single string which is the emscripten directory.

We could also do (1) followed by (2), which I think is my preferred method.

The only downside of (1) or (2) is that it requires the user's environment variables to be changed.
With emsdk we already ask the user to run `./emsdk_env` in order to do this, or to modify their startup files.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.