The Emscripten toolchain includes a number of different tools, including Clang, Emscripten, Java, Git, Node, etc. Emsdk is a small package manager for controlling which tools are installed, and from the set of installed tools, which are active.

The current set of available tools and SDKs are listed using ./emsdklist. These can be installed individually (./emsdkinstallnode-0.10.17-64bit) or as a group (./emsdkinstallnode-0.10.17-64bitjava-7.45-64bit).

The SDK targets are a convenience mechanism for specifying the full set of tools used by a particular Emscripten release. For example, the two lines below are equivalent:

A particular installed SDK (or tool) can then be set as active, meaning that it will be used when Emscripten is run. The active “compiler configuration” is stored in a user-specific file (~/.emscripten), which is discussed in the next section.

Note

The different tools and SDKs managed by emsdk are stored in different directories under the root folder you specified when you first installed an SDK, grouped by tool and version.

The Compiler Configuration File stores the active configuration on behalf of the emsdk. The active configuration defines the specific set of tools that are used by default if Emscripten in called on the Emscripten Command Prompt.

The configuration file is named .emscripten. It is user-specific, and is located in the user’s home directory (~/.emscripten on Linux).

The file should generally not be updated directly unless you’re building Emscripten from source. Instead use the emsdk to activate specific SDKs and tools as needed (emsdkactivate<tool/SDK>).

Below are typical .emscripten files created by emsdk. Note the variable names used to point to the different tools:

Use the update argument to fetch the current registry of available tools, and then specify the latest install target to get the most recent SDK:

# Fetch the latest registry of available tools../emsdkupdate# Download and install the latest SDK tools../emsdkinstalllatest# Set up the compiler configuration to point to the "latest" SDK../emsdkactivatelatest

To get a list of all currently installed tools and SDK versions (and all available tools) run:

./emsdklist

A line will be printed for each tool and SDK that is available for installation. The text INSTALLED will be shown for each tool that has already been installed. If a tool/SDK is currently active, a star (*) will be shown next to it.

Toggle between different tools and SDK versions using the activate command. This will set up ~/.emscripten to point to that particular tool:

./emsdkactivate<tool/sdkname># On Linux and OSX, also set the environment variables.source./emsdk_env.sh

Note

On Linux and Mac OS X, activate writes the required information to the configuration file, but cannot automatically set up the environment variables in the current terminal. To do this you need to call source./emsdk_env.sh after calling activate. The use of source is a security feature of Unix shells.

On Windows, calling activate automatically sets up the required paths and environment variables.

Emsdk contains a history of old tools and SDKs that you can use to maintain your migration path. Use the list--old argument to get a list of archived tool and SDK versions, and install<name_of_tool> to install a specific tool:

# Get list of the old versions of the tool../emsdklist--old# Install the required version../emsdkinstall<name_of_tool># Activate required version../emsdkactivate<name_of_tool>

It is also possible to use the latest and greatest versions of the tools on the Github repositories! This allows you to obtain new features and latest fixes immediately as they are pushed to Github, without having to wait for release to be tagged. No Github account or fork of Emscripten is required.

To switch to using the latest upstream git development branch (incoming), run the following:

# Install git. Skip if the system already has it../emsdkinstallgit-1.8.3# Clone+pull the latest kripken/emscripten/incoming../emsdkinstallsdk-incoming-64bit# Set the "incoming SDK" as the active version../emsdkactivatesdk-incoming-64bit

If you want to use the upstream stable branch master, then replace -incoming- with -master- in the commands above.

It is also possible to use your own fork of the Emscripten repository via the SDK. This is useful in the case when you want to make your own modifications to the Emscripten toolchain, but still keep using the SDK environment and tools.

The way this works is that you first install the sdk-incoming SDK as in the previous section. Then you use familiar git commands to replace this branch with the information from your own fork:

cdemscripten/incoming# Add a git remote link to your own repository.gitremoteaddmyremotehttps://github.com/mygituseraccount/emscripten.git# Obtain the changes in your link.gitfetchmyremote# Switch the emscripten-incoming tool to use your fork.gitcheckout-bmyincoming--trackmyremote/incoming

You can switch back and forth between remotes via the gitcheckout command as usual.