-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathMakefile
More file actions
294 lines (226 loc) · 12.6 KB
/
Makefile
File metadata and controls
294 lines (226 loc) · 12.6 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
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
.DEFAULT_GOAL := help
.PHONY: help
help: ## Show description of all commands
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
# --- Variables -----------------------------------------------------------------------------------
# The build target can be set via BUILD_TARGET to cross-compile.
# Used when targeting a specific environment (used to produce artifact binaries)
# in the CI.
ifneq ($(BUILD_TARGET),)
TARGET_FLAG = --target $(BUILD_TARGET)
endif
FEATURES_CLIENT=--features "std"
WARNINGS=RUSTDOCFLAGS="-D warnings"
PROVER_DIR="crates/testing/prover"
WEB_CLIENT_DIR=crates/web-client
RUST_CLIENT_DIR=crates/rust-client
EXCLUDE_WASM_PACKAGES=--exclude miden-client-web --exclude miden-idxdb-store
TEST_MIDEN_NOTE_TRANSPORT_URL?=http://127.0.0.1:57292
# --- Linting -------------------------------------------------------------------------------------
.PHONY: clippy
clippy: ## Run Clippy with configs
cargo +nightly clippy --workspace $(EXCLUDE_WASM_PACKAGES) --features "testing std" --all-targets -- -D warnings
.PHONY: clippy-wasm
clippy-wasm: rust-client-ts-build ## Run Clippy for the wasm packages (web client and idxdb store)
cargo +nightly clippy --package miden-client-web --target wasm32-unknown-unknown --all-targets -- -D warnings
cargo +nightly clippy --package miden-idxdb-store --target wasm32-unknown-unknown --all-targets -- -D warnings
.PHONY: fix
fix: ## Run Fix with configs
cargo +nightly fix --workspace $(EXCLUDE_WASM_PACKAGES) --features "testing std" --all-targets --allow-staged --allow-dirty
.PHONY: fix-wasm
fix-wasm: ## Run Fix for the wasm packages (web client and idxdb store)
cargo +nightly fix --package miden-client-web --target wasm32-unknown-unknown --allow-staged --allow-dirty --all-targets
cargo +nightly fix --package miden-idxdb-store --target wasm32-unknown-unknown --allow-staged --allow-dirty --all-targets
.PHONY: format
format: ## Run format using nightly toolchain
cargo +nightly fmt --all
yarn --silent prettier . --write --log-level silent
yarn --silent eslint . --fix
.PHONY: format-check
format-check: ## Run format using nightly toolchain but only in check mode
cargo +nightly fmt --all --check
yarn --silent prettier . --check
yarn --silent eslint .
.PHONY: lint
lint: fix fix-wasm format toml clippy clippy-wasm typos-check rust-client-ts-lint web-client-check-methods ## Run all linting tasks at once (clippy, fixing, formatting, typos)
.PHONY: toml
toml: ## Runs Format for all TOML files
taplo fmt
.PHONY: toml-check
toml-check: ## Runs Format for all TOML files but only in check mode
taplo fmt --check --verbose
.PHONY: typos-check
typos-check: ## Run typos to check for spelling mistakes
@typos --config ./.typos.toml
.PHONY: rust-client-ts-lint
rust-client-ts-lint:
cd crates/idxdb-store/src && yarn && yarn lint
.PHONY: web-client-check-methods
web-client-check-methods: ## Check that all WASM methods are classified in the web client proxy
cd $(WEB_CLIENT_DIR) && yarn check:method-classification
.PHONY: react-sdk-lint
react-sdk-lint: ## Run lint for the React SDK
cd packages/react-sdk && yarn && yarn lint
# --- Documentation -------------------------------------------------------------------------------
.PHONY: doc
doc: ## Generate & check rust documentation. Ensure you have the nightly toolchain installed.
@cd crates/rust-client && \
RUSTDOCFLAGS="-D warnings --cfg docsrs" cargo +nightly doc --lib --no-deps --all-features --keep-going --release
doc-open: ## Generate & open rust documentation in browser. Ensure you have the nightly toolchain installed.
@cd crates/rust-client && \
RUSTDOCFLAGS="-D warnings --cfg docsrs" cargo +nightly doc --lib --no-deps --all-features --keep-going --release --open
.PHONY: serve-docs
serve-docs: ## Serves the docs
cd docs/external && npm run start:dev
.PHONY: typedoc
typedoc: rust-client-ts-build ## Generate web client package documentation.
@cd crates/web-client && \
npm run build-dev && \
yarn typedoc
# --- Testing -------------------------------------------------------------------------------------
.PHONY: test
test: ## Run tests
cargo nextest run --workspace $(EXCLUDE_WASM_PACKAGES) --exclude testing-remote-prover --release --lib $(FEATURES_CLIENT)
.PHONY: test-docs
test-docs: ## Run documentation tests
cargo test --doc $(FEATURES_CLIENT)
.PHONY: test-react-sdk
test-react-sdk: ## Run React SDK unit tests
cd packages/react-sdk && yarn && yarn test:unit
# --- Integration testing -------------------------------------------------------------------------
.PHONY: start-node
start-node: ## Start the testing node server
RUST_LOG=info cargo run --release --package node-builder --locked
.PHONY: start-node-background
start-node-background: ## Start the testing node server in background
./scripts/start-binary-bg.sh node-builder
.PHONY: stop-node
stop-node: ## Stop the testing node server
-pkill -f "node-builder"
sleep 1
.PHONY: start-note-transport-background
start-note-transport-background: ## Start the note transport service in background
./scripts/start-note-transport-bg.sh
.PHONY: stop-note-transport
stop-note-transport: ## Stop the note transport service
./scripts/stop-note-transport.sh
.PHONY: start-note-transport
start-note-transport:
./scripts/start-note-transport.sh
.PHONY: integration-test
integration-test: ## Run integration tests
cargo nextest run --workspace $(EXCLUDE_WASM_PACKAGES) --exclude testing-remote-prover --release --test=integration
.PHONY: integration-test-web-client
SHARD_PARAMETER ?= ""
integration-test-web-client: ## Run integration tests for the web client (with a chromium browser)
cd ./crates/web-client && yarn run test:clean -- --project=chromium $(SHARD_PARAMETER)
.PHONY: integration-test-web-client-webkit
integration-test-web-client-webkit: ## Run web client tests (webkit)
cd ./crates/web-client && yarn run test -- --project=webkit
.PHONY: test-web-client-nodejs
test-web-client-nodejs: ## Run web client tests on Node.js (mock chain, no browser needed)
cargo build -p miden-client-web --no-default-features --features nodejs,testing --release
cd ./crates/web-client && yarn install && SKIP_WEB_SERVER=1 npx playwright test --project=nodejs --workers=1
.PHONY: integration-test-remote-prover-web-client
integration-test-remote-prover-web-client: ## Run integration tests for the web client with remote prover
cd ./crates/web-client && yarn run test:remote_prover -- --project=chromium
.PHONY: integration-test-full
integration-test-full: ## Run the integration test binary with ignored tests included (requires note transport service)
TEST_MIDEN_NOTE_TRANSPORT_URL=$(TEST_MIDEN_NOTE_TRANSPORT_URL) cargo nextest run --workspace $(EXCLUDE_WASM_PACKAGES) --exclude testing-remote-prover --release --test=integration
cargo nextest run --workspace $(EXCLUDE_WASM_PACKAGES) --exclude testing-remote-prover --release --test=integration --run-ignored ignored-only -- import_genesis_accounts_can_be_used_for_transactions
.PHONY: test-dev
test-dev: ## Run tests with debug assertions enabled via test-dev profile
cargo nextest run --workspace $(EXCLUDE_WASM_PACKAGES) --exclude testing-remote-prover --cargo-profile test-dev --lib $(FEATURES_CLIENT)
.PHONY: integration-test-dev
integration-test-dev: ## Run integration tests with debug assertions enabled via test-dev profile
cargo nextest run --workspace $(EXCLUDE_WASM_PACKAGES) --exclude testing-remote-prover --cargo-profile test-dev --test=integration
.PHONY: integration-test-binary
integration-test-binary: ## Run the integration tests using the standalone binary (requires note transport service)
TEST_MIDEN_NOTE_TRANSPORT_URL=$(TEST_MIDEN_NOTE_TRANSPORT_URL) cargo run --package miden-client-integration-tests --release --locked
.PHONY: start-prover
start-prover: ## Start the remote prover
cd $(PROVER_DIR) && RUST_LOG=info cargo run --release --locked
.PHONY: start-prover-background
start-prover-background: ## Start the remote prover in background
cd $(PROVER_DIR) && ../../../scripts/start-binary-bg.sh testing-remote-prover
.PHONY: stop-prover
stop-prover: ## Stop prover process
-pkill -f "testing-remote-prover"
sleep 1
# --- Installing ----------------------------------------------------------------------------------
install: ## Install the CLI binary
cargo install --path bin/miden-cli --locked
install-bench: ## Install the benchmark binary
cargo install --path bin/miden-bench --locked
install-tests: ## Install the tests binary
cargo install --path bin/integration-tests --locked
# --- Building ------------------------------------------------------------------------------------
## Build the CLI binary. This is done separately in order to save time during
## artifact generation for releases.
build: ## Build the CLI binary, client library and tests binary in release mode
cargo build --workspace $(EXCLUDE_WASM_PACKAGES) $(TARGET_FLAG) --release --locked
build-wasm: rust-client-ts-build ## Build the wasm packages (web client and idxdb store)
cargo build --package miden-client-web --package miden-idxdb-store --target wasm32-unknown-unknown --locked
.PHONY: rust-client-ts-build
rust-client-ts-build:
cd crates/idxdb-store/src && yarn && yarn build
.PHONY: build-react-sdk
build-react-sdk: ## Build the React SDK package
cd crates/web-client && yarn && yarn build
cd packages/react-sdk && yarn && yarn build
# --- Check ---------------------------------------------------------------------------------------
.PHONY: check
check: ## Build the CLI binary and client library in release mode
cargo check --workspace $(EXCLUDE_WASM_PACKAGES) --exclude testing-remote-prover --release
.PHONY: check-wasm
check-wasm: ## Check the wasm packages (web client and idxdb store)
cargo check --package miden-client-web --target wasm32-unknown-unknown
cargo check --package miden-idxdb-store --target wasm32-unknown-unknown
## --- Setup --------------------------------------------------------------------------------------
.PHONY: check-tools
check-tools: ## Checks if development tools are installed
@echo "Checking development tools..."
@command -v mdbook >/dev/null 2>&1 && echo "[OK] mdbook is installed" || echo "[MISSING] mdbook (make install-tools)"
@command -v typos >/dev/null 2>&1 && echo "[OK] typos is installed" || echo "[MISSING] typos (make install-tools)"
@command -v cargo nextest >/dev/null 2>&1 && echo "[OK] cargo-nextest is installed" || echo "[MISSING] cargo-nextest(make install-tools)"
@command -v taplo >/dev/null 2>&1 && echo "[OK] taplo is installed" || echo "[MISSING] taplo (make install-tools)"
@command -v yarn >/dev/null 2>&1 && echo "[OK] yarn is installed" || echo "[MISSING] yarn (make install-tools)"
@command -v wasm-opt >/dev/null 2>&1 && echo "[OK] wasm-opt is installed" || echo "[MISSING] wasm-opt (brew install binaryen / apt-get install binaryen)"
.PHONY: install-tools
install-tools: ## Installs Rust + Node tools required by the Makefile
@echo "Installing development tools..."
@rustup show active-toolchain >/dev/null 2>&1 || (echo "Rust toolchain not detected. Install rustup + toolchain first." && exit 1)
@echo "Ensuring wasm32-unknown-unknown target is installed..."
@rustup target add wasm32-unknown-unknown >/dev/null
@RUST_TC=$$(rustup show active-toolchain | awk '{print $$1}'); \
echo "Ensuring required Rust components are installed for $$RUST_TC..."; \
rustup component add --toolchain $$RUST_TC clippy rust-src rustfmt >/dev/null
# Rust-related
cargo install mdbook --locked
cargo install [email protected] --locked
cargo install [email protected] --locked
cargo install taplo-cli --locked
# Binaryen (wasm-opt) – needed by web-client build
@command -v wasm-opt >/dev/null 2>&1 && echo "wasm-opt already installed" || { \
echo "Installing binaryen (wasm-opt)..."; \
if [ "$$(uname)" = "Darwin" ]; then \
brew install binaryen; \
else \
sudo apt-get update && sudo apt-get install -y binaryen; \
fi; \
}
# Web-related
command -v yarn >/dev/null 2>&1 || npm install -g yarn
yarn --cwd $(WEB_CLIENT_DIR) --silent # installs prettier, eslint, typedoc, etc.
yarn --cwd crates/idxdb-store/src --silent
yarn install --prefix docs/external --no-progress
yarn --silent
yarn
@echo "Development tools installation complete!"
## --- Debug --------------------------------------------------------------------------------------
.PHONY: build-web-client-debug
build-web-client-debug: # build the web-client with debug symbols for the WASM-generated rust code
cd crates/web-client && yarn build-dev
.PHONY: link-web-client-dep
link-web-client-dep: # links the local web-client for debugging JS applications.
cd crates/web-client && yarn link