-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathjustfile
More file actions
584 lines (490 loc) · 20 KB
/
justfile
File metadata and controls
584 lines (490 loc) · 20 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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
set positional-arguments
# Display help
help:
just -l
# === Build ===
# Debug build
build:
cargo build
# Release build
build-release:
cargo build --release
# Check compilation without building
check:
cargo check --all-features
# === Code Quality ===
# Format code
fmt:
cargo fmt -- --config imports_granularity=Item
# Auto-fix lint warnings
fix *args:
cargo clippy --fix --all-features --tests --allow-dirty "$@"
# Run linter
clippy:
cargo clippy --all-features --tests "$@"
# Alias for clippy
lint:
just clippy
# === Installation ===
install:
#!/usr/bin/env bash
set -euo pipefail
echo "eaRS Smart Installation"
echo "======================="
echo ""
# Show active toolchain if rustup is available
if command -v rustup &>/dev/null; then
rustup show active-toolchain
else
echo "rustup not found, checking cargo..."
cargo --version || { echo "Error: cargo not found"; exit 1; }
fi
# Detect OS
OS_TYPE="unknown"
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
OS_TYPE="linux"
echo "Detected OS: Linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
OS_TYPE="macos"
echo "Detected OS: macOS"
elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
OS_TYPE="windows"
echo "Detected OS: Windows"
else
echo "Warning: Unknown OS type: $OSTYPE"
fi
# For Linux, detect distribution and set environment variables
if [[ "$OS_TYPE" == "linux" ]]; then
# Check if Arch Linux
if command -v pacman &>/dev/null; then
echo "Detected: Arch Linux"
IS_ARCH=true
else
IS_ARCH=false
fi
# Check if Wayland/Hyprland is running
if [[ "${XDG_SESSION_TYPE:-}" == "wayland" ]] || [[ -n "${WAYLAND_DISPLAY:-}" ]]; then
echo "Detected: Wayland session"
IS_WAYLAND=true
else
IS_WAYLAND=false
fi
# Set CUDA environment variables if on Arch Linux with NVIDIA
if [[ "$IS_ARCH" == true ]] && command -v nvidia-smi &>/dev/null; then
echo "Detected: NVIDIA GPU on Arch Linux"
echo "Setting CUDA environment variables..."
export PATH=/opt/cuda/bin:$PATH
export CUDA_ROOT=/opt/cuda
export CUDARC_CUDA_VERSION=12060
# Auto-detect GPU compute capability
GPU_NAME=$(nvidia-smi --query-gpu=name --format=csv,noheader | head -1)
echo "GPU: $GPU_NAME"
case "$GPU_NAME" in
*"RTX 40"*|*"RTX 4"*)
export CMAKE_CUDA_ARCHITECTURES=89
echo "CUDA architecture: 8.9 (Ada Lovelace)"
;;
*"RTX 30"*|*"RTX 3"*)
export CMAKE_CUDA_ARCHITECTURES=86
echo "CUDA architecture: 8.6 (Ampere)"
;;
*"RTX 20"*|*"RTX 2"*|*"GTX 16"*)
export CMAKE_CUDA_ARCHITECTURES=75
echo "CUDA architecture: 7.5 (Turing)"
;;
*)
echo "Using default CUDA architecture"
;;
esac
fi
# Set Wayland/Hyprland environment variables if needed
if [[ "$IS_WAYLAND" == true ]]; then
echo "Setting Wayland-compatible environment variables..."
export WEBKIT_DISABLE_DMABUF_RENDERER=1
export GDK_BACKEND=x11
export WEBKIT_DISABLE_COMPOSITING_MODE=0
export WEBKIT_ENABLE_MEDIA_STREAM=1
fi
# Use system sentencepiece on Linux
export SENTENCEPIECE_SYS_USE_PKG_CONFIG=1
fi
echo ""
echo "Fetching dependencies..."
cargo fetch
echo ""
echo "Ready to install. Run 'just install-ears' for interactive installation."
echo "Or use specific install commands:"
echo " - just install-ears-cuda (NVIDIA GPU)"
echo " - just install-ears-metal (macOS Apple Silicon)"
echo " - just install-ears-default (CPU only)"
# Check and install system dependencies
check-deps:
#!/usr/bin/env bash
set -euo pipefail
echo "Checking system dependencies..."
# Detect OS
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
# Linux: requires system sentencepiece to avoid protobuf conflicts
if command -v apt-get &> /dev/null; then
# Debian/Ubuntu
if ! pkg-config --exists sentencepiece; then
echo "Installing sentencepiece..."
sudo apt-get update
sudo apt-get install -y libsentencepiece-dev sentencepiece
else
echo "✓ sentencepiece already installed"
fi
elif command -v dnf &> /dev/null; then
# Fedora/RHEL
if ! pkg-config --exists sentencepiece; then
echo "Installing sentencepiece..."
sudo dnf install -y sentencepiece-devel
else
echo "✓ sentencepiece already installed"
fi
elif command -v pacman &> /dev/null; then
# Arch Linux
if ! pkg-config --exists sentencepiece; then
echo "Installing sentencepiece..."
sudo pacman -S --noconfirm sentencepiece
else
echo "✓ sentencepiece already installed"
fi
else
echo "⚠ Unsupported Linux distribution. Please install sentencepiece manually."
exit 1
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
# macOS: sentencepiece is compiled from source (static linking)
echo "✓ macOS detected - sentencepiece will be compiled from source"
elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
# Windows: sentencepiece is compiled from source (static linking)
echo "✓ Windows detected - sentencepiece will be compiled from source"
else
echo "⚠ Unsupported OS: $OSTYPE"
exit 1
fi
echo "✓ All system dependencies checked"
# Run `cargo nextest` since it's faster than `cargo test`, though including
# --no-fail-fast is important to ensure all tests are run.
#
# Run `cargo install cargo-nextest` if you don't have it installed.
test:
cargo nextest run --no-fail-fast
# Install ears with all features and auto-detected acceleration
install-all:
#!/usr/bin/env bash
set -euo pipefail
# First check dependencies
just check-deps
echo "eaRS Full Installation (All Features)"
echo "======================================"
echo ""
# Detect compatible acceleration
ACCEL_FEATURE=""
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
# Linux: Check for GPU
if command -v nvidia-smi &>/dev/null; then
echo "✓ NVIDIA GPU detected"
ACCEL_FEATURE="nvidia"
# Set CUDA environment variables for Arch
if command -v pacman &>/dev/null; then
export PATH=/opt/cuda/bin:$PATH
export CUDA_ROOT=/opt/cuda
export CUDARC_CUDA_VERSION=12060
GPU_NAME=$(nvidia-smi --query-gpu=name --format=csv,noheader | head -1 2>/dev/null || echo "unknown")
if [[ "$GPU_NAME" != "unknown" ]]; then
echo "GPU: $GPU_NAME"
case "$GPU_NAME" in
*"RTX 40"*|*"RTX 4"*)
export CMAKE_CUDA_ARCHITECTURES=89
echo "CUDA architecture: 8.9 (Ada Lovelace)"
;;
*"RTX 30"*|*"RTX 3"*)
export CMAKE_CUDA_ARCHITECTURES=86
echo "CUDA architecture: 8.6 (Ampere)"
;;
*"RTX 20"*|*"RTX 2"*|*"GTX 16"*)
export CMAKE_CUDA_ARCHITECTURES=75
echo "CUDA architecture: 7.5 (Turing)"
;;
esac
fi
fi
elif lspci 2>/dev/null | grep -i amd | grep -iq vga; then
echo "✓ AMD GPU detected"
ACCEL_FEATURE="amd"
else
echo "ℹ No GPU acceleration detected, using CPU"
fi
# Set Wayland environment variables if running Wayland
if [[ "${XDG_SESSION_TYPE:-}" == "wayland" ]] || [[ -n "${WAYLAND_DISPLAY:-}" ]]; then
echo "✓ Wayland session detected"
export WEBKIT_DISABLE_DMABUF_RENDERER=1
export GDK_BACKEND=x11
export WEBKIT_DISABLE_COMPOSITING_MODE=0
export WEBKIT_ENABLE_MEDIA_STREAM=1
fi
export SENTENCEPIECE_SYS_USE_PKG_CONFIG=1
elif [[ "$OSTYPE" == "darwin"* ]]; then
# macOS: Check for Apple Silicon
if [[ $(uname -m) == "arm64" ]]; then
echo "✓ Apple Silicon detected"
ACCEL_FEATURE="apple"
else
echo "ℹ Intel Mac detected, using CPU"
fi
elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" ]]; then
# Windows: Check for NVIDIA or suggest DirectML
if command -v nvidia-smi &>/dev/null; then
echo "✓ NVIDIA GPU detected"
ACCEL_FEATURE="nvidia"
else
echo "ℹ Using DirectML (Windows GPU acceleration)"
ACCEL_FEATURE="directml"
fi
fi
# Build feature list with all engines and hooks
FEATURES=("whisper" "parakeet" "hooks")
if [[ -n "$ACCEL_FEATURE" ]]; then
FEATURES=("$ACCEL_FEATURE" "${FEATURES[@]}")
fi
FEATURE_STRING=$(IFS=,; echo "${FEATURES[*]}")
echo ""
echo "Installing with features: $FEATURE_STRING"
echo ""
# Allow user to confirm or override
read -rp "Proceed with installation? [Y/n/custom]: " choice
case "${choice:-y}" in
[Yy]|"")
cargo install --path . --force --features "$FEATURE_STRING"
;;
[Cc]*)
echo ""
echo "Available acceleration options:"
echo " 1) nvidia (CUDA)"
echo " 2) apple (Metal/CoreML)"
echo " 3) amd (ROCm)"
echo " 4) directml (Windows)"
echo " 5) none (CPU only)"
read -rp "Select acceleration [1-5]: " accel_choice
case "${accel_choice:-1}" in
1) ACCEL_FEATURE="nvidia" ;;
2) ACCEL_FEATURE="apple" ;;
3) ACCEL_FEATURE="amd" ;;
4) ACCEL_FEATURE="directml" ;;
5) ACCEL_FEATURE="" ;;
*) echo "Invalid choice, using auto-detected"; ;;
esac
FEATURES=("whisper" "parakeet" "hooks")
if [[ -n "$ACCEL_FEATURE" ]]; then
FEATURES=("$ACCEL_FEATURE" "${FEATURES[@]}")
fi
FEATURE_STRING=$(IFS=,; echo "${FEATURES[*]}")
echo "Installing with features: $FEATURE_STRING"
cargo install --path . --force --features "$FEATURE_STRING"
;;
*)
echo "Installation cancelled"
exit 0
;;
esac
echo ""
echo "✓ Installation complete!"
echo "Installed binaries: ears, ears-server, ears-dictation"
# Install ears with interactive feature selection (checks dependencies first)
install-ears:
#!/usr/bin/env bash
set -euo pipefail
# First check dependencies
just check-deps
# Detect OS and set environment variables
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
# Check if Arch Linux with NVIDIA
if command -v pacman &>/dev/null && command -v nvidia-smi &>/dev/null; then
echo "Setting CUDA environment variables for Arch Linux..."
export PATH=/opt/cuda/bin:$PATH
export CUDA_ROOT=/opt/cuda
export CUDARC_CUDA_VERSION=12060
# Auto-detect GPU compute capability
GPU_NAME=$(nvidia-smi --query-gpu=name --format=csv,noheader | head -1 2>/dev/null || echo "unknown")
if [[ "$GPU_NAME" != "unknown" ]]; then
case "$GPU_NAME" in
*"RTX 40"*|*"RTX 4"*)
export CMAKE_CUDA_ARCHITECTURES=89
;;
*"RTX 30"*|*"RTX 3"*)
export CMAKE_CUDA_ARCHITECTURES=86
;;
*"RTX 20"*|*"RTX 2"*|*"GTX 16"*)
export CMAKE_CUDA_ARCHITECTURES=75
;;
esac
fi
fi
# Set Wayland environment variables if running Wayland
if [[ "${XDG_SESSION_TYPE:-}" == "wayland" ]] || [[ -n "${WAYLAND_DISPLAY:-}" ]]; then
echo "Setting Wayland-compatible environment variables..."
export WEBKIT_DISABLE_DMABUF_RENDERER=1
export GDK_BACKEND=x11
export WEBKIT_DISABLE_COMPOSITING_MODE=0
export WEBKIT_ENABLE_MEDIA_STREAM=1
fi
# Use system sentencepiece on Linux
export SENTENCEPIECE_SYS_USE_PKG_CONFIG=1
fi
# Run the interactive install script
./scripts/install-ears.sh
# Install ears with specific features (e.g., just install-ears-features "nvidia,parakeet")
# Available features: nvidia, apple, amd, directml, whisper, parakeet, hooks
# Combine multiple features with commas: "nvidia,parakeet" or "apple,whisper,hooks"
install-ears-features features:
#!/usr/bin/env bash
set -euo pipefail
# First check dependencies
just check-deps
# Detect OS and set environment variables
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
# Check if Arch Linux with NVIDIA
if command -v pacman &>/dev/null && command -v nvidia-smi &>/dev/null; then
export PATH=/opt/cuda/bin:$PATH
export CUDA_ROOT=/opt/cuda
export CUDARC_CUDA_VERSION=12060
GPU_NAME=$(nvidia-smi --query-gpu=name --format=csv,noheader | head -1 2>/dev/null || echo "unknown")
if [[ "$GPU_NAME" != "unknown" ]]; then
case "$GPU_NAME" in
*"RTX 40"*|*"RTX 4"*) export CMAKE_CUDA_ARCHITECTURES=89 ;;
*"RTX 30"*|*"RTX 3"*) export CMAKE_CUDA_ARCHITECTURES=86 ;;
*"RTX 20"*|*"RTX 2"*|*"GTX 16"*) export CMAKE_CUDA_ARCHITECTURES=75 ;;
esac
fi
fi
# Set Wayland environment variables if running Wayland
if [[ "${XDG_SESSION_TYPE:-}" == "wayland" ]] || [[ -n "${WAYLAND_DISPLAY:-}" ]]; then
export WEBKIT_DISABLE_DMABUF_RENDERER=1
export GDK_BACKEND=x11
export WEBKIT_DISABLE_COMPOSITING_MODE=0
export WEBKIT_ENABLE_MEDIA_STREAM=1
fi
export SENTENCEPIECE_SYS_USE_PKG_CONFIG=1
fi
cargo install --path . --force --features {{features}}
# Install ears with default features (CPU only)
install-ears-default:
#!/usr/bin/env bash
set -euo pipefail
just check-deps
# Set Linux-specific environment variables
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
if [[ "${XDG_SESSION_TYPE:-}" == "wayland" ]] || [[ -n "${WAYLAND_DISPLAY:-}" ]]; then
export WEBKIT_DISABLE_DMABUF_RENDERER=1
export GDK_BACKEND=x11
export WEBKIT_DISABLE_COMPOSITING_MODE=0
export WEBKIT_ENABLE_MEDIA_STREAM=1
fi
export SENTENCEPIECE_SYS_USE_PKG_CONFIG=1
fi
cargo install --path . --force
# Install ears with Metal acceleration (macOS)
install-ears-metal:
#!/usr/bin/env bash
set -euo pipefail
just check-deps
cargo install --path . --force --features apple
# Install ears with CUDA acceleration (NVIDIA)
install-ears-cuda:
#!/usr/bin/env bash
set -euo pipefail
just check-deps
# Set CUDA environment variables for Arch Linux
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
if command -v pacman &>/dev/null && command -v nvidia-smi &>/dev/null; then
export PATH=/opt/cuda/bin:$PATH
export CUDA_ROOT=/opt/cuda
export CUDARC_CUDA_VERSION=12060
GPU_NAME=$(nvidia-smi --query-gpu=name --format=csv,noheader | head -1 2>/dev/null || echo "unknown")
if [[ "$GPU_NAME" != "unknown" ]]; then
case "$GPU_NAME" in
*"RTX 40"*|*"RTX 4"*) export CMAKE_CUDA_ARCHITECTURES=89 ;;
*"RTX 30"*|*"RTX 3"*) export CMAKE_CUDA_ARCHITECTURES=86 ;;
*"RTX 20"*|*"RTX 2"*|*"GTX 16"*) export CMAKE_CUDA_ARCHITECTURES=75 ;;
esac
fi
fi
if [[ "${XDG_SESSION_TYPE:-}" == "wayland" ]] || [[ -n "${WAYLAND_DISPLAY:-}" ]]; then
export WEBKIT_DISABLE_DMABUF_RENDERER=1
export GDK_BACKEND=x11
export WEBKIT_DISABLE_COMPOSITING_MODE=0
export WEBKIT_ENABLE_MEDIA_STREAM=1
fi
export SENTENCEPIECE_SYS_USE_PKG_CONFIG=1
fi
cargo install --path . --force --features nvidia
# Install ears with CUDA + Parakeet (best for NVIDIA GPUs)
install-ears-cuda-parakeet:
#!/usr/bin/env bash
set -euo pipefail
just check-deps
# Set Linux-specific environment variables
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
if command -v pacman &>/dev/null && command -v nvidia-smi &>/dev/null; then
export PATH=/opt/cuda/bin:$PATH
export CUDA_ROOT=/opt/cuda
export CUDARC_CUDA_VERSION=12060
GPU_NAME=$(nvidia-smi --query-gpu=name --format=csv,noheader | head -1 2>/dev/null || echo "unknown")
if [[ "$GPU_NAME" != "unknown" ]]; then
case "$GPU_NAME" in
*"RTX 40"*|*"RTX 4"*) export CMAKE_CUDA_ARCHITECTURES=89 ;;
*"RTX 30"*|*"RTX 3"*) export CMAKE_CUDA_ARCHITECTURES=86 ;;
*"RTX 20"*|*"RTX 2"*|*"GTX 16"*) export CMAKE_CUDA_ARCHITECTURES=75 ;;
esac
fi
fi
if [[ "${XDG_SESSION_TYPE:-}" == "wayland" ]] || [[ -n "${WAYLAND_DISPLAY:-}" ]]; then
export WEBKIT_DISABLE_DMABUF_RENDERER=1
export GDK_BACKEND=x11
export WEBKIT_DISABLE_COMPOSITING_MODE=0
export WEBKIT_ENABLE_MEDIA_STREAM=1
fi
export SENTENCEPIECE_SYS_USE_PKG_CONFIG=1
fi
cargo install --path . --force --features nvidia,parakeet
# Install ears with Parakeet engine
install-ears-parakeet:
#!/usr/bin/env bash
set -euo pipefail
just check-deps
# Set Linux-specific environment variables
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
if command -v pacman &>/dev/null && command -v nvidia-smi &>/dev/null; then
export PATH=/opt/cuda/bin:$PATH
export CUDA_ROOT=/opt/cuda
export CUDARC_CUDA_VERSION=12060
GPU_NAME=$(nvidia-smi --query-gpu=name --format=csv,noheader | head -1 2>/dev/null || echo "unknown")
if [[ "$GPU_NAME" != "unknown" ]]; then
case "$GPU_NAME" in
*"RTX 40"*|*"RTX 4"*) export CMAKE_CUDA_ARCHITECTURES=89 ;;
*"RTX 30"*|*"RTX 3"*) export CMAKE_CUDA_ARCHITECTURES=86 ;;
*"RTX 20"*|*"RTX 2"*|*"GTX 16"*) export CMAKE_CUDA_ARCHITECTURES=75 ;;
esac
fi
fi
if [[ "${XDG_SESSION_TYPE:-}" == "wayland" ]] || [[ -n "${WAYLAND_DISPLAY:-}" ]]; then
export WEBKIT_DISABLE_DMABUF_RENDERER=1
export GDK_BACKEND=x11
export WEBKIT_DISABLE_COMPOSITING_MODE=0
export WEBKIT_ENABLE_MEDIA_STREAM=1
fi
export SENTENCEPIECE_SYS_USE_PKG_CONFIG=1
fi
cargo install --path . --force --features parakeet
# === Maintenance ===
# Clean build artifacts
clean:
cargo clean
# Update dependencies
update:
cargo update
# Generate documentation
docs:
cargo doc --no-deps --open