forked from ReamLabs/ream
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
122 lines (95 loc) · 3.67 KB
/
Makefile
File metadata and controls
122 lines (95 loc) · 3.67 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
# Heavily inspired by Reth: https://github.com/paradigmxyz/reth/blob/4c39b98b621c53524c6533a9c7b52fc42c25abd6/Makefile
.DEFAULT_GOAL := help
BIN_DIR = "dist/bin"
# Cargo features for builds.
FEATURES ?=
# Cargo profile for builds.
PROFILE ?= release
# Extra flags for Cargo.
CARGO_INSTALL_EXTRA_FLAGS ?=
CARGO_TARGET_DIR ?= target
##@ Help
.PHONY: help
help: # Display this help.
@awk 'BEGIN {FS = ":.*#"; printf "Usage:\n make \033[34m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?#/ { printf " \033[34m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) }' $(MAKEFILE_LIST)
##@ Build
.PHONY: build
build: # Build the Ream binary into `target` directory.
cargo build --bin ream --features "$(FEATURES)" --profile "$(PROFILE)"
.PHONY: build-debug
build-debug: # Build the Ream binary into `target/debug` directory
cargo build --bin ream --features "$(FEATURES)"
.PHONY: install
install: # Build and install the Ream binary under `~/.cargo/bin`.
cargo install --path bin/ream --force --locked \
--features "$(FEATURES)" \
--profile "$(PROFILE)" \
$(CARGO_INSTALL_EXTRA_FLAGS)
##@ Testing and Linting
.PHONY: test
test: # Run all tests.
cargo test --workspace -- --nocapture
.PHONY: fmt
fmt: # Run `rustfmt` on the entire workspace and enfore closure variables on `map_err` to be `err`
cargo +nightly fmt --all
@all_occurrences=$$(grep -RIn --include="*.rs" "\.map_err(|" . || true); \
violations=$$(echo "$$all_occurrences" | grep -Ev "\.map_err\(\|err\|" || true); \
if [ -n "$$violations" ]; then \
echo "Invalid .map_err closure naming found:"; \
echo "$$violations"; \
echo; \
echo "Only this form is allowed:"; \
echo " .map_err(|err| ... )"; \
exit 1; \
fi
@# ---- Err(err) naming check ----
@all_errs=$$(grep -RIn --include="*.rs" "Err(" . || true); \
violations_err=$$(echo "$$all_errs" | grep -E "Err\(\s*[a-z][a-zA-Z0-9_]*\s*\)" | grep -Ev "Err\(err\)" || true); \
if [ -n "$$violations_err" ]; then \
echo "Invalid Err variable naming found:"; \
echo "$$violations_err"; \
echo; \
echo "Only this form is allowed:"; \
echo " Err(err)"; \
exit 1; \
fi
.PHONY: clippy
clippy: # Run `clippy` on the entire workspace.
cargo clippy --all --all-targets --features "$(FEATURES)" --no-deps -- --deny warnings
cargo clippy --package ream-bls --all-targets --features "supranational" --no-deps -- --deny warnings
.PHONY: sort
sort: # Run `cargo sort` on the entire workspace.
cargo sort --grouped --workspace
.PHONY: lint
lint: fmt clippy sort # Run all linters.
##@ Others
.PHONY: check
check: # Run `cargo check`.
cargo check --workspace --features "$(FEATURES)"
.PHONY: clean
clean: # Run `cargo clean`.
cargo clean
.PHONY: update-book-cli
update-book-cli: build-debug # Update book cli documentation.
@echo "Updating book cli doc..."
@./book/cli/update.sh $(CARGO_TARGET_DIR)/debug/ream
.PHONY: clean-deps
clean-deps: # Run `cargo udeps` except `ef-tests` directory.
cargo +nightly udeps --workspace --tests --all-targets --release --exclude ef-tests
.PHONY: pr
pr: lint update-book-cli clean-deps test # Run all checks for a PR.
build-%:
cross build --bin ream --target $* --features "$(FEATURES)" --profile "$(PROFILE)"
.PHONY: docker-build-push
docker-build-push:
$(MAKE) build-x86_64-unknown-linux-gnu
mkdir -p $(BIN_DIR)/amd64
cp $(CARGO_TARGET_DIR)/x86_64-unknown-linux-gnu/$(PROFILE)/ream $(BIN_DIR)/amd64/ream
$(MAKE) build-aarch64-unknown-linux-gnu
mkdir -p $(BIN_DIR)/arm64
cp $(CARGO_TARGET_DIR)/aarch64-unknown-linux-gnu/$(PROFILE)/ream $(BIN_DIR)/arm64/ream
docker buildx build --file ./Dockerfile.cross . \
--platform linux/amd64,linux/arm64 \
--tag ghcr.io/reamlabs/ream:latest \
--provenance=false \
--push