-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
186 lines (150 loc) · 5.41 KB
/
Makefile
File metadata and controls
186 lines (150 loc) · 5.41 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
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
.PHONY: default
default: build
.git/hooks/pre-commit: .githooks/pre-commit
cp .githooks/pre-commit .git/hooks/pre-commit
.PHONY: githooks
githooks: .git/hooks/pre-commit
.PHONY: deps
deps: .lib/libbls.a .lib/libbandersnatch_vrfs.a .lib/libec.a .lib/libed25519_zebra_ffi.a .lib/libmsquic.a
.lib/libbls.a: $(wildcard Utils/Sources/bls/src/*)
./scripts/build-rust-libs.sh
.lib/libbandersnatch_vrfs.a: $(wildcard Utils/Sources/bandersnatch/src/*)
./scripts/build-rust-libs.sh
.lib/libec.a: $(wildcard Utils/Sources/erasure-coding/src/*)
./scripts/build-rust-libs.sh
.lib/libed25519_zebra_ffi.a: $(wildcard Utils/Sources/ed25519-zebra/src/*)
./scripts/build-rust-libs.sh
.lib/libmsquic.a:
./scripts/external-libs.sh
# Test packages
TEST_PACKAGES := Blockchain Boka Codec Database Fuzzing JAMTests Networking Node PolkaVM RPC Utils
TEST_FILTER ?=
.PHONY: test
test: githooks deps
@echo "=== Running tests ==="
@failed=""; \
for pkg in $(TEST_PACKAGES); do \
if [ -n "$$TEST_FILTER" ] && [ "$$pkg" != "$$TEST_FILTER" ]; then \
continue; \
fi; \
printf "Testing %-12s ...\n" "$$pkg"; \
if swift test --package-path "$$pkg"; then \
echo " ✓ PASS"; \
else \
echo " ✗ FAIL (exit code $$?)"; \
failed="$$failed $$pkg"; \
fi; \
done; \
echo ""; \
echo "=== Test Summary ==="; \
if [ -n "$$failed" ]; then \
echo "Failed packages:$$failed"; \
exit 1; \
else \
echo "All packages passed!"; \
fi
.PHONY: test-cargo
test-cargo:
cargo test --manifest-path Utils/Sources/bandersnatch/Cargo.toml
.PHONY: test-all
test-all: test test-cargo
.PHONY: test-coverage
test-coverage:
@for pkg in $(TEST_PACKAGES); do \
echo "Running coverage for $$pkg..."; \
swift test --enable-code-coverage --package-path "$$pkg"; \
done
.PHONY: build
build: githooks deps
./scripts/run.sh build
.PHONY: build-verbose
build-verbose: githooks
./scripts/run.sh build --verbose
.PHONY: resolve
resolve: githooks
./scripts/run.sh package resolve
.PHONY: clean
clean:
./scripts/run.sh package clean
.PHONY: clean-lib
clean-lib:
rm -f .lib/*.a
.PHONY: clean-all
clean-all: clean clean-lib
.PHONY: lint
lint: githooks
swiftlint lint --config .swiftlint.yml --strict
.PHONY: format
format: githooks
swiftformat .
.PHONY: format-cargo
format-cargo:
cargo fmt --all
.PHONY: format-all
format-all: format format-cargo
.PHONY: format-clang
format-clang:
find . \( -name "*.c" -o -name "helpers.h" \) -exec clang-format -i {} +
.PHONY: run
run: githooks
SWIFT_BACKTRACE=enable=yes swift run --package-path Boka Boka --validator
.PHONY: devnet
devnet:
./scripts/devnet.sh
# Determine build directory using SwiftPM
# This works cross-platform (Linux, macOS) for both x86_64 and arm64
BUILD_DIR := $(shell swift build --show-bin-path -c release 2>/dev/null)
SANDBOX_PATH := $(BUILD_DIR)/boka-sandbox
# Benchmark targets
# Build sandbox in release mode and use it for benchmarks
BENCHMARK_ARGS ?=
.PHONY: benchmark
benchmark: githooks deps build-sandbox-release
cd JAMTests && BOKA_SANDBOX_PATH=$(SANDBOX_PATH) swift package benchmark
.PHONY: benchmark-list
benchmark-list: githooks deps build-sandbox-release
cd JAMTests && BOKA_SANDBOX_PATH=$(SANDBOX_PATH) swift package benchmark list
.PHONY: benchmark-filter
benchmark-filter: githooks deps build-sandbox-release
@echo "Usage: make benchmark-filter FILTER=<pattern>"
@echo "Example: make benchmark-filter FILTER=trie"
@if [ -z "$(FILTER)" ]; then \
echo "Error: FILTER parameter is required"; \
exit 1; \
fi
cd JAMTests && BOKA_SANDBOX_PATH=$(SANDBOX_PATH) swift package benchmark --filter $(FILTER)
.PHONY: benchmark-baseline
benchmark-baseline: githooks deps build-sandbox-release
@echo "Usage: make benchmark-baseline BASELINE=<name>"
@echo "Example: make benchmark-baseline BASELINE=master"
@if [ -z "$(BASELINE)" ]; then \
echo "Error: BASELINE parameter is required"; \
exit 1; \
fi
cd JAMTests && BOKA_SANDBOX_PATH=$(SANDBOX_PATH) swift package --allow-writing-to-directory .benchmarkBaselines/ benchmark baseline update $(BASELINE) $(BENCHMARK_ARGS)
.PHONY: benchmark-compare
benchmark-compare: githooks deps build-sandbox-release
@echo "Usage: make benchmark-compare BASELINE1=<name1> BASELINE2=<name2>"
@echo "Example: make benchmark-compare BASELINE1=master BASELINE2=pull_request"
@if [ -z "$(BASELINE1)" ] || [ -z "$(BASELINE2)" ]; then \
echo "Error: BASELINE1 and BASELINE2 parameters are required"; \
exit 1; \
fi
cd JAMTests && BOKA_SANDBOX_PATH=$(SANDBOX_PATH) swift package benchmark baseline compare $(BASELINE1) $(BASELINE2)
.PHONY: benchmark-check
benchmark-check: githooks deps build-sandbox-release
@echo "Usage: make benchmark-check BASELINE1=<name1> BASELINE2=<name2>"
@echo "Example: make benchmark-check BASELINE1=master BASELINE2=pull_request"
@if [ -z "$(BASELINE1)" ] || [ -z "$(BASELINE2)" ]; then \
echo "Error: BASELINE1 and BASELINE2 parameters are required"; \
exit 1; \
fi
cd JAMTests && BOKA_SANDBOX_PATH=$(SANDBOX_PATH) swift package benchmark baseline check $(BASELINE1) $(BASELINE2) --thresholds .benchmarkBaselines/thresholds.json
.PHONY: benchmark-all
benchmark-all: githooks deps build-sandbox-release
cd JAMTests && BOKA_SANDBOX_PATH=$(SANDBOX_PATH) swift package --allow-writing-to-directory .benchmarkBaselines/ benchmark baseline update all
# Helper target to build sandbox in release mode
.PHONY: build-sandbox-release
build-sandbox-release:
@echo "Building boka-sandbox in release mode..."
cd PolkaVM && swift build -c release --product boka-sandbox