-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
justfile
158 lines (116 loc) · 3.74 KB
/
justfile
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
##
# Development Recipes
#
# This justfile is intended to be run from inside a Docker sandbox:
# https://github.com/Blobfolio/righteous-sandbox
#
# docker run \
# --rm \
# -v "{{ invocation_directory() }}":/share \
# -it \
# --name "righteous_sandbox" \
# "righteous/sandbox:debian"
#
# Alternatively, you can just run cargo commands the usual way and ignore these
# recipes.
##
pkg_id := "dactyl"
pkg_name := "Dactyl"
cargo_dir := "/tmp/" + pkg_id + "-cargo"
doc_dir := justfile_directory() + "/doc"
# Bench it!
bench BENCH="":
#!/usr/bin/env bash
clear
if [ -z "{{ BENCH }}" ]; then
cargo bench \
--benches \
--target-dir "{{ cargo_dir }}"
else
cargo bench \
--bench "{{ BENCH }}" \
--target-dir "{{ cargo_dir }}"
fi
exit 0
# Clean Cargo crap.
@clean:
# Most things go here.
[ ! -d "{{ cargo_dir }}" ] || rm -rf "{{ cargo_dir }}"
# But some Cargo apps place shit in subdirectories even if
# they place *other* shit in the designated target dir. Haha.
[ ! -d "{{ justfile_directory() }}/target" ] || rm -rf "{{ justfile_directory() }}/target"
cargo update -w
# Clippy.
@clippy:
clear
cargo clippy --target-dir "{{ cargo_dir }}"
cargo clippy \
--release \
--target-dir "{{ cargo_dir }}"
# Generate CREDITS.
@credits:
cargo bashman --no-bash --no-man
just _fix-chown "{{ justfile_directory() }}/CREDITS.md"
# Build Docs.
@doc:
# Make sure nightly is installed; this version generates better docs.
env RUSTUP_PERMIT_COPY_RENAME=true rustup install nightly
# Make the docs.
cargo +nightly rustdoc \
--release \
--all-features \
--target-dir "{{ cargo_dir }}"
# Move the docs and clean up ownership.
[ ! -d "{{ doc_dir }}" ] || rm -rf "{{ doc_dir }}"
mv "{{ cargo_dir }}/doc" "{{ justfile_directory() }}"
just _fix-chown "{{ doc_dir }}"
# Miri tests!
@miri:
# Pre-clean.
[ ! -d "{{ justfile_directory() }}/target" ] || rm -rf "{{ justfile_directory() }}/target"
fyi task "Testing x86_64-unknown-linux-gnu target."
MIRIFLAGS="-Zmiri-disable-isolation" cargo +nightly miri test --target x86_64-unknown-linux-gnu
fyi task "Testing i686-unknown-linux-gnu (32-bit) target."
MIRIFLAGS="-Zmiri-disable-isolation" cargo +nightly miri test --target i686-unknown-linux-gnu
fyi task "Testing mips64-unknown-linux-gnuabi64 (big endian) target."
MIRIFLAGS="-Zmiri-disable-isolation" cargo +nightly miri test --target mips64-unknown-linux-gnuabi64
# Post-clean.
[ ! -d "{{ justfile_directory() }}/target" ] || rm -rf "{{ justfile_directory() }}/target"
# Unit tests!
@test:
clear
cargo test \
--target-dir "{{ cargo_dir }}"
cargo test \
--release \
--target-dir "{{ cargo_dir }}"
# Get/Set version.
version:
#!/usr/bin/env bash
# Current version.
_ver1="$( toml get "{{ justfile_directory() }}/Cargo.toml" package.version | \
sed 's/"//g' )"
# Find out if we want to bump it.
_ver2="$( whiptail --inputbox "Set {{ pkg_name }} version:" --title "Release Version" 0 0 "$_ver1" 3>&1 1>&2 2>&3 )"
exitstatus=$?
if [ $exitstatus != 0 ] || [ "$_ver1" = "$_ver2" ]; then
exit 0
fi
fyi success "Setting version to $_ver2."
# Set the release version!
just _version "{{ justfile_directory() }}" "$_ver2"
just credits
# Set version for real.
@_version DIR VER:
[ -f "{{ DIR }}/Cargo.toml" ] || exit 1
# Set the release version!
toml set "{{ DIR }}/Cargo.toml" package.version "{{ VER }}" > /tmp/Cargo.toml
just _fix-chown "/tmp/Cargo.toml"
mv "/tmp/Cargo.toml" "{{ DIR }}/Cargo.toml"
# Fix file/directory permissions.
@_fix-chmod PATH:
[ ! -e "{{ PATH }}" ] || find "{{ PATH }}" -type f -exec chmod 0644 {} +
[ ! -e "{{ PATH }}" ] || find "{{ PATH }}" -type d -exec chmod 0755 {} +
# Fix file/directory ownership.
@_fix-chown PATH:
[ ! -e "{{ PATH }}" ] || chown -R --reference="{{ justfile() }}" "{{ PATH }}"