-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmise.toml
More file actions
360 lines (321 loc) · 11 KB
/
mise.toml
File metadata and controls
360 lines (321 loc) · 11 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
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
# mise configuration for cc_auto_switch
# Replaces Makefile functionality
# Use latest stable Rust version
[tools]
rust = "latest"
[env]
# Variables
CARGO = "cargo"
UPX = "upx"
DIST_DIR = "dist"
# Detect OS and set platform-specific variables
[tasks.detect-os]
description = "Detect current operating system"
run = """bash -lc '''
UNAME_S=$(uname -s)
if [ "$UNAME_S" = "Linux" ]; then
echo "HOST_OS=linux"
echo "HOST_EXT="
elif [ "$UNAME_S" = "Darwin" ]; then
echo "HOST_OS=macos"
echo "HOST_EXT="
elif [ "$OS" = "Windows_NT" ]; then
echo "HOST_OS=windows"
echo "HOST_EXT=.exe"
fi
'''"""
[tasks.all]
description = "Build in release mode for current platform (default)"
run = "cargo build --release"
alias = "all"
[tasks.build]
description = "Build in release mode for current platform"
run = "cargo build --release"
[tasks.pack]
description = "Build and pack with UPX for current platform"
depends = ["build", "check-upx"]
run = """bash -lc '''
echo "Packing binary with UPX..."
upx --best --ultra-brute -o /Users/jingzhao/target-rust/release/cc_auto_switch-packed /Users/jingzhao/target-rust/release/cc_auto_switch
echo "Packed binary: /Users/jingzhao/target-rust/release/cc_auto_switch-packed"
'''"""
[tasks.install]
description = "Build and install for current platform"
depends = ["build"]
run = "cargo install --path ."
[tasks.build-all]
description = "Build for all target platforms"
run = """bash -lc '''
for target in x86_64-unknown-linux-musl x86_64-pc-windows-gnu x86_64-apple-darwin aarch64-apple-darwin; do
echo "Building for target $target..."
cargo build --release --target $target
done
'''"""
[tasks.build-linux]
description = "Build for Linux targets"
run = """bash -lc '''
echo "Building for target x86_64-unknown-linux-musl..."
cargo build --release --target x86_64-unknown-linux-musl
'''"""
[tasks.build-macos]
description = "Build for macOS targets"
run = """bash -lc '''
echo "Building for target x86_64-apple-darwin..."
cargo build --release --target x86_64-apple-darwin
echo "Building for target aarch64-apple-darwin..."
cargo build --release --target aarch64-apple-darwin
'''"""
[tasks.build-windows]
description = "Build for Windows targets"
run = """bash -lc '''
echo "Building for target x86_64-pc-windows-gnu..."
cargo build --release --target x86_64-pc-windows-gnu
'''"""
[tasks.build-target]
description = "Build for specific target (use: mise run build-target TARGET=x86_64-unknown-linux-musl)"
run = """bash -lc '''
target="$@"
if [ -z "$target" ]; then
echo "Error: Please specify a target. Usage: mise run build-target TARGET=<target>"
exit 1
fi
echo "Building for target $target..."
cargo build --release --target "$target"
'''"""
[tasks.package-all]
description = "Package all targets as tar.gz files"
depends = ["build-all"]
run = """bash -lc '''
echo "Packaging all targets..."
mkdir -p dist
for target in x86_64-unknown-linux-musl x86_64-pc-windows-gnu x86_64-apple-darwin aarch64-apple-darwin; do
echo "Packaging $target..."
mkdir -p "dist/$target"
if echo "$target" | grep -q "windows"; then
ext=".exe"
else
ext=""
fi
if [ -f "target/$target/release/cc_auto_switch$ext" ]; then
cp "target/$target/release/cc_auto_switch$ext" "dist/$target/cc_auto_switch$ext"
cd "dist/$target" && tar -czf "../cc_auto_switch-$target.tar.gz" "cc_auto_switch$ext" && cd ../../
echo " Created dist/cc_auto_switch-$target.tar.gz"
fi
done
'''"""
[tasks.package-target]
description = "Package specific target as tar.gz file (use: mise run package-target TARGET=x86_64-unknown-linux-musl)"
depends = ["build-target"]
run = """bash -lc '''
target="$@"
if [ -z "$target" ]; then
echo "Error: Please specify a target. Usage: mise run package-target TARGET=<target>"
exit 1
fi
echo "Packaging target $target..."
mkdir -p "dist/$target"
if echo "$target" | grep -q "windows"; then
ext=".exe"
else
ext=""
fi
if [ -f "target/$target/release/cc_auto_switch$ext" ]; then
cp "target/$target/release/cc_auto_switch$ext" "dist/$target/cc_auto_switch$ext"
cd "dist/$target" && tar -czf "../cc_auto_switch-$target.tar.gz" "cc_auto_switch$ext" && cd ../../
echo "Created dist/cc_auto_switch-$target.tar.gz"
fi
'''"""
[tasks.release]
description = "Create complete release packages"
depends = ["package-all"]
run = """bash -lc '''
echo "Creating release packages..."
echo "Release packages created in dist/"
ls -la dist/*.tar.gz
'''"""
[tasks.clean]
description = "Clean build artifacts"
run = """bash -lc '''
cargo clean
rm -rf dist
'''"""
[tasks.rebuild]
description = "Clean and rebuild for current platform"
depends = ["clean", "build"]
[tasks.rebuild-all]
description = "Clean and rebuild all targets"
depends = ["clean", "build-all"]
[tasks.check-upx]
description = "Check if UPX is installed"
run = """bash -lc '''
if ! command -v upx >/dev/null 2>&1; then
echo "UPX is not installed. Please install UPX to use packing features."
exit 1
fi
echo "UPX is installed."
'''"""
[tasks.sizes]
description = "Show binary sizes for current platform"
depends = ["build"]
run = """bash -lc '''
echo "Binary sizes:"
ls -lh target/release/cc_auto_switch | awk '{print "Original: " $5}'
if [ -f "/Users/jingzhao/target-rust/release/cc_auto_switch-packed" ]; then
echo "Packed: $(ls -lh /Users/jingzhao/target-rust/release/cc_auto_switch-packed | awk '{print $5}')"
compression=$(( 100 - $(stat -c%s /Users/jingzhao/target-rust/release/cc_auto_switch-packed * 100 / $(stat -c%s target/release/cc_auto_switch)) ))
echo "Compression ratio: $compression%"
fi
'''"""
[tasks.sizes-all]
description = "Show binary sizes for all targets"
depends = ["build-all"]
run = """bash -lc '''
echo "Binary sizes for all targets:"
for target in x86_64-unknown-linux-musl x86_64-pc-windows-gnu x86_64-apple-darwin aarch64-apple-darwin; do
if echo "$target" | grep -q "windows"; then
ext=".exe"
else
ext=""
fi
if [ -f "target/$target/release/cc_auto_switch$ext" ]; then
echo " $target: $(ls -lh "target/$target/release/cc_auto_switch$ext" | awk '{print $5}')"
fi
done
'''"""
[tasks.run]
description = "Run the release binary"
depends = ["build"]
run = "target/release/cc_auto_switch"
[tasks.run-packed]
description = "Run the packed binary"
depends = ["pack"]
run = """bash -lc '''
if [ -f "/Users/jingzhao/target-rust/release/cc_auto_switch-packed" ]; then
/Users/jingzhao/target-rust/release/cc_auto_switch-packed
else
echo "Packed binary not found. Run 'mise pack' first."
exit 1
fi
'''"""
[tasks.dev]
description = "Run in development mode"
run = "cargo run"
[tasks.test]
description = "Run tests"
run = "cargo test"
[tasks.check]
description = "Check code compilation"
run = "cargo check"
[tasks.fmt]
description = "Format code"
run = "cargo fmt"
[tasks.fmt-check]
description = "Check code formatting"
run = "cargo fmt --check"
[tasks.lint]
description = "Lint code"
run = "cargo clippy"
[tasks.clippy-strict]
description = "Lint with warnings as errors"
run = "cargo clippy -- -D warnings"
[tasks.audit]
description = "Run security audit"
run = "cargo audit"
[tasks.install-hooks]
description = "Install pre-commit hooks"
run = "./scripts/setup-pre-commit.sh"
[tasks.run-hooks]
description = "Run pre-commit hooks manually"
run = "pre-commit run --all-files"
[tasks.quality]
description = "Run all quality checks"
depends = ["fmt-check", "clippy-strict", "check", "test", "audit"]
run = """bash -lc '''
echo "All quality checks passed!"
'''"""
[tasks.quick-check]
description = "Run quick checks (fmt + clippy + check)"
depends = ["fmt-check", "clippy-strict", "check"]
run = """bash -lc '''
echo "Quick checks passed!"
'''"""
[tasks.update]
description = "Update dependencies"
run = "cargo update"
[tasks.publish]
description = "Publish to crates.io"
run = """bash -lc '''
echo "Publishing to crates.io..."
cargo publish
echo "Published to crates.io successfully!"
'''"""
[tasks.publish-dry-run]
description = "Dry-run publish to crates.io"
run = """bash -lc '''
echo "Running dry-run publish to crates.io..."
cargo publish --dry-run
echo "Dry-run publish completed successfully!"
'''"""
[tasks.help]
description = "Show help message"
run = """bash -lc '''
echo "Available targets:"
echo ""
echo "Build targets:"
echo " all - Build in release mode for current platform (default)"
echo " build - Build in release mode for current platform"
echo " build-all - Build for all target platforms"
echo " build-linux - Build for Linux targets (x86_64-unknown-linux-musl)"
echo " build-macos - Build for macOS targets (x86_64-apple-darwin, aarch64-apple-darwin)"
echo " build-windows - Build for Windows targets (x86_64-pc-windows-gnu)"
echo " build-target - Build for specific target (use: mise run build-target TARGET=<target>)"
echo ""
echo "Package targets:"
echo " pack - Build and pack with UPX for current platform"
echo " package-all - Package all targets as tar.gz files"
echo " package-target - Package specific target as tar.gz file (use: mise run package-target TARGET=<target>)"
echo " release - Create complete release packages"
echo ""
echo "Install targets:"
echo " install - Build and install binary for current platform"
echo ""
echo "Publish targets:"
echo " publish - Publish to crates.io"
echo " publish-dry-run - Dry-run publish to crates.io"
echo ""
echo "Clean targets:"
echo " clean - Clean build artifacts"
echo " rebuild - Clean and rebuild for current platform"
echo " rebuild-all - Clean and rebuild all targets"
echo ""
echo "Utility targets:"
echo " check-upx - Check if UPX is installed"
echo " sizes - Show binary sizes for current platform"
echo " sizes-all - Show binary sizes for all targets"
echo " run - Run the release binary"
echo " run-packed - Run the packed binary"
echo " dev - Run in development mode"
echo " test - Run tests"
echo " check - Check code compilation"
echo " fmt - Format code"
echo " fmt-check - Check code formatting"
echo " lint - Lint code"
echo " clippy-strict - Lint with warnings as errors"
echo " audit - Run security audit"
echo " install-hooks - Install pre-commit hooks"
echo " run-hooks - Run pre-commit hooks manually"
echo " quality - Run all quality checks"
echo " quick-check - Run quick checks (fmt + clippy + check)"
echo " update - Update dependencies"
echo " help - Show this help message"
echo ""
echo "Supported targets:"
echo " x86_64-unknown-linux-musl, x86_64-pc-windows-gnu, x86_64-apple-darwin, aarch64-apple-darwin"
echo ""
echo "Examples:"
echo " mise run build-all # Build for all platforms"
echo " mise run build-linux # Build for Linux only"
echo " mise run package-target TARGET=x86_64-unknown-linux-musl # Package specific Linux target"
echo " mise run release # Create complete release"
echo " mise run publish # Publish to crates.io"
'''"""