diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml new file mode 100644 index 0000000..277d5df --- /dev/null +++ b/.github/workflows/build-and-deploy.yml @@ -0,0 +1,25 @@ +name: build-and-deploy + +on: + push: + branches: + - '*' + - '!gh-pages' + pull_request: + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - name: Build + if: + run: ./build.sh + - name: Deploy to Pages 🚀 + if: github.ref == 'refs/heads/master' + uses: JamesIves/github-pages-deploy-action@v4 + with: + branch: gh-pages + folder: dist \ No newline at end of file diff --git a/README.md b/README.md index 61ab7f2..352aa5e 100644 --- a/README.md +++ b/README.md @@ -12,4 +12,4 @@ Infocom's non-Z6 games should be played with [Parchment](https://iplayif.com/) i Building -------- -Run `./build.sh` to build Infocom Frotz. However, because of an [obscure Emscripten bug](https://github.com/emscripten-core/emscripten/issues/21930), the build will often not work. Run `rm frotz/sfrotz.js && ./build.sh` to rebuild it, until it works. This is for the moment preventing automatic builds and deployments. \ No newline at end of file +Run `./build.sh` to build Infocom Frotz. \ No newline at end of file diff --git a/build.sh b/build.sh index 9909522..6852994 100755 --- a/build.sh +++ b/build.sh @@ -17,16 +17,17 @@ COMMON_OPTS="$PORTS" COMP_OPTS="$COMMON_OPTS -DNO_EXECINFO_H" LINK_OPTS="$COMMON_OPTS -lidbfs.js --js-library ../src/frotz-library.js --pre-js ../src/preamble.js --profiling-funcs -sALLOW_MEMORY_GROWTH -sASYNCIFY -sENVIRONMENT=web" -# docker run --rm -t \ -# -u $(id -u):$(id -g) \ -# -v $(pwd):/src \ -# infocom-frotz:$DOCKER_TAG \ -# /bin/bash -c -e " \\ -# emmake make -C frotz --no-print-directory \\ -# CFLAGS=\"$COMP_OPTS\" LDFLAGS=\"$LINK_OPTS\" \\ -# EXTENSION=.js \\ -# sdl \\ -# " +rm frotz/sfrotz.js +docker run --rm -t \ + -u $(id -u):$(id -g) \ + -v $(pwd):/src \ + infocom-frotz:$DOCKER_TAG \ + /bin/bash -c -e " \\ + emmake make -C frotz --no-print-directory \\ + CFLAGS=\"$COMP_OPTS\" LDFLAGS=\"$LINK_OPTS\" \\ + EXTENSION=.js \\ + sdl \\ + " ./src/makehtml.mjs diff --git a/src/Dockerfile b/src/Dockerfile index 6425bd4..2a8c87a 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -1,7 +1,3 @@ -FROM emscripten/emsdk:3.1.59 +FROM emscripten/emsdk:3.1.62 -#RUN apt-get update && \ -# apt-get install pkg-config && \ -# rm -rf /var/lib/apt/lists/* - -RUN embuilder build zlib freetype libjpeg libpng sdl2 sdl2_mixer \ No newline at end of file +RUN embuilder build freetype libjpeg libpng sdl2 sdl2_mixer zlib \ No newline at end of file diff --git a/src/frotz-library.js b/src/frotz-library.js index 8370ce3..1cda70a 100644 --- a/src/frotz-library.js +++ b/src/frotz-library.js @@ -130,31 +130,6 @@ const FROTZ_JS = { // We've already set the title emscripten_set_window_title() {}, - - // Sync IDBFS after saving a savefile - fd_close(fd) { - try { - const stream = SYSCALLS.getStreamFromFD(fd) - const flags = stream.flags - const path = stream.path - FS.close(stream) - // Don't run if we're currently syncing (because syncing will run this code) - if (FS.syncFSRequests === 0) { - // Then check that we're saving a savefile - if (path.startsWith('/saves/') && flags & 3) { - FS.syncfs(err => { - if (err) { - console.log(err) - } - }) - } - } - return 0 - } catch (e) { - if (typeof FS == 'undefined' || !(e.name === 'ErrnoError')) throw e - return e.errno - } - }, } addToLibrary(FROTZ_JS) \ No newline at end of file diff --git a/src/preamble.js b/src/preamble.js index e048df4..c1a6ad6 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -11,7 +11,7 @@ Module.preRun = () => { // Set up the saves folder with IDBFS FS.mkdir('/saves') - FS.mount(IDBFS, {}, '/saves') + FS.mount(IDBFS, {autoPersist: true}, '/saves') FS.chdir('/saves') FS.syncfs(true, err => { if (err) {