forked from nervosnetwork/ckb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
109 lines (82 loc) · 3.76 KB
/
Copy pathMakefile
File metadata and controls
109 lines (82 loc) · 3.76 KB
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
.DEFAULT_GOAL:=help
SHELL = /bin/sh
FLATC := flatc
CFBC := cfbc
VERBOSE := $(if ${CI},--verbose,)
##@ Testing
test: ## Run all tests.
cargo test ${VERBOSE} --all -- --nocapture
setup-ckb-test:
cp -f Cargo.lock test/Cargo.lock
rm -rf test/target && ln -snf ../target/ test/target
integration: setup-ckb-test ## Run integration tests in "test" dir.
cargo build ${VERBOSE}
cd test && cargo run ../target/debug/ckb
integration-release: setup-ckb-test ## Run integration tests in "test" dir with release build.
cargo build ${VERBOSE} --release
cd test && cargo run --release -- ../target/release/ckb
##@ Document
doc: ## Build the documentation for the local package.
cargo doc --all --no-deps
doc-deps: ## Build the documentation for the local package and all dependencies.
cargo doc --all
##@ Building
check: setup-ckb-test ## Runs all of the compiler's checks.
cargo check ${VERBOSE} --all
cd test && cargo check ${VERBOSE} --all
build: ## Build binary with release profile.
cargo build ${VERBOSE} --release
prod: ## Build binary for production release.
RUSTFLAGS="--cfg disable_faketime" cargo build ${VERBOSE} --release
prod-test: ## Build binary for testing production release.
RUSTFLAGS="--cfg disable_faketime" RUSTDOCFLAGS="--cfg disable_faketime" cargo test ${VERBOSE} --all -- --nocapture
docker: ## Build docker image with the bin built from "prod" then push it to Docker Hub as nervos/ckb:latest .
docker build -f docker/hub/Dockerfile -t nervos/ckb:latest .
##@ Code Quality
fmt: setup-ckb-test ## Check Rust source code format to keep to the same style.
cargo fmt ${VERBOSE} --all -- --check
cd test && cargo fmt ${VERBOSE} --all -- --check
clippy: setup-ckb-test ## Run linter to examine Rust source codes.
cargo clippy ${VERBOSE} --all --all-targets --all-features -- -D warnings -D clippy::clone_on_ref_ptr -D clippy::enum_glob_use -D clippy::fallible_impl_from
cd test && cargo clippy ${VERBOSE} --all --all-targets --all-features -- -D warnings -D clippy::clone_on_ref_ptr -D clippy::enum_glob_use -D clippy::fallible_impl_from
security-audit: ## Use cargo-audit to audit Cargo.lock for crates with security vulnerabilities.
@cargo audit --version || cargo install cargo-audit
@cargo audit
# expecting to see "Success No vulnerable packages found"
##@ Continuous Integration
ci: ## Run recipes for CI.
ci: cargo-license fmt clippy security-audit test
git diff --exit-code Cargo.lock
info: ## Show environment info.
date
pwd
env
cargo-license:
FILES="$$(find . -name Cargo.toml | xargs grep -L '^license')"; if [ -n "$$FILES" ]; then echo "Missing license in: $${FILES}"; false; fi
##@ Generates Files
GEN_FILES := protocol/src/protocol_generated.rs protocol/src/protocol_generated_verifier.rs
gen: ${GEN_FILES}
gen-clean:
rm -f ${GEN_FILES}
check-cfbc-version:
test "$$($(CFBC) --version)" = 0.1.9
%_generated.rs: %.fbs
$(FLATC) -r -o $(shell dirname $@) $<
%_generated_verifier.rs: %.fbs check-cfbc-version
$(FLATC) -b --schema -o $(shell dirname $@) $<
$(CFBC) -o $(shell dirname $@) $*.bfbs
rm -f $*.bfbs $*_builder.rs
##@ Cleanup
clean: ## Clean tmp files.
rm -rf ckb.toml ckb-miner.toml specs/
##@ Helpers
stats: ## Counting lines of code.
@cargo count --version || cargo +nightly install --git https://github.com/kbknapp/cargo-count
@cargo count --separator , --unsafe-statistics
help: ## Display help message.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
.PHONY: build prod prod-test docker
.PHONY: gen gen-clean clean check-cfbc-version
.PHONY: fmt test clippy doc doc-deps check stats
.PHONY: ci info security-audit
.PHONY: integration integration-release setup-ckb-test