#!/usr/bin/env bash # Compiles the StarOffice binding (binding_star.cpp), the event recorder and the JSON drawing generator and links them with # libstaroffice and librevenge (with its generators), built in the Dockerfile's stardeps stage. Runs inside the # emscripten/emsdk container. # # compile_star.sh -> /star.mjs and /star.wasm set -euo pipefail OUT="${1:-/out}" PREFIX="${PREFIX:-/opt/rv}" EH_FLAGS="${EH_FLAGS:--fwasm-exceptions}" PORTS="-sUSE_ZLIB=1 -sUSE_BOOST_HEADERS=1" INCLUDES="-I${PREFIX}/include/librevenge-0.0 -I${PREFIX}/include/libstaroffice-0.0" LIBS="-L${PREFIX}/lib -lstaroffice-0.0 -lrevenge-generators-0.0 -lrevenge-stream-0.0 -lrevenge-0.0" mkdir -p "${OUT}" em++ -std=c++17 -Oz ${EH_FLAGS} ${PORTS} ${INCLUDES} -c JSONDrawingGenerator.cpp -o /tmp/JSONDrawingGenerator.o em++ -std=c++17 -Oz ${EH_FLAGS} ${PORTS} ${INCLUDES} -c recorder.cpp -o /tmp/recorder.o em++ -std=c++17 -Oz ${EH_FLAGS} ${PORTS} ${INCLUDES} -c binding_star.cpp -o /tmp/binding.o em++ -Oz /tmp/binding.o /tmp/recorder.o /tmp/JSONDrawingGenerator.o ${LIBS} \ ${EH_FLAGS} ${PORTS} \ -lembind \ -sMODULARIZE=1 -sEXPORT_ES6=1 -sEXPORT_NAME=createStar \ -sENVIRONMENT=web,worker,node \ -sALLOW_MEMORY_GROWTH=1 \ -sMAXIMUM_MEMORY=1073741824 \ -sSTACK_SIZE=1048576 \ -sINITIAL_MEMORY=33554432 \ -sFILESYSTEM=0 \ -sDYNAMIC_EXECUTION=0 \ -sINCOMING_MODULE_JS_API=print,printErr,locateFile \ -o "${OUT}/star.mjs" ls -l "${OUT}"