-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMakefile
More file actions
171 lines (127 loc) · 4.49 KB
/
Makefile
File metadata and controls
171 lines (127 loc) · 4.49 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
.PHONY: all build test clean fmt lint run help
# Build configuration
CARGO = cargo
BINARY_NAME = ev-reth
TARGET_DIR = target
# Default target
all: build
## help: Display this help message
help:
@echo "Available targets:"
@awk 'BEGIN {FS = ":.*##"; printf "\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
##@ Building
## build: Build the ev-reth binary in release mode
build:
$(CARGO) build --release --bin $(BINARY_NAME)
## build-dev: Build the ev-reth binary in debug mode
build-dev:
$(CARGO) build --bin $(BINARY_NAME)
## build-maxperf: Build ev-reth with the most aggressive optimizations
build-maxperf:
RUSTFLAGS="-C target-cpu=native" $(CARGO) build --profile maxperf --features jemalloc,asm-keccak --bin $(BINARY_NAME)
##@ Testing
## test: Run all tests
test:
$(CARGO) test --workspace
## test-verbose: Run all tests with verbose output
test-verbose:
$(CARGO) test --workspace -- --nocapture
## test-unit: Run unit tests only
test-unit:
$(CARGO) test --lib
## test-integration: Run integration tests only
test-integration:
$(CARGO) test -p ev-tests
##@ Development
## run: Run the ev-reth node with default settings
run: build-dev
./$(TARGET_DIR)/debug/$(BINARY_NAME) node
## run-dev: Run with debug logs enabled
run-dev: build-dev
RUST_LOG=debug ./$(TARGET_DIR)/debug/$(BINARY_NAME) node
## fmt: Format code using rustfmt (nightly)
fmt:
$(CARGO) +nightly fmt --all
## fmt-check: Check if code is formatted correctly (nightly)
fmt-check:
$(CARGO) +nightly fmt --all --check
## lint: Run clippy linter
lint:
$(CARGO) clippy --all-targets --all-features -- -D warnings
## check: Run cargo check
check:
$(CARGO) check --workspace
##@ Maintenance
## clean: Clean build artifacts
clean:
$(CARGO) clean
## update: Update dependencies
update:
$(CARGO) update
## audit: Audit dependencies for security vulnerabilities
audit:
$(CARGO) audit
##@ Documentation
## doc: Build documentation
doc:
$(CARGO) doc --no-deps --open
## doc-all: Build documentation including dependencies
doc-all:
$(CARGO) doc --open
##@ Workspace Management
## build-all: Build all workspace members
build-all:
$(CARGO) build --workspace --release
## test-node: Test only the node crate
test-node:
$(CARGO) test -p ev-node
## test-evolve: Test only the evolve crate
test-evolve:
$(CARGO) test -p evolve-ev-reth
## test-common: Test only the common crate
test-common:
$(CARGO) test -p ev-common
##@ Docker
# Docker configuration
GIT_TAG ?= $(shell git describe --tags --abbrev=0 || echo "latest")
GIT_COMMIT ?= $(shell git rev-parse --short HEAD || echo "unknown")
DOCKER_TAG ?= $(GIT_COMMIT)
BIN_DIR = dist/bin
DOCKER_IMAGE_NAME ?= ghcr.io/$(shell git config --get remote.origin.url | sed 's/.*github.com[:/]\(.*\)\.git/\1/' | cut -d'/' -f1)/ev-reth
PROFILE ?= release
# List of features to use when building
FEATURES ?= jemalloc
## docker-build: Build Docker image (tagged with git commit hash by default)
docker-build:
@echo "Building Docker image: $(DOCKER_IMAGE_NAME):$(DOCKER_TAG)"
docker build -t $(DOCKER_IMAGE_NAME):$(DOCKER_TAG) .
## docker-build-push: Build and push a cross-arch Docker image
docker-build-push:
$(call docker_build_push,$(DOCKER_TAG),$(DOCKER_TAG))
## docker-build-push-latest: Build and push a cross-arch Docker image tagged with latest
docker-build-push-latest:
$(call docker_build_push,$(GIT_TAG),latest)
# Cross-compilation targets
build-x86_64-unknown-linux-gnu:
cross build --bin $(BINARY_NAME) --target x86_64-unknown-linux-gnu --features "$(FEATURES)" --profile "$(PROFILE)"
build-aarch64-unknown-linux-gnu:
JEMALLOC_SYS_WITH_LG_PAGE=16 cross build --bin $(BINARY_NAME) --target aarch64-unknown-linux-gnu --features "$(FEATURES)" --profile "$(PROFILE)"
# Create a cross-arch Docker image with the given tags and push it
define docker_build_push
$(MAKE) build-x86_64-unknown-linux-gnu
mkdir -p $(BIN_DIR)/linux/amd64
cp $(TARGET_DIR)/x86_64-unknown-linux-gnu/$(PROFILE)/$(BINARY_NAME) $(BIN_DIR)/linux/amd64/$(BINARY_NAME)
$(MAKE) build-aarch64-unknown-linux-gnu
mkdir -p $(BIN_DIR)/linux/arm64
cp $(TARGET_DIR)/aarch64-unknown-linux-gnu/$(PROFILE)/$(BINARY_NAME) $(BIN_DIR)/linux/arm64/$(BINARY_NAME)
docker buildx build --file ./Dockerfile.cross . \
--platform linux/amd64,linux/arm64 \
--tag $(DOCKER_IMAGE_NAME):$(1) \
--tag $(DOCKER_IMAGE_NAME):$(2) \
--provenance=false \
--sbom=false \
--push
endef
##@ CI Helpers
## check-all: Run all checks (fmt, lint, test)
check-all: fmt-check lint test