Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
63 lines (52 loc) · 1.72 KB
/
Copy pathMakefile
File metadata and controls
63 lines (52 loc) · 1.72 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
.PHONY: help test build spec fmt lint clean optimize check all
# Default target
default: help
# Help target - lists all available targets
help:
@echo "Available targets:"
@echo " help - Show this help message"
@echo " all - Run all checks (fmt, lint, test, build)"
@echo " test - Run test suite"
@echo " build - Build contract WASM"
@echo " spec - Export the contract spec (JSON and XDR)"
@echo " optimize - Build and optimize contract WASM"
@echo " fmt - Format code with rustfmt"
@echo " lint - Run clippy lints"
@echo " check - Run fmt, lint, and test"
@echo " clean - Clean build artifacts"
test:
cargo test --workspace
build:
stellar contract build
spec: build
scripts/export-spec.sh
optimize: build
@WASM="target/wasm32v1-none/release/stellar_tickets_ticketing.wasm"; \
if [ ! -f "$$WASM" ]; then \
WASM="target/wasm32-unknown-unknown/release/stellar_tickets_ticketing.wasm"; \
fi; \
if [ ! -f "$$WASM" ]; then \
echo "Error: Built WASM file not found"; exit 1; \
fi; \
echo "==> Optimizing contract WASM..."; \
stellar contract optimize --wasm "$$WASM"; \
OPT_WASM="$${WASM%.wasm}.optimized.wasm"; \
if [ -f "$$OPT_WASM" ]; then \
FINAL_WASM="$$OPT_WASM"; \
else \
FINAL_WASM="$$WASM"; \
fi; \
WASM_HASH=$$(sha256sum "$$FINAL_WASM" | awk '{print $$1}'); \
echo "=================================================="; \
echo "Contract build & optimization successful!"; \
echo "WASM File: $$FINAL_WASM"; \
echo "WASM Hash: $$WASM_HASH"; \
echo "=================================================="
fmt:
cargo fmt --all
lint:
cargo clippy --all-targets -- -D warnings -W clippy::pedantic
check: fmt lint test
clean:
cargo clean
all: check build