Skip to content

Commit 07b10cc

Browse files
committed
Minor improvements to the Emscripten instructions
1 parent 6c41828 commit 07b10cc

1 file changed

Lines changed: 31 additions & 20 deletions

File tree

getting-started/setup-building.rst

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -522,34 +522,44 @@ The simplest way to build Emscripten is to run:
522522

523523
.. code-block:: sh
524524
525-
python3 Platforms/emscripten build all --emsdk-cache=./cross-build/emsdk
525+
export EMSDK_CACHE=$PWD/cross-build/emsdk
526+
python3 Platforms/emscripten install-emscripten
527+
python3 Platforms/emscripten build all
526528
527-
This will:
529+
`install-emscripten` downloads and installs the version of the Emscripten SDK
530+
required, placing it in the `EMSDK_CACHE` directory.
531+
`build all` will:
528532

529533
1. Build a copy of Python that can run on the host machine (the "build" python);
530-
2. Download a copy of the Emscripten SDK matching the version required by the
531-
version of Python being compiled;
532-
3. Ensure that a required version of Node is installed;
533-
4. Download the code for all the binary dependencies of Python (such as
534-
``libFFI`` and ``xz``), and compile them for Emscripten; and
535-
5. Build a copy of Python that can run on Emscripten (the "host" python).
536-
537-
If you omit the ``--emsdk-cache`` environment variable, the build script will
534+
2. Ensure that a required version of Node is installed;
535+
3. Download the code for all the binary dependencies of Python (such as
536+
``libffi`` and ``mpdecimal``), and compile them for Emscripten; and
537+
4. Build a copy of Python that can run on Emscripten (the "host" python).
538+
539+
The built binary dependencies are cached inside the Emscripten cache directory.
540+
Once built for a given Emscripten version, they will not be rebuilt on
541+
subsequent runs unless there is a change in the version or build script for the
542+
dependency.
543+
544+
If you omit the ``EMSDK_CACHE`` environment variable, the build script will
538545
assume that the current environment has the Emscripten tools available. You are
539546
responsible for downloading and activating those tools in your environment. The
540547
version of Emscripten and Node that is required to build Python is defined in
541548
the :cpy-file:`Platforms/emscripten/config.toml` configuration file.
542549

543-
There are three environment variables that can be used to control the operation of
550+
There are two environment variables that can be used to control the operation of
544551
the ``Platforms/emscripten`` build script:
545552

546-
* ``EMSDK_CACHE`` controls the location of the emscripten SDK. You can use this instead
547-
environment variable instead of passing the ``--emsdk-cache`` flag.
548-
* ``CACHE_DIR`` defines the location where downloaded artefacts, such
549-
as precompiled ``libFFI`` and ``xz`` binaries, will be stored.
550-
* ``CROSS_BUILD_DIR`` defines the name of the ``cross-build`` directory
551-
that will be used for builds. This can be useful if you need to maintain
552-
builds of multiple versions of Python.
553+
* ``EMSDK_CACHE`` (or the ``--emsdk-cache`` flag) controls the location of the
554+
Emscripten SDK cache directory. You can use this environment variable instead
555+
of passing the ``--emsdk-cache`` flag. When set, the build script will
556+
validate that the required Emscripten version is present in the cache and will
557+
exit with an error if it is not; run ``install-emscripten`` to populate the
558+
cache.
559+
* ``CROSS_BUILD_DIR`` (or the ``--cross-build-dir`` flag) defines the location
560+
of the ``cross-build`` directory that will be used for builds. This can be
561+
useful if you need to maintain builds of multiple versions of Python
562+
side by side.
553563

554564
It is possible (but not necessary) to enable ``ccache`` for Emscripten builds
555565
by setting the ``EM_COMPILER_WRAPPER`` environment, but this step will only
@@ -571,8 +581,9 @@ Emscripten build in ``cross-build/build`` and
571581
``cross-build/wasm32-emscripten/build/python/``, respectively.
572582

573583
The ``Platforms/emscripten`` script has a number of other entry points that allow for
574-
fine-grained execution of each part of an iOS build; run ``python3
575-
Platforms/emscripten --help`` for more details.
584+
fine-grained execution of each part of an Emscripten build; run
585+
``python3 Platforms/emscripten --help`` for more details.
586+
576587

577588
Once the build is complete, you can run Python code using:
578589

0 commit comments

Comments
 (0)