-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
56 lines (47 loc) · 1.45 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
# Define variables
SRC_DIR := src/backend
DID_TEMP_DIR := did_temp
OUT_DIR := src/frontend/src/ic-agent/declarations
MOC := $(shell dfx cache show)/moc
MOPS_SOURCES := $(shell mops sources)
DIDC := didc
build:
dfx build main --identity anonymous
process_did_files:
@mkdir -p $(DID_TEMP_DIR)
@for dir in .dfx/local/canisters/*; do \
if [ -d "$$dir" ]; then \
base=$$(basename $$dir); \
did_file="$$dir/$$base.did"; \
if [ -f "$$did_file" ]; then \
echo "Processing $$did_file..."; \
cp "$$did_file" "$(DID_TEMP_DIR)/"; \
fi; \
fi; \
done
compile_did_files:
@for did in $(DID_TEMP_DIR)/*.did; do \
if [ -f "$$did" ]; then \
js="$$(echo "$$did" | sed 's|^$(DID_TEMP_DIR)|$(OUT_DIR)|' | sed 's|\.did$$|.js|')"; \
./didc bind -t js "$$did" > "$$js"; \
ts="$$(echo "$$js" | sed 's|\.js$$|.d.ts|')"; \
./didc bind -t ts "$$did" > "$$ts"; \
fi; \
done
rm -rf $(DID_TEMP_DIR)
$(DIDC):
@echo "Downloading didc..."
@curl -L -o $(DIDC) https://github.com/dfinity/candid/releases/latest/download/didc-linux64
@chmod +x $(DIDC)
@echo "didc downloaded and made executable."
# Cleanup
clean:
rm -rf $(OUT_DIR)
@rm -f $(DIDC)
reinstall:
dfx canister install main --identity anonymous --mode reinstall -y
reinstall_prod:
dfx canister install main --ic --mode reinstall -y
generate: $(DIDC) build process_did_files compile_did_files
# Phony targets
.PHONY: generate clean build process_did_files compile_did_files reinstall reinstall_prod