-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
379 lines (305 loc) · 11.7 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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
.PHONY: FORCE
SHELL = bash
NAME = devhub
# External WASM dependencies
MERE_MEMORY_WASM = .devhub/zomes/@spartan-hc/mere_memory.wasm
MERE_MEMORY_API_WASM = .devhub/zomes/@spartan-hc/mere_memory_csr.wasm
COOP_CONTENT_WASM = .devhub/zomes/@spartan-hc/coop_content.wasm
COOP_CONTENT_CSR_WASM = .devhub/zomes/@spartan-hc/coop_content_csr.wasm
# External DNA dependencies
PORTAL_VERSION = 0.17.0
PORTAL_DNA = dnas/portal.dna
# hApp
DEVHUB_HAPP = happ/$(NAME).happ
# DNAs
ZOMEHUB_DNA = dnas/zomehub.dna
DNAHUB_DNA = dnas/dnahub.dna
APPHUB_DNA = dnas/apphub.dna
# Integrity Zomes
ZOMEHUB_WASM = zomes/zomehub.wasm
DNAHUB_WASM = zomes/dnahub.wasm
APPHUB_WASM = zomes/apphub.wasm
# Coordinator WASMs
ZOMEHUB_CSR_WASM = zomes/zomehub_csr.wasm
DNAHUB_CSR_WASM = zomes/dnahub_csr.wasm
APPHUB_CSR_WASM = zomes/apphub_csr.wasm
TARGET = release
TARGET_DIR = target/wasm32-unknown-unknown/release
COMMON_SOURCE_FILES = Makefile zomes/Cargo.toml
INT_SOURCE_FILES = $(COMMON_SOURCE_FILES) \
dnas/%/types/Cargo.toml dnas/%/types/src/*.rs \
zomes/%/Cargo.toml zomes/%/src/*.rs \
zomes/%/src/**
CSR_SOURCE_FILES = $(COMMON_SOURCE_FILES) $(INT_SOURCE_FILES) \
zomes/%_csr/Cargo.toml zomes/%_csr/src/*.rs \
dnas/%/sdk/Cargo.toml dnas/%/sdk/src/*.rs \
devhub_sdk/Cargo.toml devhub_sdk/src/*.rs
#
# Project
#
clean:
rm -rf \
tests/node_modules \
.cargo target \
$(DEVHUB_HAPP) \
$(ZOMEHUB_DNA) $(DNAHUB_DNA) $(APPHUB_DNA) \
$(ZOMEHUB_WASM) $(ZOMEHUB_CSR_WASM) \
$(DNAHUB_WASM) $(DNAHUB_CSR_WASM) \
$(APPHUB_WASM) $(APPHUB_CSR_WASM) \
$(MERE_MEMORY_WASM) $(MERE_MEMORY_API_WASM) \
$(COOP_CONTENT_WASM) $(COOP_CONTENT_CSR_WASM)
rebuild: clean build
build: $(DEVHUB_HAPP)
$(DEVHUB_HAPP): $(ZOMEHUB_DNA) $(DNAHUB_DNA) $(APPHUB_DNA) $(PORTAL_DNA) happ/happ.yaml
hc app pack -o $@ ./happ/
$(ZOMEHUB_DNA): $(ZOMEHUB_WASM) $(ZOMEHUB_CSR_WASM) \
$(MERE_MEMORY_WASM) $(MERE_MEMORY_API_WASM) \
$(COOP_CONTENT_WASM) $(COOP_CONTENT_CSR_WASM)
$(DNAHUB_DNA): $(DNAHUB_WASM) $(DNAHUB_CSR_WASM)
$(APPHUB_DNA): $(APPHUB_WASM) $(APPHUB_CSR_WASM)
dnas/%.dna: dnas/%/dna.yaml
@echo "Packaging '$*': $@"
@hc dna pack -o $@ dnas/$*
$(MERE_MEMORY_WASM):
$(MERE_MEMORY_API_WASM):
$(COOP_CONTENT_WASM):
$(COOP_CONTENT_CSR_WASM):
.devhub/zomes/%.wasm:
@if [[ -e "$@" ]]; then \
touch $@; \
else \
echo -e "\x1b[32;2mInstall WASM dependency '$*' using devhub (https://github.com/holochain/devhub-cli)\x1b[0m"; \
exit 1; \
fi
zomes/%.wasm: $(TARGET_DIR)/%.wasm
@echo -e "\x1b[38;2mCopying WASM ($<) to 'zomes' directory: $@\x1b[0m"; \
cp $< $@
$(TARGET_DIR)/%.wasm: $(INT_SOURCE_FILES)
rm -f zomes/$*.wasm
@echo -e "\x1b[37mBuilding zome '$*' -> $@\x1b[0m";
RUST_BACKTRACE=1 cargo build --release \
--target wasm32-unknown-unknown \
--package $*
@touch $@ # Cargo must have a cache somewhere because it doesn't update the file time
$(TARGET_DIR)/%_csr.wasm: $(CSR_SOURCE_FILES)
rm -f zomes/$*_csr.wasm
@echo -e "\x1b[37mBuilding zome '$*_csr' -> $@\x1b[0m";
RUST_BACKTRACE=1 cargo build --release \
--target wasm32-unknown-unknown \
--package $*_csr
@touch $@ # Cargo must have a cache somewhere because it doesn't update the file time
$(PORTAL_DNA):
wget -O $@ "https://github.com/holochain/portal-dna/releases/download/v$(PORTAL_VERSION)/portal.dna" || rm -f $(PORTAL_DNA)
reset-mere-memory:
rm -f zomes/mere_memory*.wasm
make $(MERE_MEMORY_WASM) $(MERE_MEMORY_API_WASM)
reset-portal:
rm -f dnas/portal.dna
make $(PORTAL_DNA)
PRE_MM_VERSION = mere_memory_types = "0.97.0"
NEW_MM_VERSION = mere_memory_types = "0.98.0"
PRE_CRUD_VERSION = hc_crud_caps = "0.17"
NEW_CRUD_VERSION = hc_crud_caps = "0.18"
PRE_HDIE_VERSION = whi_hdi_extensions = "0.12"
NEW_HDIE_VERSION = whi_hdi_extensions = "0.13"
PRE_HDKE_VERSION = whi_hdk_extensions = "0.12"
NEW_HDKE_VERSION = whi_hdk_extensions = "0.13"
PRE_PSDK_VERSION = hc_portal_sdk = "0.8"
NEW_PSDK_VERSION = hc_portal_sdk = "0.9"
PRE_HIT_VERSION = holochain_integrity_types = "=0.4.0-dev.12"
NEW_HIT_VERSION = holochain_integrity_types = "=0.4.0-dev.15"
PRE_HZT_VERSION = holochain_zome_types = { version = "=0.4.0-dev.14"
NEW_HZT_VERSION = holochain_zome_types = { version = "=0.4.0-dev.18"
GG_REPLACE_LOCATIONS = ':(exclude)*.lock' Cargo.toml devhub_sdk/Cargo.toml dnas/*/types/Cargo.toml dnas/*/sdk/Cargo.toml zomes/*/Cargo.toml
update-mere-memory-version:
git grep -l '$(PRE_MM_VERSION)' -- $(GG_REPLACE_LOCATIONS) | xargs sed -i 's|$(PRE_MM_VERSION)|$(NEW_MM_VERSION)|g'
update-crud-version:
git grep -l '$(PRE_CRUD_VERSION)' -- $(GG_REPLACE_LOCATIONS) | xargs sed -i 's|$(PRE_CRUD_VERSION)|$(NEW_CRUD_VERSION)|g'
update-hdk-extensions-version:
git grep -l '$(PRE_HDKE_VERSION)' -- $(GG_REPLACE_LOCATIONS) | xargs sed -i 's|$(PRE_HDKE_VERSION)|$(NEW_HDKE_VERSION)|g'
update-hdi-extensions-version:
git grep -l '$(PRE_HDIE_VERSION)' -- $(GG_REPLACE_LOCATIONS) | xargs sed -i 's|$(PRE_HDIE_VERSION)|$(NEW_HDIE_VERSION)|g'
update-portal-sdk-version: reset-portal
git grep -l '$(PRE_PSDK_VERSION)' -- $(GG_REPLACE_LOCATIONS) | xargs sed -i 's|$(PRE_PSDK_VERSION)|$(NEW_PSDK_VERSION)|g'
update-integrity-types-version:
git grep -l '$(PRE_HIT_VERSION)' -- $(GG_REPLACE_LOCATIONS) | xargs sed -i 's|$(PRE_HIT_VERSION)|$(NEW_HIT_VERSION)|g'
update-zome-types-version:
git grep -l '$(PRE_HZT_VERSION)' -- $(GG_REPLACE_LOCATIONS) | xargs sed -i 's|$(PRE_HZT_VERSION)|$(NEW_HZT_VERSION)|g'
update-edition:
git grep -l '$(PRE_EDITION)' -- $(GG_REPLACE_LOCATIONS) | xargs sed -i 's/$(PRE_EDITION)/$(NEW_EDITION)/g'
npm-reinstall-local:
cd tests; npm uninstall $(NPM_PACKAGE); npm i --save $(LOCAL_PATH)
npm-reinstall-public:
cd tests; npm uninstall $(NPM_PACKAGE); npm i --save $(NPM_PACKAGE)
npm-reinstall-%-zomelets-local:
cd dnas/$*/zomelets; npm uninstall $(NPM_PACKAGE); npm i --save $(LOCAL_PATH)
npm-reinstall-%-zomelets-public:
cd dnas/$*/zomelets; npm uninstall $(NPM_PACKAGE); npm i --save $(NPM_PACKAGE)
npm-use-app-interface-client-public:
npm-use-app-interface-client-local:
npm-use-app-interface-client-%:
NPM_PACKAGE=@spartan-hc/app-interface-client LOCAL_PATH=../../app-interface-client-js make npm-reinstall-$*
npm-use-backdrop-public:
npm-use-backdrop-local:
npm-use-backdrop-%:
NPM_PACKAGE=@spartan-hc/holochain-backdrop LOCAL_PATH=../../node-backdrop make npm-reinstall-$*
npm-use-bundles-public:
npm-use-bundles-local:
npm-use-bundles-%:
NPM_PACKAGE=@spartan-hc/bundles LOCAL_PATH=../../bundles-js make npm-reinstall-$*
NPM_PACKAGE=@spartan-hc/bundles LOCAL_PATH=../../../../bundles-js make npm-reinstall-zomehub-zomelets-$*
NPM_PACKAGE=@spartan-hc/bundles LOCAL_PATH=../../../../bundles-js make npm-reinstall-dnahub-zomelets-$*
NPM_PACKAGE=@spartan-hc/bundles LOCAL_PATH=../../../../bundles-js make npm-reinstall-apphub-zomelets-$*
#
# Testing
#
TEST_UI = tests/test.zip
TEST_HAPP = tests/test.happ
TEST_WEBHAPP = tests/test.webhapp
$(TEST_UI):
dd if=/dev/zero of=$@ bs=1M count=1
$(TEST_HAPP): $(ZOMEHUB_DNA)
@echo "Packaging: $@"
@hc app pack -o $@ tests/test_happ/
$(TEST_WEBHAPP): $(TEST_HAPP) $(TEST_UI)
@echo "Packaging: $@"
@hc web-app pack -o $@ tests/test_webhapp/
%/package-lock.json: %/package.json
touch $@
%/node_modules: %/package-lock.json
cd $*; npm install
touch $@
test-setup: tests/node_modules \
dnas/zomehub/zomelets/node_modules \
dnas/dnahub/zomelets/node_modules \
dnas/apphub/zomelets/node_modules
test:
make test-unit
make test-integration
# Unit tests
CRATE_DEBUG_LEVELS = normal info debug trace
test-crate:
@if [[ "$(CRATE_DEBUG_LEVELS)" == *"$(DEBUG_LEVEL)"* ]]; then \
RUST_BACKTRACE=1 cargo test -- --nocapture --show-output; \
else \
cargo test --quiet --tests; \
fi
test-unit:
make test-crate
# Integration tests
DEBUG_LEVEL ?= warn
TEST_ENV_VARS = LOG_LEVEL=$(DEBUG_LEVEL)
MOCHA_OPTS = -n enable-source-maps -t 10000
test-integration:
make test-zomehub
make test-dnahub
make test-apphub
make test-real-uploads
make test-webapp-upload
test-zomehub: test-setup $(ZOMEHUB_DNA)
cd tests; $(TEST_ENV_VARS) npx mocha $(MOCHA_OPTS) ./integration/test_zomehub.js
test-dnahub: test-setup $(ZOMEHUB_DNA) $(DNAHUB_DNA)
cd tests; $(TEST_ENV_VARS) npx mocha $(MOCHA_OPTS) ./integration/test_dnahub.js
test-apphub: test-setup $(ZOMEHUB_DNA) $(DNAHUB_DNA) $(APPHUB_DNA)
cd tests; $(TEST_ENV_VARS) npx mocha $(MOCHA_OPTS) ./integration/test_apphub.js
test-webapp-upload: test-setup $(TEST_WEBHAPP) $(DEVHUB_HAPP)
cd tests; $(TEST_ENV_VARS) npx mocha $(MOCHA_OPTS) ./integration/test_webapp_upload.js
test-integration-zomehub-group-management: test-setup $(ZOMEHUB_DNA)
cd tests; $(TEST_ENV_VARS) npx mocha $(MOCHA_OPTS) ./integration/test_zomehub_group_management.js
# Real-input tests
test-real-uploads:
make test-real-zome-upload
make test-real-dna-upload
make test-real-app-upload
test-real-zome-upload: test-setup $(ZOMEHUB_DNA)
cd tests; $(TEST_ENV_VARS) npx mocha $(MOCHA_OPTS) ./integration/test_real_zome_upload.js
test-real-dna-upload: test-setup $(ZOMEHUB_DNA) $(DNAHUB_DNA)
cd tests; $(TEST_ENV_VARS) npx mocha $(MOCHA_OPTS) ./integration/test_real_dna_upload.js
test-real-app-upload: test-setup $(DEVHUB_HAPP)
cd tests; $(TEST_ENV_VARS) npx mocha $(MOCHA_OPTS) ./integration/test_real_app_upload.js
#
# Repository
#
clean-remove-chaff:
@find . -name '*~' -exec rm {} \;
clean-files: clean-remove-chaff
git clean -nd
clean-files-force: clean-remove-chaff
git clean -fd
clean-files-all: clean-remove-chaff
git clean -ndx
clean-files-all-force: clean-remove-chaff
git clean -fdx
#
# DevHub SDK package
#
.cargo/credentials:
cp ~/$@ $@
fix-rust-compile-issue: # Force rebuild to fix rust issue (typically after dry-run)
touch devhub_sdk/src/lib.rs
touch dnas/*/types/src/lib.rs
touch zomes/*/src/lib.rs
preview-sdk-crate: test .cargo/credentials
cd devhub_sdk; cargo publish --dry-run --allow-dirty
make fix-rust-compile-issue
publish-sdk-crate: test .cargo/credentials
cd devhub_sdk; cargo publish
#
# Previewing DNA Packages
#
preview-%-packages: preview-%-types-crate \
preview-%-sdk-crate \
preview-%-zomelets-package
@echo -e "\x1b[37mFinished previewing packages for '$*'\x1b[0m";
preview-zomehub-packages:
preview-dnahub-packages:
preview-apphub-packages:
#
# Publishing Types Packages
#
preview-%-types-crate: test-unit test-% .cargo/credentials
cd dnas/$*; make preview-types-crate
publish-%-types-crate: test-unit test-% .cargo/credentials
cd dnas/$*; make publish-types-crate
preview-zomehub-types-crate:
publish-zomehub-types-crate:
preview-dnahub-types-crate:
publish-dnahub-types-crate:
preview-apphub-types-crate:
publish-apphub-types-crate:
#
# Publishing SDK Packages
#
preview-%-sdk-crate: test-unit test-% .cargo/credentials
cd dnas/$*; make preview-sdk-crate
publish-%-sdk-crate: test-unit test-% .cargo/credentials
cd dnas/$*; make publish-sdk-crate
preview-zomehub-sdk-crate:
publish-zomehub-sdk-crate:
preview-dnahub-sdk-crate:
publish-dnahub-sdk-crate:
preview-apphub-sdk-crate:
publish-apphub-sdk-crate:
#
# Publishing Zomelets Packages
#
prepare-%-zomelets-package: zomelets/node_modules
cd dnas/$*; make prepare-zomelets-package
preview-%-zomelets-package: clean-files test-unit test-%
cd dnas/$*; make preview-zomelets-package
create-%-zomelets-package: clean-files test-unit test-%
cd dnas/$*; make create-zomelets-package
publish-%-zomelets-package: clean-files test-unit test-%
cd dnas/$*; make publish-zomelets-package
prepare-zomehub-zomelets-package:
preview-zomehub-zomelets-package:
create-zomehub-zomelets-package:
publish-zomehub-zomelets-package:
prepare-dnahub-zomelets-package:
preview-dnahub-zomelets-package:
create-dnahub-zomelets-package:
publish-dnahub-zomelets-package:
prepare-apphub-zomelets-package:
preview-apphub-zomelets-package:
create-apphub-zomelets-package:
publish-apphub-zomelets-package: