-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathMakefile
92 lines (79 loc) · 2.7 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
.PHONY: lint build clean test help format staticcheck pre-commit
GOPATH_DIR :=`go env GOPATH`
BINARY_DIR := bin
BINARY_NAME := cairo-vm
TEST := "."
default: help
help:
@echo "This makefile allows the following commands"
@echo " make build - compile the source code"
@echo " make clean - remove binary files"
@echo " make unit - run unit tests"
@echo " make integration - run integration tests"
@echo " make testall - run all tests"
@echo " make bench - benchmark all tests"
@echo " make help - show this help message"
build:
@echo "Building..."
@mkdir -p $(BINARY_DIR)
@go build -o $(BINARY_DIR)/$(BINARY_NAME) cmd/cli/main.go
@if [ $$? -eq 0 ]; then \
echo "Build completed succesfully!"; \
else \
echo "Build failed."; \
exit 1; \
fi
clean:
@echo "Cleaning up..."
@rm -rf $(BINARY_DIR)
unit:
@echo "Running unit tests..."
@go test ./pkg/...
integration:
@echo "Running integration tests..."
@$(MAKE) build
@if [ $$? -eq 0 ]; then \
if [ ! -d rust_vm_bin ]; then \
mkdir -p rust_vm_bin; \
fi; \
if [ ! -d rust_vm_bin/cairo ]; then \
mkdir -p rust_vm_bin/cairo-lang; \
fi; \
if [ ! -f ./rust_vm_bin/cairo-lang/cairo-compile ] || [ ! -f ./rust_vm_bin/cairo-lang/sierra-compile-json ] || [ ! -d rust_vm_bin/corelib ]; then \
cd rust_vm_bin; \
git clone --single-branch --branch feat/main-casm-json --depth=1 https://github.com/zmalatrax/cairo.git; \
mv cairo/corelib .; \
cd cairo/crates/bin && cargo build --release --bin cairo-compile --bin sierra-compile-json && cd ../../../; \
mv cairo/target/release/cairo-compile cairo/target/release/sierra-compile-json cairo-lang; \
rm -rf cairo; \
cd ../; \
fi; \
if [ ! -f ./rust_vm_bin/cairo-lang/cairo1-run ] || [ ! -f ./rust_vm_bin/cairo-vm-cli ]; then \
cd rust_vm_bin; \
git clone https://github.com/lambdaclass/cairo-vm.git; \
cd cairo-vm && cargo build --release --bin cairo-vm-cli --bin cairo1-run && cd ../; \
mv cairo-vm/target/release/cairo1-run cairo-lang;\
mv cairo-vm/target/release/cairo-vm-cli . ; \
rm -rf cairo-vm; \
cd ../; \
fi; \
go test ./integration_tests/... -v; \
else \
echo "Integration tests were not run"; \
exit 1; \
fi
testall:
@echo "Running all tests..."
@$(MAKE) build
@go test ./...
bench:
@echo "Running benchmarks..."
@go run scripts/benchmark.go --pkg=${PKG_NAME} --test=${TEST}
zerobench:
@echo "Running integration benchmarks..."
@go test integration_tests/cairozero_test.go -v -zerobench;
# Use the same version of the golangci-lint as in our CI linting config.
lint:
go install github.com/golangci/golangci-lint/cmd/[email protected]
golangci-lint run ./... -v
@echo "lint: all good!"