1
0
forked from GitHub/gf-core

Add Dockerfile and script for building WASM files

This commit is contained in:
John J. Camilleri
2022-08-01 11:56:11 +02:00
parent 539b946c96
commit 72bec84f58
2 changed files with 58 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
FROM emscripten/emsdk:latest
RUN apt update
RUN apt install -y autoconf automake libtool make
WORKDIR /tmp/c
COPY gu/*.c gu/*.h /tmp/c/gu/
COPY pgf/*.c pgf/*.h /tmp/c/pgf/
COPY pgf/lightning/i386/*.h /tmp/c/pgf/lightning/i386/
COPY pgf/lightning/*.h /tmp/c/pgf/lightning/
COPY \
Makefile.am \
configure.ac \
lib*.pc.in \
/tmp/c/
RUN autoreconf -i
RUN emconfigure ./configure
RUN emmake make
RUN emcc .libs/libgu.a .libs/libpgf.a -o pgf.html \
-sFORCE_FILESYSTEM \
-sALLOW_MEMORY_GROWTH \
-sEXPORTED_FUNCTIONS="\
_pgf_read,\
_pgf_abstract_name,\
_pgf_read_expr,\
_pgf_print_expr,\
_pgf_expr_arity,\
_gu_new_pool,\
_gu_new_exn,\
_gu_data_in,\
_gu_exn_is_raised,\
_gu_exn_caught_,\
_gu_exn_caught_data,\
_gu_exn_clear,\
_gu_new_string_buf,\
_gu_string_buf_out,\
_gu_string_buf_data,\
_malloc,\
_free\
"\
-sEXPORTED_RUNTIME_METHODS="\
ccall,\
FS,\
getValue,\
stringToUTF8,\
UTF8ToString,\
allocateUTF8\
"

View File

@@ -0,0 +1,10 @@
#! /usr/bin/env bash
set -e
cd ../c
# Build inside Docker image
IMAGE="gf/build-c-runtime-wasm"
docker build . --file Dockerfile-wasm --tag $IMAGE
# Copy bulit files from container to host
docker run --rm --volume "$PWD":/tmp/host $IMAGE bash -c "cp pgf.js pgf.wasm /tmp/host/"