tomato-testing/other/emscripten/Dockerfile
Green Sky fd4c16d090 Squashed 'external/toxcore/c-toxcore/' changes from da438763d5b..671b1f92332
671b1f92332 fix: toxav rtp temp buffer allocation size was too large and cast from 32bit to 16bit, causing a overflow and making the allocated size too small
258148bd4e1 chore(ci): new minimum for all android versions is 21
d369c93c489 chore: Fix Emscripten build failing with no host specified
51b24d1c239 chore: Run CompCert on the stable branch of libsodium
cab1f7d522b chore: Update WineHQ's apt key hash
102a1fa9b82 chore: Fix -Werror=maybe-uninitialized in a test
cc9515da9c7 chore: Fix cpplint failing to install
3485b5feef3 chore: Disable -Wswitch-default and -Wunsafe-buffer-usage
719041e04b6 chore: Fix Circle CI failing on a missing clang lib
5344d7f84d0 fix: Memory leak in the bootstrap daemon
fa201681e18 cleanup: Remove useless if clause
7572888a218 chore: Fix GitHub actions deprecation warnings

git-subtree-dir: external/toxcore/c-toxcore
git-subtree-split: 671b1f92332a8314dccf76d5df93c0b6c1230636
2024-09-19 13:45:12 +02:00

86 lines
2.1 KiB
Docker

FROM ubuntu:20.04
ENV DEBIAN_FRONTEND="noninteractive"
# Install dependencies.
RUN apt-get update && apt-get install --no-install-recommends -y \
autoconf \
automake \
ca-certificates \
cmake \
curl \
git \
libtool \
make \
ninja-build \
pkg-config \
python3 \
unzip \
wget \
xz-utils \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /work/emsdk
RUN git clone --depth=1 https://github.com/emscripten-core/emsdk /work/emsdk \
&& ./emsdk install 3.1.3 \
&& ./emsdk activate 3.1.3
# Build libsodium.
RUN . "/work/emsdk/emsdk_env.sh" \
&& git clone --depth=1 --branch=1.0.18 https://github.com/jedisct1/libsodium /work/libsodium \
&& cd /work/libsodium \
&& autoreconf -fi \
&& emconfigure ./configure --disable-shared \
--without-pthreads \
--disable-ssp --disable-asm --disable-pie \
--host x86_64-linux-gnu \
&& emmake make install -j8
# Build an unused libsodium binding first so emcc caches all the system
# libraries. This makes rebuilds of toxcore below much faster.
RUN . "/work/emsdk/emsdk_env.sh" \
&& mkdir -p /work/wasm \
&& emcc -O3 -flto \
--closure=1 \
-s ALLOW_UNIMPLEMENTED_SYSCALLS=1 \
-s EXPORT_NAME=libtoxcore \
-s IGNORE_MISSING_MAIN=1 \
-s MAIN_MODULE=1 \
-s MALLOC=emmalloc \
-s MODULARIZE=1 \
-s STRICT=1 \
-s WEBSOCKET_URL=wss:// \
/usr/local/lib/libsodium.a \
-o /work/wasm/libsodium.js
# Build c-toxcore.
COPY . /work/c-toxcore
RUN . "/work/emsdk/emsdk_env.sh" \
&& cd /work/c-toxcore \
&& emcmake cmake -B_build -H. -GNinja \
-DCMAKE_INSTALL_PREFIX:PATH="/usr/local" \
-DCMAKE_C_FLAGS="-O3 -flto -fPIC" \
-DBUILD_TOXAV=OFF \
-DENABLE_SHARED=OFF \
-DBOOTSTRAP_DAEMON=OFF \
-DMIN_LOGGER_LEVEL=DEBUG \
&& emmake cmake --build _build --parallel 8 --target install
# Build wasm bindings.
RUN . "/work/emsdk/emsdk_env.sh" \
&& mkdir -p /work/wasm \
&& emcc -O3 -flto \
--closure=1 \
-s ALLOW_UNIMPLEMENTED_SYSCALLS=1 \
-s EXPORT_NAME=libtoxcore \
-s IGNORE_MISSING_MAIN=1 \
-s MAIN_MODULE=1 \
-s MALLOC=emmalloc \
-s MODULARIZE=1 \
-s STRICT=1 \
-s WEBSOCKET_URL=wss:// \
/usr/local/lib/libsodium.a \
/usr/local/lib/libtoxcore.a \
-o /work/wasm/libtoxcore.js