-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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 :
message(FATAL_ERROR "Could not locate the Emscripten compiler toolchain directory! Either set the EMSCRIPTEN environment variable, or pass -DEMSCRIPTEN_ROOT_PATH=xxx to CMake to explicitly specify the location of the compiler!") - scons :
emscripten_path = os.environ.get('EMSCRIPTEN_ROOT') - 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:
- Look for
$EMSCRIPTEN
to$EMSCRIPTEN_ROOT
in the environment. - Look for
emcc
in the $PATH environment. - 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.