Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP #295

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft

WIP #295

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 38 additions & 15 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,39 +1,62 @@
# Builds SWI-Prolog WebAssembly version.
# https://swi-prolog.discourse.group/t/swi-prolog-in-the-browser-using-wasm/5650
ARG EMSDK_VERSION
FROM emscripten/emsdk:$EMSDK_VERSION

FROM emscripten/emsdk:$EMSDK_VERSION AS ninja
# Installs build dependencies.
RUN apt-get update && apt-get install -y bzip2 lzip ninja-build xz-utils
RUN apt-get update
RUN apt-get install -y ninja-build

FROM emscripten/emsdk:$EMSDK_VERSION as swipl-devel-build

# Clone SWI-Prolog. Only make a shallow clone and only clone the
# submodules we need at depth 1.
WORKDIR /
ARG SWIPL_VERSION
RUN git clone --depth 1 https://github.com/SWI-Prolog/swipl-devel --branch V$SWIPL_VERSION
RUN cd swipl-devel && git submodule update --init --depth 1 -j 100 \
packages/chr packages/clib packages/clpqr packages/http packages/nlp \
packages/pcre packages/plunit packages/sgml packages/RDF \
packages/semweb packages/zlib

FROM emscripten/emsdk:$EMSDK_VERSION as zlib

# Download dependency sources
WORKDIR /wasm
ARG ZLIB_VERSION
ARG PCRE2_NAME
RUN wget --no-verbose -qO- https://zlib.net/zlib-$ZLIB_VERSION.tar.gz | tar xvz
RUN git clone --branch=$PCRE2_NAME --depth 1 https://github.com/PCRE2Project/pcre2

# Build the dependencies and install them in /wasm
WORKDIR /wasm/zlib-$ZLIB_VERSION
RUN emconfigure ./configure --static --prefix=/wasm
RUN EMCC_CFLAGS=-Wno-deprecated-non-prototype emmake make
RUN emmake make install

FROM emscripten/emsdk:$EMSDK_VERSION as pcre-clone
# Download dependency sources
WORKDIR /wasm
ARG PCRE2_NAME
RUN git clone --branch=$PCRE2_NAME --depth 1 https://github.com/PCRE2Project/pcre2

FROM ninja as pcre

COPY --from=pcre-clone /wasm /wasm
# Build the pcre dependencies and install them in /wasm
WORKDIR /wasm/pcre2/build
RUN emcmake cmake -DCMAKE_INSTALL_PREFIX=/wasm \
-DPCRE2GREP_SUPPORT_JIT=OFF \
-G Ninja .. $@
RUN ninja && ninja install
RUN ninja
RUN ninja install

# Clone SWI-Prolog. Only make a shallow clone and only clone the
# submodules we need at depth 1.
WORKDIR /
ARG SWIPL_VERSION
RUN git clone --depth 1 https://github.com/SWI-Prolog/swipl-devel --branch V$SWIPL_VERSION
RUN cd swipl-devel && git submodule update --init --depth 1 -j 100 \
packages/chr packages/clib packages/clpqr packages/http packages/nlp \
packages/pcre packages/plunit packages/sgml packages/RDF \
packages/semweb packages/zlib
FROM ninja

# Installs build dependencies.
RUN apt-get update
RUN apt-get install -y ninja-build

COPY --from=swipl-devel-build /swipl-devel /swipl-devel
COPY --from=zlib /wasm /wasm
COPY --from=pcre /wasm /wasm

# Build SWIPL
WORKDIR /swipl-devel/build.wasm
Expand Down