@@ -14,6 +14,7 @@ Targets:
1414
1515 [ SETUP ]
1616
17+ - setup-cairo Setup Cairo 0 environment for building
1718 - setup-l2 Setup orchestrator with L2 layer
1819 - setup-l2-localstack Setup orchestrator with L2 layer and Localstack
1920 - setup-l3 Setup orchestrator with L3 layer
@@ -69,6 +70,11 @@ Targets:
6970 - clean-db Perform clean and remove local database
7071 - fclean Perform clean-db and remove local images
7172
73+ [ BUILDING ]
74+
75+ - build-madara Build Madara with Cairo 0 environment setup
76+ - build-orchestrator Build Orchestrator with Cairo 0 environment setup
77+
7278 [ CODE QUALITY ]
7379
7480 Runs various code quality checks including formatting and linting.
@@ -103,6 +109,8 @@ DOCKER_TAG := madara:latest
103109DOCKER_IMAGE := ghcr.io/madara-alliance/$(DOCKER_TAG )
104110DOCKER_GZ := image.tar.gz
105111ARTIFACTS := ./build-artifacts
112+ VENV := sequencer_venv
113+ VENV_ACTIVATE := . $(VENV ) /bin/activate
106114
107115# Configuration for E2E bridge tests
108116CARGO_TARGET_DIR ?= target
@@ -195,9 +203,48 @@ artifacts:
195203 @git submodule update --init --recursive
196204 ./scripts/artifacts.sh
197205
206+ .PHONY : setup-cairo
207+ setup-cairo :
208+ @echo -e " $( DIM) Setting up Cairo 0 environment...$( RESET) "
209+ @if [ ! -d " $( VENV) " ]; then \
210+ echo -e " $( INFO) Creating Python virtual environment...$( RESET) " ; \
211+ python3 -m venv $(VENV ) ; \
212+ else \
213+ echo -e " $( PASS) ✅ Virtual environment already exists$( RESET) " ; \
214+ fi
215+ @echo -e " $( INFO) Installing Cairo 0 dependencies...$( RESET) "
216+ @if [ ! -f sequencer_requirements.txt ]; then \
217+ CARGO_HOME=$$ {CARGO_HOME:-$$ HOME/.cargo}; \
218+ GIT_CHECKOUTS=$$(readlink -f "$$CARGO_HOME/git" 2>/dev/null || echo "$$CARGO_HOME/git" ) ; \
219+ SEQUENCER_REV=$$(grep -A 2 'name = "blockifier"' Cargo.lock | grep 'sequencer?rev=' | sed -E 's/.*rev=([a-f0-9]+ ) .* /\1 /' | cut -c1-7); \
220+ REQUIREMENTS_PATH=$$(find "$$GIT_CHECKOUTS/checkouts" -type f -path "*/sequencer*/$$SEQUENCER_REV*/scripts/requirements.txt" 2>/dev/null | head -n 1 ) ; \
221+ if [ -n " $$ REQUIREMENTS_PATH" ]; then \
222+ sed ' s/numpy==2.0.2/numpy<2.0/' " $$ REQUIREMENTS_PATH" > sequencer_requirements.txt; \
223+ echo -e " $( INFO) Found requirements.txt at: $$ REQUIREMENTS_PATH$( RESET) " ; \
224+ else \
225+ echo -e " $( WARN) ⚠️ WARNING: Could not find requirements.txt from sequencer checkout$( RESET) " ; \
226+ echo -e " $( INFO) Creating basic requirements with cairo-lang...$( RESET) " ; \
227+ echo " cairo-lang==0.14.0.1" > sequencer_requirements.txt; \
228+ echo " numpy<2.0" >> sequencer_requirements.txt; \
229+ fi ; \
230+ fi
231+ @$(VENV_ACTIVATE ) && pip install --upgrade pip > /dev/null 2>&1 && pip install -r sequencer_requirements.txt > /dev/null 2>&1
232+ @$(VENV_ACTIVATE ) && cairo-compile --version > /dev/null 2>&1 && echo -e " $( PASS) ✅ Cairo 0 environment ready (cairo-compile $$ ($( VENV_ACTIVATE) && cairo-compile --version 2>&1))$( RESET) " || (echo -e " $( WARN) ❌ Cairo setup failed$( RESET) " && exit 1)
233+
234+ .PHONY : build-madara
235+ build-madara :
236+ @echo -e " $( DIM) Building Madara with Cairo 0 environment...$( RESET) "
237+ @$(VENV_ACTIVATE ) && cargo build --manifest-path madara/Cargo.toml --bin madara --release
238+ @echo -e " $( PASS) ✅ Build complete!$( RESET) "
239+
240+ .PHONY : build-orchestrator
241+ build-orchestrator : setup-cairo
242+ @echo -e " $( DIM) Building Orchestrator with Cairo 0 environment...$( RESET) "
243+ @$(VENV_ACTIVATE ) && cargo build --bin orchestrator --release
244+ @echo -e " $( PASS) ✅ Build complete!$( RESET) "
198245
199246.PHONY : check
200- check :
247+ check : setup-cairo
201248 @echo -e " $( DIM) Running code quality checks...$( RESET) "
202249 @echo -e " $( INFO) Running prettier check...$( RESET) "
203250 @npm install
@@ -206,20 +253,23 @@ check:
206253 @cargo fmt -- --check
207254 @echo -e " $( INFO) Running taplo fmt check...$( RESET) "
208255 @taplo fmt --config=./taplo/taplo.toml --check
209- @echo -e " $( INFO ) Running cargo clippy workspace checks ...$( RESET ) "
256+ @echo " Running cargo clippy..."
210257 @cargo clippy --workspace --no-deps -- -D warnings
211- @echo -e " $( INFO) Running cargo clippy workspace tests...$( RESET) "
212258 @cargo clippy --workspace --tests --no-deps -- -D warnings
213- @echo -e " $( INFO) Running cargo clippy with testing features...$( RESET) "
214- @cargo clippy --workspace --exclude madara --features testing --no-deps -- -D warnings
215- @echo -e " $( INFO) Running cargo clippy with testing features and tests...$( RESET) "
216- @cargo clippy --workspace --exclude madara --features testing --tests --no-deps -- -D warnings
259+ @# TODO(mehul 14/11/2025, hotfix): This is a temporary fix to ensure that the madara is linted.
260+ @# Madara does not belong to the toplevel workspace, so we need to lint it separately.
261+ @# Remove this once we add madara back to toplevel workspace.
262+ @echo " Running cargo clippy for madara..."
263+ @cd madara && \
264+ cargo clippy --workspace --no-deps -- -D warnings && \
265+ cargo clippy --workspace --tests --no-deps -- -D warnings && \
266+ cd ..
217267 @echo -e " $( INFO) Running markdownlint check...$( RESET) "
218268 @npx markdownlint -c .markdownlint.json -q -p .markdownlintignore .
219269 @echo -e " $( PASS) All code quality checks passed!$( RESET) "
220270
221271.PHONY : fmt
222- fmt :
272+ fmt : setup-cairo
223273 @echo -e " $( DIM) Running code formatters...$( RESET) "
224274 @echo -e " $( INFO) Running taplo formatter...$( RESET) "
225275 @npm install
@@ -421,10 +471,10 @@ test: test-e2e test-orchestrator
421471 @echo -e " $( PASS) All tests completed!$( RESET) "
422472
423473.PHONY : pre-push
424- pre-push :
474+ pre-push : setup-cairo
425475 @echo -e " $( DIM) Running pre-push checks...$( RESET) "
426476 @echo -e " $( INFO) Running code quality checks...$( RESET) "
427- @$(MAKE ) --silent check
477+ @$(VENV_ACTIVATE ) && $( MAKE ) --silent check
428478 @echo -e " $( PASS) Pre-push checks completed successfully!$( RESET) "
429479
430480.PHONY : git-hook
0 commit comments