forked from tikv/rust-rocksdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
38 lines (30 loc) · 1.11 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
.PHONY: all format
# format rust code using the specified command for the specified file or directory.
# $(call do-format-with-cmd,cmd,file-or-dir)
define do-format-with-cmd
$1 --write-mode diff $2 | grep -E "Diff .*at line" > /dev/null && $1 --write-mode overwrite $2 || exit 0
endef
# format rust code in the specified file or directory
# a file of rust code follows the convention of having suffix '.rs'
# $(call format-code-in,file-or-dir)
define format-code-in
$(if $(filter %.rs, $1), \
$(call do-format-with-cmd, rustfmt, $1), \
cd $1 && $(call do-format-with-cmd, cargo fmt --))
endef
all: format build test
build:
@cargo build
test:
@export RUST_BACKTRACE=1 && cargo test -- --nocapture
format:
@$(call format-code-in, .)
@$(call format-code-in, tests/test.rs)
@$(call format-code-in, librocksdb_sys)
# User may not install clang-format-diff.py, ignore any error here.
@librocksdb_sys/crocksdb/format-diff.sh > /dev/null || true
clean:
@cargo clean
@cd librocksdb_sys && cargo clean
update-rocksdb:
@git subtree pull -P librocksdb_sys/rocksdb https://github.com/pingcap/rocksdb.git release --squash