diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 48478fe..6a0c6e5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 @@ -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: diff --git a/Makefile b/Makefile index dcf1171..67e8152 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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 @@ -30,6 +47,7 @@ serve: clean: rm -rf dist-newstyle public + . ~/.ghc-wasm/env && cabal clean update-js: cabal update --with-ghc=javascript-unknown-ghcjs-ghc --with-hc-pkg=javascript-unknown-ghcjs-ghc-pkg