From e1453cb4c8b640db293726d33f77c1cb03b83634 Mon Sep 17 00:00:00 2001 From: Corwin Date: Wed, 3 Apr 2024 22:58:10 +0100 Subject: [PATCH] build mgba wasm --- justfile | 5 +++++ website/app/.gitignore | 3 +++ website/mgba-wasm/BuildMgbaWasm | 25 +++++++++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 website/mgba-wasm/BuildMgbaWasm diff --git a/justfile b/justfile index ce2d3c50..b4d53dd5 100644 --- a/justfile +++ b/justfile @@ -92,6 +92,11 @@ release +args: (_run-tool "release" args) miri: (cd agb-hashmap && cargo miri test) +build-mgba-wasm: + rm -r website/app/src/vendor + mkdir website/app/src/vendor + podman build --file website/mgba-wasm/BuildMgbaWasm --output=website/app/src/vendor . + _run-tool +tool: (cd tools && cargo build) "$CARGO_TARGET_DIR/debug/tools" {{tool}} diff --git a/website/app/.gitignore b/website/app/.gitignore index 4d29575d..2fec0226 100644 --- a/website/app/.gitignore +++ b/website/app/.gitignore @@ -21,3 +21,6 @@ npm-debug.log* yarn-debug.log* yarn-error.log* + + +src/vendor \ No newline at end of file diff --git a/website/mgba-wasm/BuildMgbaWasm b/website/mgba-wasm/BuildMgbaWasm new file mode 100644 index 00000000..ba308ed3 --- /dev/null +++ b/website/mgba-wasm/BuildMgbaWasm @@ -0,0 +1,25 @@ +FROM docker.io/emscripten/emsdk:3.1.46 as builder + +RUN apt-get update && \ + apt-get install -y --no-install-recommends make cmake git && \ + apt-get autoremove -y && apt-get clean + +RUN userdel emscripten -r +USER root +ENV BUILD_DIR=build-wasm + +WORKDIR / + +RUN git clone https://github.com/thenick775/mgba.git --filter=tree:0 -b feature/wasm +RUN mkdir /mgba/build-wasm +WORKDIR /mgba/build-wasm +RUN git checkout 27dede256b6de36303a87d0886f81505a0f30c28 + + +RUN emcmake cmake .. && make install DESTDIR=install + + +FROM scratch +COPY --from=builder /mgba/build-wasm/wasm/mgba.js . +COPY --from=builder /mgba/build-wasm/wasm/mgba.wasm . +COPY --from=builder /mgba/build-wasm/wasm/mgba.d.ts .