-
Notifications
You must be signed in to change notification settings - Fork 161
/
Copy pathMakefile
136 lines (101 loc) · 3.97 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
VENDORED_DOCS_TOOLCHAIN := "nightly-2023-04-19"
# Using https://github.com/tonistiigi/xx
# Use in Docker images when cross-compiling.
install-xx:
xx-cargo install --locked --path . --force
# Redundancy tracked by #2991
install-cli:
cargo install --locked --path . --force
install-daemon:
cargo install --locked --path . --force
install:
cargo install --locked --path . --force
# Installs Forest binaries with default rust global allocator
install-with-rustalloc:
cargo install --locked --path . --force --no-default-features --features rustalloc
# Installs Forest binaries with MiMalloc global allocator
install-with-mimalloc:
cargo install --locked --path . --force --no-default-features --features mimalloc
install-deps:
# https://github.com/git-lfs/git-lfs/blob/main/INSTALLING.md#1-adding-the-packagecloud-repository
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
apt-get update -y
apt-get install --no-install-recommends -y git-lfs build-essential clang aria2
install-lint-tools:
cargo install --locked taplo-cli
cargo install --locked cargo-audit
cargo install --locked cargo-spellcheck
install-lint-tools-ci:
wget https://github.com/cargo-bins/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-musl.tgz
tar xzf cargo-binstall-x86_64-unknown-linux-musl.tgz
cp cargo-binstall ~/.cargo/bin/cargo-binstall
cargo binstall --no-confirm taplo-cli cargo-spellcheck cargo-audit
install-doc-tools:
cargo install --locked mdbook
cargo install --locked mdbook-linkcheck
clean-all:
cargo clean
clean:
cargo clean
# Lints with everything we have in our CI arsenal
lint-all: lint audit spellcheck
audit:
cargo audit || (echo "See .config/audit.toml"; false)
spellcheck:
cargo spellcheck --code 1 || (echo "See .config/spellcheck.md for tips"; false)
lint: license clean lint-clippy
cargo fmt --all --check
taplo fmt --check
taplo lint
# Don't bother linting different allocators
# Don't lint all permutations, just different versions of database, cns
# This should be simplified in #2984
# --quiet: don't show build logs
lint-clippy:
cargo clippy --quiet --no-deps -- --deny=warnings
cargo clippy --tests --quiet --no-deps -- --deny=warnings
DOCKERFILES=$(wildcard Dockerfile*)
lint-docker: $(DOCKERFILES)
docker run --rm -i hadolint/hadolint < $<
# Formats Rust, TOML and Markdown files.
fmt:
cargo fmt --all
taplo fmt
yarn md-fmt
build:
cargo build
release:
cargo build --release
docker-run:
docker build -t forest:latest -f ./Dockerfile . && docker run forest
test: go-mod
cargo nextest run
# nextest doesn't run doctests https://github.com/nextest-rs/nextest/issues/16
# see also lib.rs::doctest_private
cargo test --doc --features doctest-private
test-release: go-mod
cargo nextest run --release
test-all: test test-release
go-mod:
(cd $(PWD)/src/libp2p_bitswap/tests/go-app && go mod vendor && go build -o /tmp/forest-go-compat-test) || \
(echo "Some tests require Go 1.20.x to be installed, follow instructions at https://go.dev/dl/" && exit 1)
# Checks if all headers are present and adds if not
license:
./scripts/add_license.sh
docs:
cargo doc --no-deps
mdbook:
mdbook serve documentation
mdbook-build:
mdbook build ./documentation
# When you visit https://chainsafe.github.io/forest/rustdoc you get an index.html
# listing all crates that are documented (which is then published in CI).
# This isn't included by default, so we use a nightly toolchain, and the
# (unstable) `--enable-index-page` option.
# https://doc.rust-lang.org/nightly/rustdoc/unstable-features.html#--index-page-provide-a-top-level-landing-page-for-docs
# We document private items to ensure internal documentation is up-to-date (i.e passes lints)
vendored-docs:
rustup toolchain install $(VENDORED_DOCS_TOOLCHAIN)
RUSTDOCFLAGS="--deny=warnings --allow=rustdoc::private-intra-doc-links --document-private-items -Zunstable-options --enable-index-page" \
cargo +$(VENDORED_DOCS_TOOLCHAIN) doc --workspace --no-deps
.PHONY: $(MAKECMDGOALS)