forked from lambdaclass/cairo_native
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
145 lines (108 loc) · 4.94 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
138
139
140
141
142
143
144
145
.PHONY: usage build book build-dev build-native coverage check test bench bench-ci doc doc-open install clean install-scarb install-scarb-macos build-alexandria runtime test-ci proptest-ci
#
# Environment detection.
#
UNAME := $(shell uname)
CAIRO_2_VERSION=2.6.3
check-llvm:
ifndef MLIR_SYS_180_PREFIX
$(error Could not find a suitable LLVM 18 toolchain (mlir), please set MLIR_SYS_180_PREFIX env pointing to the LLVM 18 dir)
endif
ifndef TABLEGEN_180_PREFIX
$(error Could not find a suitable LLVM 18 toolchain (tablegen), please set TABLEGEN_180_PREFIX env pointing to the LLVM 18 dir)
endif
@echo "LLVM is correctly set at $(MLIR_SYS_180_PREFIX)."
needs-cairo2:
ifeq ($(wildcard ./cairo2/.),)
$(error You are missing the Starknet Cairo 1 compiler, please run 'make deps' to install the necessary dependencies.)
endif
./scripts/check-corelib-version.sh $(CAIRO_2_VERSION)
usage:
@echo "Usage:"
@echo " deps: Installs the necesarry dependencies."
@echo " build: Builds the cairo-native library and binaries."
@echo " build-native: Builds cairo-native with the target-cpu=native rust flag."
@echo " build-dev: Builds cairo-native under a development-optimized profile."
@echo " check: Checks format and lints."
@echo " test: Runs all tests."
@echo " proptest: Runs property tests."
@echo " coverage: Runs all tests and computes test coverage."
@echo " doc: Builds documentation."
@echo " doc-open: Builds and opens documentation in browser."
@echo " bench: Runs the hyperfine benchmark script."
@echo " bench-ci: Runs the criterion benchmarks for CI."
@echo " install: Invokes cargo to install cairo-native."
@echo " clean: Cleans the built artifacts."
build: check-llvm runtime
cargo build --release --all-features
build-native: check-llvm runtime
RUSTFLAGS="-C target-cpu=native" cargo build --release --all-features
build-dev: check-llvm
cargo build --profile optimized-dev --all-features
check: check-llvm
cargo fmt --all -- --check
cargo clippy --all-targets --all-features -- -D warnings
test: check-llvm needs-cairo2 build-alexandria runtime-ci
cargo test --profile ci --all-features
test-cairo: check-llvm needs-cairo2 build-alexandria runtime-ci
cargo r --profile ci --bin cairo-native-test -- cairo-tests/
proptest: check-llvm needs-cairo2 runtime-ci
cargo test --profile ci --all-features proptest
test-ci: check-llvm needs-cairo2 build-alexandria runtime-ci
cargo test --profile ci --all-features
proptest-ci: check-llvm needs-cairo2 runtime-ci
cargo test --profile ci --all-features proptest
coverage: check-llvm needs-cairo2 build-alexandria runtime-ci
cargo llvm-cov --verbose --profile ci --all-features --workspace --lcov --output-path lcov.info
cargo llvm-cov --verbose --profile ci --all-features --lcov --output-path lcov-test.info run --bin cairo-native-test -- cairo-tests
doc: check-llvm
cargo doc --all-features --no-deps --workspace
doc-open: check-llvm
cargo doc --all-features --no-deps --workspace --open
bench: build needs-cairo2 runtime
./scripts/bench-hyperfine.sh
bench-ci: check-llvm needs-cairo2 runtime
cargo criterion --all-features
install: check-llvm
RUSTFLAGS="-C target-cpu=native" cargo install --all-features --locked --path .
clean:
cargo clean
deps:
ifeq ($(UNAME), Linux)
deps: build-cairo-2-compiler install-scarb
endif
ifeq ($(UNAME), Darwin)
deps: deps-macos
endif
-rm -rf corelib
-ln -s cairo2/corelib corelib
deps-macos: build-cairo-2-compiler-macos install-scarb-macos
-brew install llvm@18 --quiet
@echo "You can execute the env-macos.sh script to setup the needed env variables."
cairo-repo-2-dir = cairo2
cairo-repo-2-dir-macos = cairo2-macos
build-cairo-2-compiler-macos: | $(cairo-repo-2-dir-macos)
$(cairo-repo-2-dir-macos): cairo-${CAIRO_2_VERSION}-macos.tar
$(MAKE) decompress-cairo SOURCE=$< TARGET=cairo2/
build-cairo-2-compiler: | $(cairo-repo-2-dir)
$(cairo-repo-2-dir): cairo-${CAIRO_2_VERSION}.tar
$(MAKE) decompress-cairo SOURCE=$< TARGET=cairo2/
decompress-cairo:
rm -rf $(TARGET) \
&& tar -xzvf $(SOURCE) \
&& mv cairo/ $(TARGET)
cairo-%-macos.tar:
curl -L -o "$@" "https://github.com/starkware-libs/cairo/releases/download/v$*/release-aarch64-apple-darwin.tar"
cairo-%.tar:
curl -L -o "$@" "https://github.com/starkware-libs/cairo/releases/download/v$*/release-x86_64-unknown-linux-musl.tar.gz"
SCARB_VERSION = 2.6.3
install-scarb:
curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh| sh -s -- --no-modify-path --version $(SCARB_VERSION)
install-scarb-macos:
curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh| sh -s -- --version $(SCARB_VERSION)
build-alexandria:
cd tests/alexandria; scarb build
runtime:
cargo b --release --all-features -p cairo-native-runtime && cp target/release/libcairo_native_runtime.a .
runtime-ci:
cargo b --profile ci --all-features -p cairo-native-runtime && cp target/ci/libcairo_native_runtime.a .