# syntax=docker/dockerfile:1 # # libwpd (WordPerfect for DOS, Windows and Mac, versions 1 to X9 and later) # with librevenge, compiled to WebAssembly for johnmcm.com's # /open-file/wordperfect. Built the same way as wasm-src/wps/: the Emscripten # image pinned by digest, every source tarball by SHA-256 from the projects' # own release locations, and the same JSON recorder (src/recorder.*), so the # page builds the document with the Works Viewer's code. # # ./build.ps1 (or) docker build --target export --output type=local,dest=dist . # # Licences: libwpd and librevenge are MPL-2.0 (or LGPL-2.1+). These build # files are published at /source/wpd/; 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 LIBWPD_VERSION=0.10.3 ARG LIBWPD_SHA256=2465b0b662fdc5d4e3bebcdc9a79027713fb629ca2bff04a3c9251fdec42dd09 # libwpd 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). 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 libwpd.tar.xz https://dev-www.libreoffice.org/src/libwpd-${LIBWPD_VERSION}.tar.xz \ && echo "${LIBWPD_SHA256} libwpd.tar.xz" | sha256sum -c - \ && tar xjf librevenge.tar.bz2 && tar xJf libwpd.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/libwpd-${LIBWPD_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" \ REVENGE_STREAM_CFLAGS="-I${PREFIX}/include/librevenge-0.0" REVENGE_STREAM_LIBS="-L${PREFIX}/lib -lrevenge-stream-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 -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/libwpd-0.10 -c binding.cpp -o /tmp/binding.o \ && em++ -Oz /tmp/binding.o /tmp/recorder.o -L${PREFIX}/lib -lwpd-0.10 -lrevenge-stream-0.0 -lrevenge-0.0 \ ${EH_FLAGS} ${PORT_FLAGS} -lembind \ -sMODULARIZE=1 -sEXPORT_ES6=1 -sEXPORT_NAME=createWpd \ -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,wasmBinary \ -o /out/wpd.mjs \ && ls -l /out FROM scratch AS export COPY --from=wasm /out/ /