1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
|
.. _emsdk:
======================
Emscripten SDK (emsdk)
======================
**Emscripten SDK (** ``emsdk`` **) is used to perform all SDK maintenance. You only need to install the SDK once; after that emsdk can do all further updates!**
With *emsdk* you can download, install or remove *any* :term:`SDK` or :term:`Tool`, and even use the :ref:`bleeding edge versions <emsdk-master-or-incoming-sdk>` in development on GitHub. To access the *emsdk* on Windows, first launch the :ref:`Emscripten Command Prompt <emcmdprompt>`. Most operations are of the form ``./emsdk command``.
This document provides the command syntax, and a :ref:`set of guides <emsdk_howto>` explaining how to perform both common and advanced maintenance operations.
Command line syntax
===================
**./emsdk** [**help** [**--old**] | **list** | **update** | **install** *<tool/sdk>* | **uninstall** *<tool/sdk>* | **activate** *<tool/sdk>*]
Arguments
---------
.. list-table::
:header-rows: 1
:widths: 20 80
:class: wrap-table-content
* - Command
- Description
* - ``list [--old]``
- Lists all current SDKs and tools and their installation status. With the ``--old`` parameter, historical versions are also shown.
* - ``update``
- Fetches the latest list of all available tools and SDKs (but does not install them).
* - ``install <tool/sdk>``
- Downloads and installs the :ref:`specified tool or SDK <emsdk-specified-tool-sdk>`.
* - ``uninstall <tool/sdk>``
- Removes the :ref:`specified tool or SDK <emsdk-specified-tool-sdk>` from the disk.
* - ``activate <tool/sdk>``
- Sets the :ref:`specified tool or SDK <emsdk-specified-tool-sdk>` as the default tool in the system environment. On Linux you additionally have to enable the environment settings using ``source ./emsdk_env.sh``, as described in ":ref:`emsdk-set-active-tools`".
* - ``help``
- Lists all supported commands. The same list is output if no command is specified.
.. note::
- For Linux and macOS the commands are called with **./emsdk**. On Windows use **emsdk**.
.. _emsdk-specified-tool-sdk:
Tools and SDK targets
---------------------
The ``<tool/sdk>`` given above as a command argument is one of the targets listed using ``./emsdk list`` (or ``./emsdk list --old``).
Note that some of the tools and SDK names include *master* or *incoming*: these targets are used to clone and pull the very latest versions from the Emscripten incoming and master branches.
You can also specify a target of ``latest`` to grab the most current SDK.
SDK concepts
============
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 :term:`tools <Tool>` and :term:`SDKs <SDK>` are listed using ``./emsdk list``. These can be installed individually (``./emsdk install node-0.10.17-64bit``) or as a group (``./emsdk install node-0.10.17-64bit java-7.45-64bit``).
The :term:`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: ::
./emsdk install sdk-incoming-64bit
./emsdk install git-1.8.3 clang-incoming-64bit node-0.10.17-64bit python-2.7.5.3-64bit java-7.45-64bit emscripten-incoming
A particular installed SDK (or tool) can then be set as :term:`active <Active
Tool/SDK>`, meaning that it will be used when Emscripten is run. The active
"compiler configuration" is stored is a config file (*.emscripten*) within
the emsdk directory.
.. 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.
.. _compiler-configuration-file:
Emscripten Compiler Configuration File (.emscripten)
====================================================
The *Compiler Configuration File* stores the :term:`active <Active Tool/SDK>` 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 :ref:`Emscripten Command Prompt <emcmdprompt>`.
The configuration file is named **.emscripten**. It is emsdk-specific, so it
won't conflict with any config file the user might have in their home directory.
The file should generally not be updated directly unless you're :ref:`building Emscripten from source <installing-from-source>`. Instead use the *emsdk* to activate specific SDKs and tools as needed (``emsdk activate <tool/SDK>``).
Below are examples of possible **.emscripten** files created by *emsdk*. Note
the variable names used to point to the different tools::
# .emscripten file from Windows SDK
import os
LLVM_ROOT='C:/Program Files/Emscripten/clang/e1.21.0_64bit'
NODE_JS='C:/Program Files/Emscripten/node/0.10.17_64bit/node.exe'
JAVA='C:/Program Files/Emscripten/java/7.45_64bit/bin/java.exe'
::
# .emscripten file from Linux SDK
import os
NODE_JS = 'nodejs'
LLVM_ROOT='/home/ubuntu/emsdk/upstream/bin'
.. _emsdk_howto:
"How to" guides
=========================
The following topics explain how to perform both common and advanced maintenance operations, ranging from installing the latest SDK through to installing your own fork from GitHub.
.. note:: The examples below show the commands for Linux and macOS. The commands are the same on Windows, but you need to replace **./emsdk** with **emsdk**.
.. _emsdk-get-latest-sdk:
How do I just get the latest SDK?
------------------------------------------------------------------------------------------------
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.
./emsdk update
# Download and install the latest SDK tools.
./emsdk install latest
# Set up the compiler configuration to point to the "latest" SDK.
./emsdk activate latest
How do I use emsdk?
--------------------------------
Use ``./emsdk help`` or just ``./emsdk`` to get information about all available commands.
How do I check which versions of the SDK and tools are installed?
------------------------------------------------------------------------------------------------
To get a list of all currently installed tools and SDK versions (and all available tools) run: ::
./emsdk list
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.
How do I install a tool/SDK version?
------------------------------------
Use the ``install`` argument to download and install a new tool or SDK version: ::
./emsdk install <tool/sdk name>
For example: ::
./emsdk install sdk-1.38.21-64bit
.. note:: An installed tool is present on the local machine, but not necessarily the active environment. To make an installed SDK active, use the ``activate`` command.
.. _emsdk-remove-tool-sdk:
How do I remove a tool or an SDK?
----------------------------------------------------------------
Use the ``uninstall`` argument to delete a given tool or SDK from the local computer: ::
./emsdk uninstall <tool/sdk name>
If you want to completely remove Emscripten from your system, follow the guide at :ref:`downloads-uninstall-the-sdk`.
How do I check for updates to the Emscripten SDK?
----------------------------------------------------------------
First use the ``update`` command to fetch package information for all new tools and SDK versions. Then use ``install <tool/sdk name>`` to install a new version: ::
# Fetch the latest registry of available tools.
./emsdk update
# Download and install the specified new version.
./emsdk install <tool/sdk name>
.. _emsdk-set-active-tools:
How do I change the currently active SDK version?
----------------------------------------------------------------
Toggle between different tools and SDK versions using the :term:`activate
<Active Tool/SDK>` command. This will set up ``.emscripten`` to point to that
particular tool: ::
./emsdk activate <tool/sdk name>
# On Linux and macOS, also set the environment variables.
source ./emsdk_env.sh
.. note:: On Linux and macOS, ``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-install-old-tools:
How do I install and activate old Emscripten SDKs and tools?
------------------------------------------------------------
*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.
./emsdk list --old
# Install the required version.
./emsdk install <name_of_tool>
# Activate required version.
./emsdk activate <name_of_tool>
.. _emsdk-master-or-incoming-sdk:
How do I track the latest Emscripten development with the SDK?
------------------------------------------------------------------------------------------------
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.
./emsdk install git-1.8.3
# Clone+pull the latest emscripten-core/emscripten/incoming.
./emsdk install sdk-incoming-64bit
# Set the "incoming SDK" as the active version.
./emsdk activate sdk-incoming-64bit
If you want to use the upstream stable branch ``master``, then replace ``-incoming-`` with ``-master-`` in the commands above.
.. _emsdk-howto-use-own-fork:
How do I use my own Emscripten GitHub fork with the SDK?
----------------------------------------------------------------
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 :ref:`previous section <emsdk-master-or-incoming-sdk>`. Then you use familiar git commands to replace this branch with the information from your own fork:
::
cd emscripten/incoming
# Add a git remote link to your own repository.
git remote add myremote https://github.com/mygituseraccount/emscripten.git
# Obtain the changes in your link.
git fetch myremote
# Switch the emscripten-incoming tool to use your fork.
git checkout -b myincoming --track myremote/incoming
You can switch back and forth between remotes via the ``git checkout`` command as usual.
|