Use local emsdk so that emsdk version can be pinned

master
paradust7 2022-12-27 20:44:27 +00:00
parent e8f754e1c5
commit 79d01a47b6
6 changed files with 74 additions and 11 deletions

1
.gitignore vendored
View File

@ -12,3 +12,4 @@ sources/webshims
sources/minetest
sources/irrlichtmt
sources/minetest_game
emsdk/

View File

@ -29,6 +29,6 @@ RUN \
cd "$HOME"/emsdk \
&& . ./emsdk_env.sh \
&& cd /minetest-wasm \
&& ./apply_patches.sh \
&& ls -la \
&& ./install_emsdk.sh \
&& ./build_all.sh

View File

@ -10,14 +10,6 @@ This has only been tested on Ubuntu 20.04.
* Ubuntu: apt-get install -y build-essential cmake tclsh
Pre-requisites
--------------
The Emscripten SDK (emsdk) must be installed, activated, and in the PATH.
It is assumed to be installed in $HOME/emsdk (edit `common.sh` to change this).
The emsdk directory must be patched exactly once by running:
./apply_patches.sh
Building
---------
@ -31,3 +23,29 @@ If the build completes successfully, the www/ directory will contain the entire
includes an `.htaccess` file which sets headers that are required (by browsers) to load the app.
If your webserver does not recognize `.htaccess` files, you may need to set the headers in
another way.
Network Play
------------
By default, the proxy server is set to `wss://minetest.dustlabs.io/proxy` (see static/launcher.js).
This is necessary for network play, since websites cannot open normal TCP/UDP sockets. This proxy
is located in California. There are regional proxies which may perform better depending on your
location:
North America (Dallas) - wss://na1.dustlabs.io/mtproxy
South America (Sao Paulo) - wss://sa1.dustlabs.io/mtproxy
Europe (Frankfurt) - wss://eu1.dustlabs.io/mtproxy
Asia (Singapore) - wss://ap1.dustlabs.io/mtproxy
Australia (Melbourne) - wss://ap2.dustlabs.io/mtproxy
You could also roll your own own custom proxy server. The client code is here:
https://github.com/paradust7/webshims/blob/main/src/emsocket/proxy.js
Custom Emscripten
-----------------
The Emscripten SDK (emsdk) will be downloaded and installed the first time you build. To provide
your own instead, set $EMSDK before building (e.g. using `emsdk_env.sh`). An external Emscripten
may need to be patched by running this exactly once:
./apply_patches.sh /path/to/emsdk

View File

@ -1,7 +1,13 @@
#!/bin/bash -eu
source common.sh
BASE_DIR="$(dirname -- "$(readlink -f -- "$0")")"
if [ $# -ne 1 ]; then
echo "Usage: $0 /path/to/emsdk"
exit 1
fi
EMSDK_ROOT="$1"
cd "$EMSDK_ROOT"
patch -p1 < "$BASE_DIR/emsdk_emcc.patch"

View File

@ -4,6 +4,28 @@ cd "$BASE_DIR"
# Debug / Release
export BUILD_KIND="${BUILD_KIND:-release}"
# Setup emscripten (if not already)
export EMSDK="${EMSDK:-use_local_install}"
if [ "$EMSDK" == "use_local_install" ]; then
if [ ! -d emsdk ]; then
set +x
echo "-------------------------------------------------------"
echo "Emscripten is not installed. (EMSDK not set)"
echo "Press ENTER to install it into emsdk/. Ctrl-C to abort."
echo "-------------------------------------------------------"
read unused_var
if [ "$unused_var" != "" ]; then
echo "Aborting"
exit 1
fi
set -x
./install_emsdk.sh
fi
pushd emsdk
source ./emsdk_env.sh
popd
fi
case $BUILD_KIND in
debug)
export MINETEST_BUILD_TYPE="Debug"
@ -40,7 +62,7 @@ export CFLAGS="$COMMON_CFLAGS -pthread -sUSE_PTHREADS=1 -fexceptions"
export CXXFLAGS="$COMMON_CFLAGS -pthread -sUSE_PTHREADS=1 -fexceptions"
export LDFLAGS="$COMMON_LDFLAGS -pthread -sUSE_PTHREADS=1 -fexceptions -sEXIT_RUNTIME"
export EMSDK_ROOT="$HOME/emsdk"
export EMSDK_ROOT="$EMSDK"
export EMSDK_SYSLIB="${EMSDK_ROOT}/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten"
export EMSDK_SYSINCLUDE="${EMSDK_ROOT}/upstream/emscripten/cache/sysroot/include"

16
install_emsdk.sh Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash -eux
BASE_DIR="$(dirname -- "$(readlink -f -- "$0")")"
cd "$BASE_DIR"
rm -rf emsdk
git clone https://github.com/emscripten-core/emsdk.git
pushd emsdk
./emsdk install 3.1.25
./emsdk activate 3.1.25
popd
./apply_patches.sh emsdk