# syntax=docker/dockerfile:1 # # fmptools (Evan Miller, MIT) compiled to WebAssembly for johnmcm.com's # /filemaker-viewer: the reader library for FileMaker Pro .fp3, .fp5, .fp7 # and .fmp12 files, behind a few plain C functions in src/wrapper.c. Only the # library is built (no fmp2excel/fmp2json/fmp2sqlite, so no libxlsxwriter, # yajl or SQLite); the page writes Excel, CSV and JSON itself. The library is # built unmodified; the exact sources built are copied into source/ and # published with these files at /source/fmptools/. The Emscripten image is # pinned by version and digest, fmptools by commit (see README.md). # # ./build.ps1 (or) docker build --target export --output type=local,dest=dist . ARG EMSDK_IMAGE=emscripten/emsdk:6.0.10@sha256:e077d54e2b8970575ebc4f185ac1de0b95c05f2b266134d4ba27449af7aebf65 FROM ${EMSDK_IMAGE} AS build ARG FMPTOOLS_COMMIT=fd32a6c4f425a377f27efd558cf9bc7cc09985a6 RUN git clone -q https://github.com/evanmiller/fmptools /fmptools \ && git -C /fmptools checkout -q ${FMPTOOLS_COMMIT} \ && test "$(git -C /fmptools rev-parse HEAD)" = "${FMPTOOLS_COMMIT}" WORKDIR /build COPY src/wrapper.c src/macroman.c ./ # The library's sources as its Makefile.am lists them. fmp_open_buffer reads # from memory through fmemopen (in Emscripten's musl libc). fmp7/fmp12 text # goes through fmptools' own SCSU decoder; the MacRoman text of .fp3/.fp5 # files through src/macroman.c, which stands in for libc's iconv (musl has no # MacRoman table). RUN mkdir -p /out/source \ && SRCS="block.c dump_file.c fmp.c scsu.c list_columns.c list_tables.c read_values.c" \ && cd /fmptools/src && cp $SRCS fmp.h fmp_internal.h /fmptools/LICENSE /fmptools/README.md /fmptools/HACKING /out/source/ && cd /build \ && emcc -O2 -DHAVE_FMEMOPEN=1 -I/fmptools/src wrapper.c macroman.c $(for f in $SRCS; do echo /fmptools/src/$f; done) -o /out/fmptools.mjs \ -sMODULARIZE=1 -sEXPORT_ES6=1 -sEXPORT_NAME=createFmptools \ -sENVIRONMENT=web,worker,node \ -sALLOW_MEMORY_GROWTH=1 \ -sMAXIMUM_MEMORY=4294967296 \ -sFILESYSTEM=0 \ -sDYNAMIC_EXECUTION=0 \ -sINCOMING_MODULE_JS_API=print,printErr,locateFile \ -sEXPORTED_FUNCTIONS=_fm_input,_fm_open,_fm_meta,_fm_read,_fm_out,_fm_out_length,_fm_out_free,_fm_pool,_fm_stream,_fm_close \ -sEXPORTED_RUNTIME_METHODS=HEAPU8,UTF8ToString FROM scratch AS export COPY --from=build /out/ /