# HG changeset patch # User Sebastien Jodogne # Date 1593069236 -7200 # Node ID 4b5ec9ea268eb544a29e028ea4ffd7f99eb259e1 # Parent c5627b8493f3d4d48cccb7f1c05463818aaaa403 Building WebAssembly samples using Docker diff -r c5627b8493f3 -r 4b5ec9ea268e Samples/WebAssembly/NOTES.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Samples/WebAssembly/NOTES.txt Thu Jun 25 09:13:56 2020 +0200 @@ -0,0 +1,22 @@ + +Building WebAssembly samples using Docker +========================================= + +The script "./docker-build.sh" can be used to quickly build the +WebAssembly samples on any GNU/Linux distribution equipped with +Docker. This avoids newcomers to install Emscripten and learn the +CMake options. Just type: + +$ ./docker-build.sh Release + +After successful build, the binaries will be installed in the +following folder (i.e. in the folder "wasm-binaries" at the root of +the source distribution): + +$ ls -l ../../wasm-binaries + + +NB: The source code of the Docker build environment can be found at +the following location: +https://github.com/jodogne/OrthancDocker/tree/master/wasm-builder + diff -r c5627b8493f3 -r 4b5ec9ea268e Samples/WebAssembly/docker-build.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Samples/WebAssembly/docker-build.sh Thu Jun 25 09:13:56 2020 +0200 @@ -0,0 +1,27 @@ +#!/bin/bash + +set -ex + +IMAGE=jodogne/wasm-builder:1.39.17-upstream + +if [ "$1" != "Debug" -a "$1" != "Release" ]; then + echo "Please provide build type: Debug or Release" + exit -1 +fi + +if [ -t 1 ]; then + # TTY is available => use interactive mode + DOCKER_FLAGS='-i' +fi + +ROOT_DIR=`dirname $(readlink -f $0)`/../.. + +mkdir -p ${ROOT_DIR}/wasm-binaries + +docker run -t ${DOCKER_FLAGS} --rm \ + --user $(id -u):$(id -g) \ + -v ${ROOT_DIR}:/source:ro \ + -v ${ROOT_DIR}/wasm-binaries:/target:rw ${IMAGE} \ + bash /source/Samples/WebAssembly/docker-internal.sh $1 + +ls -lR ${ROOT_DIR}/wasm-binaries/ diff -r c5627b8493f3 -r 4b5ec9ea268e Samples/WebAssembly/docker-internal.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Samples/WebAssembly/docker-internal.sh Thu Jun 25 09:13:56 2020 +0200 @@ -0,0 +1,30 @@ +#!/bin/bash +set -ex + +source /opt/emsdk/emsdk_env.sh + +# Use a folder that is writeable by non-root users for the Emscripten cache +export EM_CACHE=/tmp/emscripten-cache + +# Get the Orthanc framework +cd /tmp/ +hg clone https://hg.orthanc-server.com/orthanc/ + +# Make a copy of the source code in a writeable folder, because of +# "DownloadPackage.cmake" that writes to the "ThirdPartyDownloads" +# folder next to the "CMakeLists.txt" +cd /source +hg archive /tmp/source-writeable + +mkdir /tmp/build +cd /tmp/build + +cmake /tmp/source-writeable/Samples/WebAssembly \ + -DCMAKE_BUILD_TYPE=$1 \ + -DCMAKE_INSTALL_PREFIX=/target \ + -DCMAKE_TOOLCHAIN_FILE=${EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \ + -DORTHANC_FRAMEWORK_ROOT=/tmp/orthanc \ + -DSTATIC_BUILD=ON \ + -G Ninja + +ninja -j2 install