diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 48478fe..3125d0f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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' diff --git a/Makefile b/Makefile index dcf1171..dc44345 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 @@ -21,6 +25,19 @@ 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 @@ -28,6 +45,9 @@ optim: serve: http-server public +ghcup-serve: + cd public; php -S localhost:1234 + clean: rm -rf dist-newstyle public