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
26 changes: 6 additions & 20 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,14 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: cachix/install-nix-action@v31
- name: Install GHCup
uses: haskell/ghcup-setup@v1
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
cabal: latest

- name: Install cachix
uses: cachix/cachix-action@v16
with:
name: haskell-miso-cachix

- name: Build WASM using Nix
run: nix develop .#wasm --command bash -c "make"

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

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

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./public
- name: Build using GHC
run: |
make ghcup-build

deploy:
if: github.ref == 'refs/heads/main'
Expand Down
20 changes: 20 additions & 0 deletions 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 @@ -21,13 +25,29 @@ build:
$(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

serve:
http-server public

ghcup-serve:
cd public; php -S localhost:1234

clean:
rm -rf dist-newstyle public

Expand Down