-
Notifications
You must be signed in to change notification settings - Fork 174
Expand file tree
/
Copy pathMakefile
More file actions
79 lines (66 loc) · 2.46 KB
/
Copy pathMakefile
File metadata and controls
79 lines (66 loc) · 2.46 KB
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
WASM_DIR := target/wasm32-unknown-unknown/release
BINDINGS_DIR := bindings
PYTHON ?= python3
SHA256 ?= sha256sum
DOCS_OUTPUT := docs/contract-api.md
.PHONY: build bindings all clean generate-api-docs check check-wasm-abi setup-githooks
.PHONY: build bindings all clean generate-api-docs check setup-githooks benchmark-compare
# macOS compatibility: check for shasum (pre-installed on macOS) and fall back to sha256sum.
ifeq ($(shell uname -s),Darwin)
SHA256 = shasum -a 256
endif
.PHONY: build bindings all clean generate-api-docs check setup-githooks
all: build bindings
build: generate-api-docs
cargo build --workspace --target wasm32-unknown-unknown --release
generate-api-docs:
$(PYTHON) scripts/generate_api_docs.py --output $(DOCS_OUTPUT)
# Compute SHA-256 hash of a WASM file and retrieve the current git commit.
# Stamps both into the binding's package.json under `contractHash` and
# `sourceCommit` so consumers can verify which build produced the bindings.
define stamp-binding
contract_hash=$$($(SHA256) "$(WASM_DIR)/$(1)" | cut -d' ' -f1); \
commit_hash=$$(git rev-parse HEAD 2>/dev/null || echo "unknown"); \
pkg="$(BINDINGS_DIR)/$(2)/package.json"; \
if [ -f "$$pkg" ]; then \
node -e " \
var p = require('./$$pkg'); \
p.contractHash = '$$contract_hash'; \
p.sourceCommit = '$$commit_hash'; \
require('fs').writeFileSync('$$pkg', JSON.stringify(p, null, 2) + '\n'); \
"; \
echo " >> Stamped $$pkg: hash=$${contract_hash::12}… commit=$${commit_hash::12}…"; \
fi
endef
bindings: build
stellar contract bindings typescript \
--wasm $(WASM_DIR)/hunty_core.wasm \
--output-dir $(BINDINGS_DIR)/hunty-core \
--overwrite
$(call stamp-binding,hunty_core.wasm,hunty-core)
stellar contract bindings typescript \
--wasm $(WASM_DIR)/reward_manager.wasm \
--output-dir $(BINDINGS_DIR)/reward-manager \
--overwrite
$(call stamp-binding,reward_manager.wasm,reward-manager)
stellar contract bindings typescript \
--wasm $(WASM_DIR)/nft_reward.wasm \
--output-dir $(BINDINGS_DIR)/nft-reward \
--overwrite
$(call stamp-binding,nft_reward.wasm,nft-reward)
check-wasm-abi:
$(PYTHON) scripts/check_wasm_abi.py
validate-config:
bash scripts/validate_placeholders.sh
check:
cargo fmt --all -- --check
cargo clippy --workspace -- -D warnings
cargo test --workspace --locked
$(MAKE) validate-config
$(MAKE) check-wasm-abi
benchmark-compare:
node scripts/ci/compare_gas_benchmarks.mjs
setup-githooks:
git config core.hooksPath .githooks
clean:
cargo clean