-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
53 lines (37 loc) · 1.62 KB
/
Makefile
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
SRC=src/index.js src/bare-agent.js src/index.html
NIX_SRC=default.nix ic-qr-scanner.nix node-env.nix node-packages.nix shell.nix
NPM_SRC=webpack.config.js src/simple.min.css
OTHER_SRC=src/manifest.json src/favicon.ico src/logo.png
ALL_SRC=$(SRC) $(NIX_SRC) $(NPM_SRC) $(OTHER_SRC)
all: fmt build
build: dist/main.bundle.js
dist/index.html dist/main.bundle.js &: $(SRC) $(NPM_SRC)
npm run-script build
fmt: $(SRC) webpack.config.js
prettier -w $(SRC) webpack.config.js
dist/app.o: dist/app.c
clang --target=wasm32 -c -O3 $^ -o $@
dist/app.wasm: dist/app.o
wasm-ld --no-entry --export-dynamic --allow-undefined $^ -o $@
dist/app.did:
touch $@
dist/app.c: dist/index.html $(OTHER_SRC)
echo -e "/,./release/index.html\n/test.html,./dist/index.html\n/$$(ls dist/*.bin|cut -d/ -f2),$$(ls ./dist/*.bin)\n/manifest.json,./src/manifest.json\n/logo.png,./src/logo.png\n/favicon.ico,./src/favicon.ico" | sh epic.sh > $@
install: dist/app.wasm dist/app.did
install -D dist/index.html ${out}/share/index.html
install -D dist/app.did ${out}/bin/ic-qr-scanner.did
install -D dist/app.wasm ${out}/bin/ic-qr-scanner.wasm
dist/canister_ids.json: canister_ids.json
cd dist && ln -s ../canister_ids.json .
result : $(ALL_SRC)
nix-build ic-qr-scanner.nix
dfx.json:
echo '{"canisters":{"app":{"type":"custom","candid":"result/bin/ic-qr-scanner.did","wasm":"result/bin/ic-qr-scanner.wasm","build":""}}}' > $@
release: result dfx.json
dfx deploy --network=ic
clean:
rm -rf dist result dfx.json .dfx
# This is used by github release workflow
nix-build:
cp `nix-build ic-qr-scanner.nix`/bin/* .
.PHONY: all fmt build release install clean nix-build