forked from ninegua/reversi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
92 lines (66 loc) · 2.72 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
PROVIDER ?= local
MODE ?= install
PROJECT=reversi
MO_SRC:=src/$(PROJECT)/main.mo src/$(PROJECT)/game.mo
JS_SRC:=src/$(PROJECT)_assets/public/index.js src/$(PROJECT)_assets/public/style.css src/$(PROJECT)_assets/public/logo.png
JS_CFG:=package-lock.json webpack.config.js
DFX_CFG:=dfx.json
OBJ_DIR:=.dfx/$(PROVIDER)/canisters
CANISTER_IDS:=.dfx/$(PROVIDER)/canister_ids.json
CANISTER_TARGET:=$(OBJ_DIR)/$(PROJECT)/$(PROJECT).wasm
ASSETS_TARGET:=$(OBJ_DIR)/$(PROJECT)_assets/$(PROJECT)_assets.wasm
JS_TARGET:=$(OBJ_DIR)/$(PROJECT)_assets/assets/index.js
help:
@echo 'USAGE: make [PROVIDER=...] [install|reinstall|upgrade|clean|canister|assets]'
@echo
@echo 'Build & install instructions:'
@echo
@echo ' install|reinstall|upgrade -- Build and install canisters with different mode.'
@echo ' clean -- Remove build products.'
@echo ' canister -- Only build the main canister'
@echo ' assets -- Build both the main and assets canisters.'
@echo
@echo 'The PROVIDER variable is optional. It corresponds to "networks" configuration in'
@echo 'the dfx.json file. The default is "local".'
.PHONY: help
canister: $(CANISTER_TARGET)
assets: $(ASSETS_TARGET)
.PHONY: reinstall install install-canister install-assets
install-canister: $(CANISTER_IDS) $(CANISTER_TARGET) $(DFX_CFG)
dfx canister --network $(PROVIDER) install --mode $(MODE) $(PROJECT)
install-assets: $(JS_TARGET) $(ASSETS_TARGET) $(DFX_CFG)
dfx canister --network $(PROVIDER) install --mode $(MODE) $(PROJECT)_assets
install: install-assets install-canister
reinstall:
$(MAKE) MODE=reinstall install
.PHONY: upgrade upgrade-canister upgrade-assets
upgrade:
$(MAKE) MODE=upgrade install
upgrade-canister:
$(MAKE) MODE=upgrade install-canister
upgrade-assets:
$(MAKE) MODE=upgrade install-assets
.PHONY: clean clean-npm clean-state clean-all
clean:
rm -rf .dfx/$(PROVIDER)
clean-npm:
rm -rf node_modules package-lock.json
clean-state:
rm -rf .dfx/state
cleanall: clean clean-state clean-npm
######################
node_modules package-lock.json : package.json
npm install
$(CANISTER_IDS): $(DFX_CFG)
dfx canister --network $(PROVIDER) create --all
$(CANISTER_TARGET): $(CANISTER_IDS) $(MO_SRC) $(DFX_CFG)
dfx build --network $(PROVIDER)
$(ASSETS_TARGET) $(JS_TARGET) : $(CANISTER_IDS) $(MO_SRC) $(JS_SRC) $(JS_CFG) $(DFX_CFG) node_modules
dfx build --network $(PROVIDER)
sodium-install:
npm install > /dev/null 2>&1
dfx canister --network sodium create reversi
dfx canister --network sodium create reversi_assets
dfx build --network sodium --all
dfx canister --network sodium install --all --mode reinstall
@echo Please visit https://$$(dfx canister --network sodium id reversi_assets).ic0.app to play the reversi game!