Skip to content

Commit

Permalink
Update Emscripten to fix non-determinism issue, and build and deploy …
Browse files Browse the repository at this point in the history
…with Gihub Actions
  • Loading branch information
curiousdannii committed Jul 9, 2024
1 parent f1daf33 commit 9539686
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 43 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Run `./build.sh` to build Infocom Frotz.
21 changes: 11 additions & 10 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 2 additions & 6 deletions src/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
RUN embuilder build freetype libjpeg libpng sdl2 sdl2_mixer zlib
25 changes: 0 additions & 25 deletions src/frotz-library.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion src/preamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 9539686

Please sign in to comment.