-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-loop-rust.sh
executable file
·46 lines (38 loc) · 1.16 KB
/
build-loop-rust.sh
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
#!/bin/sh
#
# A looping build script which builds when a file changes. Helpful when editing Rust
# source code without a proper IDE or language server. This script uses cargo-watch if
# it is available or Linux inotify if not.
#
# Dependencies:
# cargo-watch OR inotify-tools (Linux-only)
# cargo-audit (optional)
# cargo-outdated (optional)
#
COMMAND=${1:-test}
# Reset terminal
reset
# Some statistics
find src -name "*.rs" | xargs wc -l && sleep 1s && echo ""
# Update, show vulnerable crates and list outdated root crates
cargo update && echo ""
cargo help outdated &>/dev/null && cargo outdated -R && sleep 1s && echo ""
cargo help audit &>/dev/null && cargo audit && sleep 1s && echo ""
# Use cargo-watch if it is installed
if cargo watch --version &>/dev/null ; then
# The initial build
cargo $COMMAND $*
# Build on demand
cargo watch --postpone -cx $COMMAND $*
else
# The initial build
shift 2>/dev/null
echo "Running cargo with subcommand '$COMMAND' $*"
cargo $COMMAND $*
# Build on demand
while inotifywait -e modify --exclude target -r . &>/dev/null ; do
sync
clear
cargo $COMMAND $*
done
fi