Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: ners/simply-nix@main
with:
reclaim_space: true

- uses: actions/checkout@v4

- uses: cachix/install-nix-action@v31
Expand All @@ -30,11 +34,22 @@ jobs:
run: nix develop .#wasm --command bash -c "make"

- name: Clean and GC
run: nix develop .#wasm --command bash -c "make" && nix-collect-garbage -d
run: |
nix develop .#wasm --command bash -c "make" && nix-collect-garbage -d
make clean

- name: Build JS using Nix
run: nix develop .#ghcjs --command bash -c "make js"

- name: Install GHCup
uses: haskell/ghcup-setup@v1
with:
cabal: latest

- name: Build using GHCup WASM
run: |
make ghcup-build

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
Expand Down
20 changes: 19 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
.PHONY= update build optim

CABAL_ARGS += --allow-newer=base,template-haskell --with-compiler=wasm32-wasi-ghc --with-hc-pkg=wasm32-wasi-ghc-pkg --with-hsc2hs=wasm32-wasi-hsc2hs --with-haddock=wasm32-wasi-haddock
RELEASE_CHANNEL := https://gitlab.haskell.org/haskell-wasm/ghc-wasm-meta/-/raw/master/ghcup-wasm-0.0.9.yaml
WASM_BOOTSTRAP := https://gitlab.haskell.org/haskell-wasm/ghc-wasm-meta/-/raw/master/bootstrap.sh

all: update build optim

js: update-js build-js
Expand All @@ -14,13 +18,26 @@ watch:
ghciwatch --after-startup-ghci :main --after-reload-ghci :main --watch . --debounce 50ms --command 'wasm32-wasi-cabal repl app -finteractive --repl-options="-fghci-browser -fghci-browser-port=8080"'

build:
wasm32-wasi-cabal build
wasm32-wasi-cabal build
rm -rf public
cp -r static public
$(eval my_wasm=$(shell wasm32-wasi-cabal list-bin app | tail -n 1))
$(shell wasm32-wasi-ghc --print-libdir)/post-link.mjs --input $(my_wasm) --output public/ghc_wasm_jsffi.js
cp -v $(my_wasm) public/

ghcup-update:
cabal update $(CABAL_ARGS)

ghcup-build: | install-wasm-via-ghcup ghcup-update
. ~/.ghc-wasm/env && \
cabal build $(CABAL_ARGS)

install-wasm-via-ghcup:
curl $(WASM_BOOTSTRAP) | SKIP_GHC=1 sh
. ~/.ghc-wasm/env && \
ghcup config add-release-channel $(RELEASE_CHANNEL) && \
ghcup install ghc --set wasm32-wasi-9.15 -- $$CONFIGURE_ARGS

optim:
wasm-opt -all -O2 public/app.wasm -o public/app.wasm
wasm-tools strip -o public/app.wasm public/app.wasm
Expand All @@ -30,6 +47,7 @@ serve:

clean:
rm -rf dist-newstyle public
. ~/.ghc-wasm/env && cabal clean

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why have . ~/.ghc-wasm/env here?


update-js:
cabal update --with-ghc=javascript-unknown-ghcjs-ghc --with-hc-pkg=javascript-unknown-ghcjs-ghc-pkg
Expand Down
Loading