-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathMakefile
137 lines (89 loc) · 5.41 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
.DEFAULT_GOAL := help
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
# -- variables --------------------------------------------------------------------------------------
WARNINGS=RUSTDOCFLAGS="-D warnings"
DEBUG_ASSERTIONS=RUSTFLAGS="-C debug-assertions"
ALL_FEATURES_BUT_ASYNC=--features concurrent,testing
# Enable file generation in the `src` directory.
# This is used in the build scripts of miden-lib, miden-proving-service and miden-proving-service-client.
BUILD_GENERATED_FILES_IN_SRC=BUILD_GENERATED_FILES_IN_SRC=1
# Enable backtraces for tests where we return an anyhow::Result. If enabled, anyhow::Error will
# then contain a `Backtrace` and print it when a test returns an error.
BACKTRACE=RUST_BACKTRACE=1
# -- linting --------------------------------------------------------------------------------------
.PHONY: clippy
clippy: ## Runs Clippy with configs
cargo clippy --workspace --all-targets $(ALL_FEATURES_BUT_ASYNC) -- -D warnings
.PHONY: clippy-no-std
clippy-no-std: ## Runs Clippy with configs
cargo clippy --no-default-features --target wasm32-unknown-unknown --workspace --lib --features tx-prover --exclude miden-proving-service -- -D warnings
.PHONY: fix
fix: ## Runs Fix with configs
cargo fix --workspace --allow-staged --allow-dirty --all-targets $(ALL_FEATURES_BUT_ASYNC)
.PHONY: format
format: ## Runs Format using nightly toolchain
cargo +nightly fmt --all
.PHONY: format-check
format-check: ## Runs Format using nightly toolchain but only in check mode
cargo +nightly fmt --all --check
.PHONY: lint
lint: ## Runs all linting tasks at once (Clippy, fixing, formatting)
@$(BUILD_GENERATED_FILES_IN_SRC) $(MAKE) format
@$(BUILD_GENERATED_FILES_IN_SRC) $(MAKE) fix
@$(BUILD_GENERATED_FILES_IN_SRC) $(MAKE) clippy
@$(BUILD_GENERATED_FILES_IN_SRC) $(MAKE) clippy-no-std
# --- docs ----------------------------------------------------------------------------------------
.PHONY: doc
doc: ## Generates & checks documentation
$(WARNINGS) cargo doc $(ALL_FEATURES_BUT_ASYNC) --keep-going --release
.PHONY: doc-serve
doc-serve: ## Serves documentation site
./scripts/serve-doc-site.sh
# --- testing -------------------------------------------------------------------------------------
.PHONY: test-build
test-build: ## Build the test binary
$(BUILD_GENERATED_FILES_IN_SRC) $(DEBUG_ASSERTIONS) cargo nextest run --cargo-profile test-release --features concurrent,testing --no-run
.PHONY: test-default
test-default: ## Run default tests excluding `prove`
$(DEBUG_ASSERTIONS) $(BACKTRACE) cargo nextest run --profile default --cargo-profile test-release --features concurrent,testing --filter-expr "not test(prove)"
.PHONY: test-dev
test-dev: ## Run default tests excluding slow tests (prove and ID anchor block tests) in debug mode intended to be run locally
$(DEBUG_ASSERTIONS) $(BACKTRACE) cargo nextest run --profile default --features concurrent,testing --filter-expr "not test(prove) & not test(create_accounts_with_non_zero_anchor_block)"
.PHONY: test-docs
test-docs: ## Run documentation tests
$(WARNINGS) $(DEBUG_ASSERTIONS) cargo test --doc $(ALL_FEATURES_BUT_ASYNC)
.PHONY: test-prove
test-prove: ## Run `prove` tests (tests which use the Miden prover)
$(DEBUG_ASSERTIONS) $(BACKTRACE) cargo nextest run --profile prove --cargo-profile test-release --features concurrent,testing --filter-expr "test(prove)"
.PHONY: test
test: test-default test-prove ## Run all tests
# --- checking ------------------------------------------------------------------------------------
.PHONY: check
check: ## Check all targets and features for errors without code generation
$(BUILD_GENERATED_FILES_IN_SRC) cargo check --all-targets $(ALL_FEATURES_BUT_ASYNC)
.PHONY: check-no-std
check-no-std: ## Check the no-std target without any features for errors without code generation
$(BUILD_GENERATED_FILES_IN_SRC) cargo check --no-default-features --target wasm32-unknown-unknown --workspace --lib
# --- building ------------------------------------------------------------------------------------
.PHONY: build
build: ## By default we should build in release mode
$(BUILD_GENERATED_FILES_IN_SRC) cargo build --release
.PHONY: build-no-std
build-no-std: ## Build without the standard library
$(BUILD_GENERATED_FILES_IN_SRC) cargo build --no-default-features --target wasm32-unknown-unknown --workspace --lib --features tx-prover --exclude miden-proving-service
.PHONY: build-no-std-testing
build-no-std-testing: ## Build without the standard library. Includes the `testing` feature
$(BUILD_GENERATED_FILES_IN_SRC) cargo build --no-default-features --target wasm32-unknown-unknown --workspace --exclude miden-bench-tx --features testing,tx-prover --exclude miden-proving-service
.PHONY: build-async
build-async: ## Build with the `async` feature enabled (only libraries)
$(BUILD_GENERATED_FILES_IN_SRC) cargo build --lib --release --features async
# --- benchmarking --------------------------------------------------------------------------------
.PHONY: bench-tx
bench-tx: ## Run transaction benchmarks
cargo run --bin bench-tx
# --- installing ----------------------------------------------------------------------------------
.PHONY: install-proving-service
install-proving-service: ## Install proving service's CLI
$(BUILD_GENERATED_FILES_IN_SRC) cargo install --path bin/proving-service --bin miden-proving-service --locked --features concurrent