Skip to content
Snippets Groups Projects
Commit 36953dc4 authored by Bartek Wrona's avatar Bartek Wrona
Browse files

Docker and script definitions for emscripten toolset (including precompiled...

Docker and script definitions for emscripten toolset (including precompiled boost openssl and sec256k1 libraries)
parent 27bf7a31
No related branches found
No related tags found
1 merge request!12Dockerfile definition and helper scripts related to preparing a toolchain image able to produce WASM binaries
ARG EMSCRIPTEN_VERSION=3.1.43
FROM emscripten/emsdk:${EMSCRIPTEN_VERSION} AS pure_emscripten_sdk
FROM pure_emscripten_sdk AS supplemented_tools_sdk
USER root
RUN apt-get update && \
DEBIAN_FRONTEND=noniteractive apt-get install -y \
git \
autoconf \
libtool
FROM supplemented_tools_sdk AS lib_source
ARG BOOST_VERSION_TAG=boost-1.82.0
ENV BOOST_VERSION_TAG=${BOOST_VERSION_TAG}
ARG OPENSSL_VERSION_TAG=openssl-3.1.1
ENV OPENSSL_VERSION_TAG=${OPENSSL_VERSION_TAG}
USER emscripten
WORKDIR /home/emscripten
RUN mkdir -vp tmp_src && cd tmp_src && \
git clone https://github.com/boostorg/boost.git && \
cd boost && \
git checkout tags/${BOOST_VERSION_TAG} && \
git submodule update --init --recursive && \
cd .. && \
git clone https://github.com/openssl/openssl.git && \
cd openssl && \
git checkout tags/${OPENSSL_VERSION_TAG} && \
git submodule update --init --recursive && \
cd .. && \
git clone https://github.com/ElementsProject/secp256k1-zkp.git
FROM lib_source as emscripten_lib_builder
USER emscripten
WORKDIR /home/emscripten
ENV TMP_SRC=/home/emscripten/tmp_src
ADD --chown=emscripten ./scripts/bash/emscripten /home/emscripten/scripts
RUN mkdir -vp "${TMP_SRC}"
FROM emscripten_lib_builder AS emscripten_boost_builder
USER emscripten
WORKDIR /home/emscripten
RUN /home/emscripten/scripts/prepare_boost.sh "${TMP_SRC}" "/emsdk/upstream/emscripten/cache/sysroot/"
FROM emscripten_lib_builder AS emscripten_openssl_builder
USER emscripten
WORKDIR /home/emscripten
RUN /home/emscripten/scripts/prepare_openssl.sh "${TMP_SRC}" "/emsdk/upstream/emscripten/cache/sysroot/"
FROM emscripten_lib_builder AS emscripten_secp256k1_builder
USER emscripten
WORKDIR /home/emscripten
RUN /home/emscripten/scripts/prepare_secp256k1-zkp.sh "${TMP_SRC}" "/emsdk/upstream/emscripten/cache/sysroot/"
FROM supplemented_tools_sdk AS emscripten_builder
USER emscripten
WORKDIR /home/emscripten
COPY --chown=emscripten --from=emscripten_secp256k1_builder /emsdk/upstream/emscripten/cache/sysroot/ /emsdk/upstream/emscripten/cache/sysroot/
COPY --chown=emscripten --from=emscripten_boost_builder /emsdk/upstream/emscripten/cache/sysroot/ /emsdk/upstream/emscripten/cache/sysroot/
COPY --chown=emscripten --from=emscripten_openssl_builder /emsdk/upstream/emscripten/cache/sysroot/ /emsdk/upstream/emscripten/cache/sysroot/
COPY --chown=emscripten --from=emscripten_openssl_builder /emsdk/upstream/emscripten/cache/sysroot/libx32/ /emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/
COPY --chown=emscripten --from=emscripten_openssl_builder /emsdk/upstream/emscripten/cache/sysroot/libx32/pkgconfig/* /emsdk/upstream/emscripten/cache/sysroot/lib/pkgconfig/
#! /bin/bash
set -euo pipefail
SCRIPTSDIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
SRCDIR="${SCRIPTSDIR}/../../"
REGISTRY=${1:-"registry.gitlab.syncad.com/hive/common-ci-configuration/"}
EMSDK_VERSION=${1:-"3.1.43"}
export DOCKER_BUILDKIT=1
docker build --target=emscripten_builder \
--build-arg EMSCRIPTEN_VERSION=${EMSDK_VERSION} \
-t ${REGISTRY}emsdk:3.1.43 \
-f "${SRCDIR}/Dockerfile.emscripten" "${SRCDIR}"
diff --git a/src/tools/emscripten.jam b/src/tools/emscripten.jam
index d6594c5e4..d7ab28ed1 100644
--- a/src/tools/emscripten.jam
+++ b/src/tools/emscripten.jam
@@ -6,6 +6,7 @@
import feature ;
import os ;
import toolset ;
+import generators ;
import common ;
import gcc ;
import type ;
@@ -51,6 +52,9 @@ toolset.inherit-flags emscripten : gcc
<rtti>off <rtti>on
;
+generators.override builtin.lib-generator : emscripten.prebuilt ;
+generators.override emscripten.searched-lib-generator : searched-lib-generator ;
+
type.set-generated-target-suffix EXE : <toolset>emscripten : "js" ;
type.set-generated-target-suffix OBJ : <toolset>emscripten : "bc" ;
type.set-generated-target-suffix STATIC_LIB : <toolset>emscripten : "bc" ;
#! /bin/bash
set -xeuo pipefail
TMP_SRC=${1:?"Missing arg #1 to specify source temp directory"}
INSTALL_PREFIX=${2:?"Missing arg #2 to specify prebuilt libraries install prefix"}
echo "Entering directory: ${TMP_SRC}/boost/tools/build"
cd "${TMP_SRC}/boost/tools/build"
# Clean local mods if any
git checkout .
# to fix ambigous generators specific to SEARCH_LIB
git apply /home/emscripten/scripts/emscripten_toolset.patch
rm -vrf "${TMP_SRC}/boost_build/"
mkdir -vp "${TMP_SRC}/boost_build/"
echo "Entering directory: ${TMP_SRC}/boost"
cd "${TMP_SRC}/boost"
./bootstrap.sh --without-icu --prefix="${INSTALL_PREFIX}"
printf "using clang : emscripten : emcc -s USE_ZLIB=1 -s USE_ICU=0 : <archiver>emar <ranlib>emranlib <linker>emlink <cxxflags>\"-std=c++11 -s USE_ICU=0\" ;" | tee -a ./project-config.jam >/dev/null
./b2 \
--build-dir="${TMP_SRC}/boost_build/" \
--prefix="${INSTALL_PREFIX}" \
-j $(nproc) \
-q \
runtime-link=static \
link=static \
toolset=clang-emscripten \
variant=release \
threading=single \
--with-atomic \
--with-chrono \
--with-date_time \
--with-filesystem \
--with-program_options \
--with-regex \
--with-system \
install
#! /bin/bash
set -xeuo pipefail
TMP_SRC=${1:?"Missing arg #1 to specify source temp directory"}
INSTALL_PREFIX=${2:?"Missing arg #2 to specify prebuilt libraries install prefix"}
echo "Entering directory: ${TMP_SRC}/openssl"
cd "${TMP_SRC}/openssl"
emconfigure ./Configure \
--prefix="${INSTALL_PREFIX}" \
--openssldir="${INSTALL_PREFIX}" \
no-hw \
no-shared \
no-asm \
no-threads \
no-ssl3 \
no-dtls \
no-engine \
no-dso \
linux-x32 \
-static
sed -i 's/$(CROSS_COMPILE)//' Makefile
emmake make -j 8
emmake make install
#! /bin/bash
set -xeuo pipefail
TMP_SRC=${1:?"Missing arg #1 to specify source temp directory"}
INSTALL_PREFIX=${2:?"Missing arg #2 to specify prebuilt libraries install prefix"}
echo "Entering directory: ${TMP_SRC}/secp256k1-zkp"
cd "${TMP_SRC}/secp256k1-zkp"
git checkout d22774e248c703a191049b78f8d04f37d6fcfa05
export VERBOSE=1
emconfigure ./autogen.sh
emconfigure ./configure --prefix=${INSTALL_PREFIX} --with-asm=no --enable-shared=no --enable-tests=no --enable-benchmark=no --enable-exhaustive-tests=no --with-pic=no --with-valgrind=no --enable-module-recovery=yes --enable-module-rangeproof=yes --enable-experimental
emmake make
emmake make install
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment