forked from holochain/happ-build-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
182 lines (147 loc) · 5.77 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#
# Test and build Holochain Project
#
# This Makefile is primarily instructional; you can simply enter the Nix environment for
# holochain-rust development (supplied by holonix;) via `nix-shell` and run
# `make test` directly, or build a target directly, eg. `nix-build -A {dna-name}
#
#SHELL = bash
#DNANAME = hello-world
#DNA = $(DNANAME).dna
#HAPP = $(DNANAME).happ
#WASM = target/wasm32-unknown-unknown/release/$(DNANAME).wasm
.PHONY: all
all:
@echo "You can run:"
@echo "- make build"
@echo "- make sandbox"
.PHONY: build build-cargo dna-pack app-pack
build: build-cargo dna-pack app-pack
build-cargo:
@CARGO_TARGET_DIR=target cargo build --release --target wasm32-unknown-unknown
dna-pack:
@hc dna pack workdir/dna
app-pack:
@hc app pack workdir/happ
.PHONY: sandbox
sandbox: build run-sandbox
run-sandbox:
@hc sandbox generate workdir/happ --run=8888
# # External targets; Uses a nix-shell environment to obtain Holochain runtimes, run tests, etc.
# .PHONY: all FORCE
# all: nix-test
# # nix-test, nix-install, ...
# nix-%:
# nix-shell --pure --run "make $*"
# # Internal targets; require a Nix environment in order to be deterministic.
# # - Uses the version of `hc` and `holochain` on the system PATH.
# # - Normally called from within a Nix environment, eg. run `nix-shell`
# .PHONY: rebuild install build build-cargo build-dna
# rebuild: clean build
# install: build
# build: build-cargo build-dna
# build: $(DNA)
# # Package the DNA from the built target release WASM
# $(DNA): $(WASM) FORCE
# @echo "Packaging DNA:"
# @hc dna pack . -o $(DNA)
# @hc app pack . -o $(HAPP)
# @ls -l $@
# # Recompile the target release WASM
# $(WASM): FORCE
# @echo "Building DNA WASM:"
# @RUST_BACKTRACE=1 CARGO_TARGET_DIR=target cargo build \
# --release --target wasm32-unknown-unknown
# @echo "Optimizing wasms:"
# @wasm-opt -Oz $(WASM) --output $(WASM)
# @wasm-opt -Oz $(WASM2) --output $(WASM2)
# .PHONY: test test-all test-unit test-e2e test-dna test-dna-debug test-stress test-sim2h test-node
# test-all: test
# test: test-unit test-e2e # test-stress # re-enable when Stress tests end reliably
# test-unit:
# RUST_BACKTRACE=1 cargo test \
# -- --nocapture
# test-dna: $(DNA) FORCE
# @echo "Starting Scenario tests in $$(pwd)..."; \
# cd tests && ( [ -d node_modules ] || npm install ) && npm test
# test-dna-debug:
# @echo "Starting Scenario tests in $$(pwd)..."; \
# cd tests && ( [ -d node_modules ] || npm install ) && npm run test:standard
# test-behavior:
# @echo "Starting Scenario tests in $$(pwd)..."; \
# cd tests && ( [ -d node_modules ] || npm install ) && npm run test:behavior
# test-e2e: test-dna
# #############################
# # █▀█ █▀▀ █░░ █▀▀ ▄▀█ █▀ █▀▀
# # █▀▄ ██▄ █▄▄ ██▄ █▀█ ▄█ ██▄
# #############################
# # How to make a release?
# # make HC_REV="HC_REV" release-0.0.0-alpha0
# update-release-%:
# cd zomes/chat/ && sed -i -e 's/^version = .*/version = "$*"/' Cargo.toml
# update-hc:
# make HC_REV=$(HC_REV) update-hc-sha
# make HC_REV=$(HC_REV) update-nix-by-failure
# make HC_REV=$(HC_REV) update-hc-cargoSha
# update-hc-sha:
# @if [ $(HC_REV) ]; then\
# echo "⚙️ Updating elemental-chat using holochain rev: $(HC_REV)";\
# echo "✔ Updating hdk and holo_hash rev in Cargo.toml...";\
# sed -i -e 's/^hdk = .*/hdk = {git ="https:\/\/github.com\/holochain\/holochain", rev = "$(HC_REV)", package = "hdk"}/' Cargo.toml;\
# sed -i -e 's/^holo_hash = .*/holo_hash = {git ="https:\/\/github.com\/holochain\/holochain", rev = "$(HC_REV)", package = "holo_hash"}/' Cargo.toml;\
# echo "✔ Replacing rev...";\
# sed -i -e 's/^ rev = .*/ rev = "$(HC_REV)";/' default.nix;\
# echo "✔ Replacing sha256...";\
# sed -i -e 's/^ sha256 = .*/ sha256 = "$(shell nix-prefetch-url --unpack "https://github.com/holochain/holochain/archive/$(HC_REV).tar.gz")";/' default.nix;\
# else \
# echo "No holochain rev provided"; \
# fi
# update-nix-by-failure:
# @if [ $(HC_REV) ]; then\
# echo "➳ Corrupting cargoSha256...";\
# sed -i -e 's/^ cargoSha256 = .*/ cargoSha256 = "000000000000000000000000000000000000000000000000000a";/' default.nix;\
# echo "➳ Getting cargoSha256... This can take a while...";\
# nix-shell &>nix.log || echo "This was ment to fail :)...";\
# else \
# echo "No holochain rev provided"; \
# fi
# update-hc-cargoSha:
# @if [ $(HC_REV) ]; then\
# echo "➳ Waiting for 5s..."$*;\
# sleep 5;\
# echo "✔ Replacing cargoSha256...";\
# $(eval CARGOSHA256=$(shell sh -c "grep "got" ./nix.log" | awk '{print $$2}'))\
# sed -i -e 's/^ cargoSha256 = .*/ cargoSha256 = "$(CARGOSHA256)";/' default.nix;\
# else \
# echo "No holochain rev provided"; \
# fi
# github-release-%:
# echo "Creating github-release for version $*"
# cp elemental-chat.happ elemental-chat.$(shell echo $* | tr .- _).happ
# cp elemental-chat.dna elemental-chat.$(shell echo $* | tr .- _).dna
# sh ./gh-release.sh $* "holochain rev: $(HC_REV)"
# release-%:
# echo '⚙️ Editing necessary files required for update...'
# make update-release-$*
# make HC_REV=$(HC_REV) update-hc
# echo '⚙️ Building dnas and happ...'
# rm -rf Cargo.lock
# make nix-build
# echo '⚙️ Running tests...'
# make nix-test-dna-debug
# echo '⚙️ Commit updates to current branch...'
# git checkout -b release-$*
# git add zomes/ Cargo.toml default.nix
# git commit -m v$*
# git push origin HEAD
# echo '⚙️ Making new release...'
# make HC_REV=$(HC_REV) github-release-$*
# echo '🚀 Successful release elemental-chat '$*
# # Generic targets; does not require a Nix environment
# .PHONY: clean
# clean:
# rm -rf \
# tests/node_modules \
# .cargo \
# target \
# $(DNA)