-
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathMakefile
More file actions
59 lines (44 loc) · 1.99 KB
/
Makefile
File metadata and controls
59 lines (44 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
.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
update:
wasm32-wasi-cabal update
repl: update
wasm32-wasi-cabal repl app -finteractive --repl-options='-fghci-browser -fghci-browser-port=8080'
watch:
ghciwatch --after-startup-ghci :main --after-reload-ghci :main --watch app --debounce 50ms --command 'wasm32-wasi-cabal repl app -finteractive --repl-options="-fghci-browser -fghci-browser-port=8080"'
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/
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
clean:
rm -rf dist-newstyle public
update-js:
cabal update --with-ghc=javascript-unknown-ghcjs-ghc --with-hc-pkg=javascript-unknown-ghcjs-ghc-pkg
build-js:
cabal build --with-ghc=javascript-unknown-ghcjs-ghc --with-hc-pkg=javascript-unknown-ghcjs-ghc-pkg
cp -v ./dist-newstyle/build/javascript-ghcjs/ghc-9.12.2/*/x/app/build/app/app.jsexe/all.js .
rm -rf public
cp -rv static public
bunx --bun swc ./all.js -o public/index.js
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