forked from holochain/lair
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
128 lines (114 loc) · 5.17 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
# Lair Makefile
.PHONY: all publish test static docs tools tool_rust tool_fmt tool_readme
SHELL = /usr/bin/env sh
ifeq ($(OS),Windows_NT)
FEATURES = --no-default-features --features=rusqlite-bundled
else
FEATURES = --no-default-features --features=rusqlite-bundled-sqlcipher-vendored-openssl
endif
all: static test
publish:
@case "$(crate)" in \
hc_seed_bundle) \
export MANIFEST="./crates/hc_seed_bundle/Cargo.toml"; \
;; \
lair_keystore_api) \
export MANIFEST="./crates/lair_keystore_api/Cargo.toml"; \
;; \
lair_keystore) \
export MANIFEST="./crates/lair_keystore/Cargo.toml"; \
;; \
*) \
echo "USAGE: make publish crate=hc_seed_bundle"; \
echo "USAGE: make publish crate=lair_keystore_api"; \
echo "USAGE: make publish crate=lair_keystore"; \
exit 1; \
;; \
esac; \
export VER="v$$(grep version $${MANIFEST} | head -1 | cut -d ' ' -f 3 | cut -d \" -f 2)"; \
echo "publish $(crate) $${MANIFEST} $${VER}"; \
git diff --exit-code; \
cargo publish --manifest-path $${MANIFEST}; \
git tag -a "$(crate)-$${VER}" -m "$(crate)-$${VER}"; \
git push --tags;
test: tools
RUST_BACKTRACE=1 cargo build $(FEATURES) --all-targets
RUST_BACKTRACE=1 cargo test $(FEATURES) -- --test-threads 1
release: tools
RUST_BACKTRACE=1 cargo build $(FEATURES) --release --all-targets
static: tools docs
cargo fmt -- --check
cargo clippy $(FEATURES) -- -Dwarnings
docs: tools
printf '### `lair-keystore --help`\n```text\n' > crates/lair_keystore/src/docs/help.md.tmp
cargo run $(FEATURES) --manifest-path=crates/lair_keystore/Cargo.toml -- --help >> crates/lair_keystore/src/docs/help.md.tmp
printf '\n```\n' >> crates/lair_keystore/src/docs/help.md.tmp
printf '### `lair-keystore init --help`\n```text\n' > crates/lair_keystore/src/docs/init-help.md.tmp
cargo run $(FEATURES) --manifest-path=crates/lair_keystore/Cargo.toml -- init --help >> crates/lair_keystore/src/docs/init-help.md.tmp
printf '\n```\n' >> crates/lair_keystore/src/docs/init-help.md.tmp
printf '### `lair-keystore url --help`\n```text\n' > crates/lair_keystore/src/docs/url-help.md.tmp
cargo run $(FEATURES) --manifest-path=crates/lair_keystore/Cargo.toml -- url --help >> crates/lair_keystore/src/docs/url-help.md.tmp
printf '\n```\n' >> crates/lair_keystore/src/docs/url-help.md.tmp
printf '### `lair-keystore import-seed --help`\n```text\n' > crates/lair_keystore/src/docs/import-seed-help.md.tmp
cargo run $(FEATURES) --manifest-path=crates/lair_keystore/Cargo.toml -- import-seed --help >> crates/lair_keystore/src/docs/import-seed-help.md.tmp
printf '\n```\n' >> crates/lair_keystore/src/docs/import-seed-help.md.tmp
printf '### `lair-keystore server --help`\n```text\n' > crates/lair_keystore/src/docs/server-help.md.tmp
cargo run $(FEATURES) --manifest-path=crates/lair_keystore/Cargo.toml -- server --help >> crates/lair_keystore/src/docs/server-help.md.tmp
printf '\n```\n' >> crates/lair_keystore/src/docs/server-help.md.tmp
mv -f crates/lair_keystore/src/docs/help.md.tmp crates/lair_keystore/src/docs/help.md
mv -f crates/lair_keystore/src/docs/init-help.md.tmp crates/lair_keystore/src/docs/init-help.md
mv -f crates/lair_keystore/src/docs/url-help.md.tmp crates/lair_keystore/src/docs/url-help.md
mv -f crates/lair_keystore/src/docs/import-seed-help.md.tmp crates/lair_keystore/src/docs/import-seed-help.md
mv -f crates/lair_keystore/src/docs/server-help.md.tmp crates/lair_keystore/src/docs/server-help.md
cargo readme -r crates/hc_seed_bundle -o README.md
cargo readme -r crates/lair_keystore_api -o README.md
cargo readme -r crates/lair_keystore -o README.md
printf '\n' >> crates/lair_keystore/README.md
cat crates/lair_keystore/src/docs/help.md >> crates/lair_keystore/README.md
cat crates/lair_keystore/src/docs/init-help.md >> crates/lair_keystore/README.md
cat crates/lair_keystore/src/docs/url-help.md >> crates/lair_keystore/README.md
cat crates/lair_keystore/src/docs/import-seed-help.md >> crates/lair_keystore/README.md
cat crates/lair_keystore/src/docs/server-help.md >> crates/lair_keystore/README.md
cp crates/lair_keystore/README.md README.md
@if [ "${CI}x" != "x" ]; then git diff --exit-code; fi
tools: tool_rust tool_fmt tool_clippy tool_readme
tool_rust:
@if rustup --version >/dev/null 2>&1; then \
echo "# Makefile # found rustup, setting override stable"; \
rustup override set stable; \
else \
echo "# Makefile # rustup not found, hopefully we're on stable"; \
fi;
tool_fmt: tool_rust
@if ! (cargo fmt --version); \
then \
if rustup --version >/dev/null 2>&1; then \
echo "# Makefile # installing rustfmt with rustup"; \
rustup component add rustfmt; \
else \
echo "# Makefile # rustup not found, cannot install rustfmt"; \
exit 1; \
fi; \
else \
echo "# Makefile # rustfmt ok"; \
fi;
tool_clippy: tool_rust
@if ! (cargo clippy --version); \
then \
if rustup --version >/dev/null 2>&1; then \
echo "# Makefile # installing clippy with rustup"; \
rustup component add clippy; \
else \
echo "# Makefile # rustup not found, cannot install clippy"; \
exit 1; \
fi; \
else \
echo "# Makefile # clippy ok"; \
fi;
tool_readme: tool_rust
@if ! (cargo readme --version); \
then \
cargo install cargo-readme; \
else \
echo "# Makefile # readme ok"; \
fi;