#!/usr/bin/env bash # Compiles the old Mac document binding (binding_mac.cpp), the event recorder and the JSON drawing generator and links them with # libmwaw and librevenge (with its generators), built in the Dockerfile's macdeps stage. Runs inside the # emscripten/emsdk container. # # compile_mac.sh -> /mac.mjs and /mac.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/libmwaw-0.3" LIBS="-L${PREFIX}/lib -lmwaw-0.3 -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_mac.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=createMac \ -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}/mac.mjs" ls -l "${OUT}"