# syntax=docker/dockerfile:1 # # libwps (Microsoft Works, Lotus 1-2-3, Quattro Pro, Word for DOS, Write, # Multiplan, Pocket Word, XYWrite) with librevenge, compiled to WebAssembly # for johnmcm.com's /works-viewer. Built the same way as wasm-src/revenge/: # the Emscripten image pinned by digest, every source tarball by SHA-256 from # the projects' own release locations. # # ./build.ps1 (or) docker build --target export --output type=local,dest=dist . # # Licences: libwps and librevenge are MPL-2.0 (or LGPL-2.1+). These build # files are published at /source/wps/; the sources are the release tarballs # named below, checked by SHA-256. ARG EMSDK_IMAGE=emscripten/emsdk:6.0.10@sha256:e077d54e2b8970575ebc4f185ac1de0b95c05f2b266134d4ba27449af7aebf65 FROM ${EMSDK_IMAGE} AS deps ARG LIBREVENGE_VERSION=0.0.5 ARG LIBREVENGE_SHA256=5892ca6796f7a2a93d580832e907e849b19d980b40d326a283b18877ab6de0c5 ARG LIBWPS_VERSION=0.4.14 ARG LIBWPS_SHA256=365b968e270e85a8469c6b160aa6af5619a4e6c995dbb04c1ecc1b4dd13e80de # libwps throws C++ exceptions while parsing; keep them, as native WebAssembly exceptions. ENV EH_FLAGS="-fwasm-exceptions" ENV PREFIX=/opt/rv # librevenge's headers include Boost (header-only); libwps itself needs nothing else. ENV PORT_FLAGS="-sUSE_ZLIB=1 -sUSE_BOOST_HEADERS=1" RUN embuilder build boost_headers zlib WORKDIR /src RUN curl -fsSL -o librevenge.tar.bz2 https://dev-www.libreoffice.org/src/librevenge-${LIBREVENGE_VERSION}.tar.bz2 \ && echo "${LIBREVENGE_SHA256} librevenge.tar.bz2" | sha256sum -c - \ && curl -fsSL -o libwps.tar.xz https://dev-www.libreoffice.org/src/libwps-${LIBWPS_VERSION}.tar.xz \ && echo "${LIBWPS_SHA256} libwps.tar.xz" | sha256sum -c - \ && tar xjf librevenge.tar.bz2 && tar xJf libwps.tar.xz WORKDIR /src/librevenge-${LIBREVENGE_VERSION} RUN emconfigure ./configure --prefix=${PREFIX} \ --disable-shared --enable-static \ --disable-tests --without-docs --disable-werror --disable-weffc \ --enable-streams --disable-generators \ CFLAGS="-Oz ${EH_FLAGS}" CXXFLAGS="-Oz ${EH_FLAGS} ${PORT_FLAGS}" CPPFLAGS="${PORT_FLAGS}" \ LDFLAGS="${PORT_FLAGS} ${EH_FLAGS}" \ ZLIB_CFLAGS=" " ZLIB_LIBS="-sUSE_ZLIB=1" \ && emmake make -j"$(nproc)" && emmake make install WORKDIR /src/libwps-${LIBWPS_VERSION} RUN emconfigure ./configure --prefix=${PREFIX} \ --disable-shared --enable-static \ --disable-tools --disable-fuzzers --without-docs --disable-werror --disable-weffc \ CFLAGS="-Oz ${EH_FLAGS}" CXXFLAGS="-Oz ${EH_FLAGS} ${PORT_FLAGS}" CPPFLAGS="${PORT_FLAGS}" \ LDFLAGS="${PORT_FLAGS} ${EH_FLAGS}" \ REVENGE_CFLAGS="-I${PREFIX}/include/librevenge-0.0" REVENGE_LIBS="-L${PREFIX}/lib -lrevenge-0.0" \ && emmake make -j"$(nproc)" && emmake make install FROM deps AS wasm WORKDIR /binding COPY src/ ./ RUN mkdir -p /out \ && em++ -std=c++17 -Oz ${EH_FLAGS} ${PORT_FLAGS} -I${PREFIX}/include/librevenge-0.0 -I${PREFIX}/include/libwps-0.4 -c recorder.cpp -o /tmp/recorder.o \ && em++ -std=c++17 -Oz ${EH_FLAGS} ${PORT_FLAGS} -I${PREFIX}/include/librevenge-0.0 -I${PREFIX}/include/libwps-0.4 -c binding.cpp -o /tmp/binding.o \ && em++ -Oz /tmp/binding.o /tmp/recorder.o -L${PREFIX}/lib -lwps-0.4 -lrevenge-stream-0.0 -lrevenge-0.0 \ ${EH_FLAGS} ${PORT_FLAGS} -lembind \ -sMODULARIZE=1 -sEXPORT_ES6=1 -sEXPORT_NAME=createWps \ -sENVIRONMENT=web,worker,node \ -sALLOW_MEMORY_GROWTH=1 -sSTACK_SIZE=1048576 -sINITIAL_MEMORY=33554432 \ -sFILESYSTEM=0 -sDYNAMIC_EXECUTION=0 \ -sINCOMING_MODULE_JS_API=print,printErr,locateFile \ -o /out/wps.mjs \ && ls -l /out FROM scratch AS export COPY --from=wasm /out/ /