-
Notifications
You must be signed in to change notification settings - Fork 120
/
Makefile
94 lines (68 loc) · 2.42 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
VENV := precommit_venv
HOOKS := .git/hooks/pre-commit
# PRE-COMMIT HOOKS
$(VENV): .requirements-precommit.txt
virtualenv -p python3 $(VENV)
$(VENV)/bin/pip install -r .requirements-precommit.txt
.PHONY: env
env: $(VENV)
.PHONY: clean-env
clean-env:
rm -rf $(VENV)
## Cargo
CARGO_BIN ?= `which cargo`
TARGET_PATH ?= `pwd`/target/release
BIN_VERSION ?= 0.1.0
BIN_NAME ?= voik
BIN_PATH ?= $(TARGET_PATH)/$(BIN_NAME)
## Testing
FUNZZY_BIN ?= `which funzzy`
PWD ?= `pwd`
HOME ?= `echo $HOME`
$(HOOKS): $(VENV) .pre-commit-config.yaml
$(VENV)/bin/pre-commit install -f --install-hooks
@$(CARGO_BIN) fmt --help > /dev/null || rustup component add rustfmt
@$(CARGO_BIN) clippy --help > /dev/null || rustup component add clippy
@$(CARGO_BIN) readme --help > /dev/null || cargo install cargo-readme
.PHONY: install-hooks
install-hooks: $(HOOKS)
.PHONY: clean-hooks
clean-hooks:
rm -rf $(HOOKS)
.PHONY: build
build:
@$(CARGO_BIN) build
.PHONY: build_all
build_all:
@$(CARGO_BIN) build --all-features
.PHONY: test
test_all: ## Tests all features
@$(CARGO_BIN) test --all-features
test: ## Tests all features
RUST_LOG=info BITCOINS_REPO=$(shell pwd) $(CARGO_BIN) test --all-targets -- --skip coinnect_tests --skip coinbase_tests --nocapture
.PHONY: coverage
coverage: ## Tests all features
@$(CARGO_BIN) tarpaulin -v
.PHONY: test_watcher ## Starts funzzy, test watcher, to run the tests on every change
test_watcher:
@$(FUNZZY_BIN)
.PHONY: bench
bench:
@$(CARGO_BIN) bench
.PHONY: profile
profile:
@$(CARGO_BIN) flamegraph --dev --bin=trader --features flame_it
.PHONY: lint
lint:
@$(CARGO_BIN) clippy --all-targets --all-features -Z unstable-options -- -Dclippy::all -Dunused_imports
.PHONY: lintfix
lintfix:
@$(CARGO_BIN) clippy --fix --all-targets --all-features -Z unstable-options -- -Dclippy::all -Dunused_imports
.PHONY: clean-lint
clean-lint:
find . -type f -name *.rs.bk -delete
## alias rust-musl-builder-nightly='docker run --cpus=$(nproc) --rm -it --user rust $MUSL_FLAGS -v "$HOME/.cargo/git":/home/rust/.cargo/git -v "$(pwd)/cargo-registry":/home/rust/.cargo/registry -v "$(pwd)/cargo-target":/home/rust/src/target -v "$(pwd)":/home/rust/src ekidd/rust-musl-builder:nightly-2020-06-17'
release:
$(rust-musl-builder-nightly) cargo build --release --target=x86_64-unknown-linux-gnu
build_test:
@$(CARGO_BIN) test --message-format=json-diagnostic-rendered-ansi --color=always --no-run --lib $(TEST_NAME) --manifest-path $(MANIFEST_PATH)