-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
132 lines (115 loc) · 3.88 KB
/
justfile
File metadata and controls
132 lines (115 loc) · 3.88 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
mod keel '.justfiles/keel.just'
default:
@echo "Root recipes:"
@just --list
@echo
@echo "Keel module:"
@just --list keel
fmt:
cargo fmt
fmt-check:
cargo fmt --check
build profile="debug":
@set -eu; \
local_target="{{justfile_directory()}}/target"; \
case "{{profile}}" in \
debug) \
cargo build; \
profile_dir=debug; \
source_root="${CARGO_TARGET_DIR:-$local_target}"; \
source_bin="$source_root/$profile_dir/sift" \
;; \
release) \
cargo build --release; \
profile_dir=release; \
source_root="${CARGO_TARGET_DIR:-$local_target}"; \
source_bin="$source_root/$profile_dir/sift"; \
;; \
*) echo "unsupported build profile: {{profile}} (expected debug or release)" >&2; exit 1 ;; \
esac; \
dest_dir="$local_target/$profile_dir"; \
dest_bin="$dest_dir/sift"; \
if [ ! -f "$source_bin" ]; then \
echo "expected build artifact not found: $source_bin" >&2; \
exit 1; \
fi; \
mkdir -p "$dest_dir"; \
if [ "$source_bin" != "$dest_bin" ]; then \
cp -f "$source_bin" "$dest_bin"; \
echo "copied $source_bin -> $dest_bin"; \
fi
clippy:
cargo clippy --all-targets -- -D warnings
clippy-cuda:
cargo clippy --all-targets --features cuda -- -D warnings
test:
cargo nextest run
test-doc:
cargo test --doc
check:
cargo fmt --check
cargo clippy --all-targets -- -D warnings
cargo nextest run
cargo test --doc
check-cuda:
cargo clippy --all-targets --features cuda -- -D warnings
build-static:
@if [ -f "flake.nix" ]; then \
echo "Building static binary using Nix..."; \
nix build .#sift-static --out-link target/release/sift-static; \
echo "Static binary created at target/release/sift-static/bin/sift"; \
else \
echo "Static build only supported via Nix in this recipe."; \
exit 1; \
fi
sift *args:
@bash -eu -c '\
cargo_args=(--release); \
env_args=(); \
sift_args=(); \
cuda_enabled=0; \
for arg in "$@"; do \
if [ "$arg" = "--cuda" ]; then \
cuda_enabled=1; \
cargo_args+=(--features cuda); \
env_args+=("SIFT_DENSE_DEVICE=${SIFT_DENSE_DEVICE:-cpu}"); \
else \
sift_args+=("$arg"); \
fi; \
done; \
if [ "$cuda_enabled" -eq 1 ] \
&& [ "${#sift_args[@]}" -ge 2 ] \
&& [ "${sift_args[0]}" = "eval" ] \
&& [ "${sift_args[1]}" = "all" ]; then \
env_args+=("SIFT_JINA_DEVICE=${SIFT_JINA_DEVICE:-cpu}"); \
env_args+=("SIFT_GEMMA_DEVICE=${SIFT_GEMMA_DEVICE:-cpu}"); \
fi; \
env "${env_args[@]}" cargo run "${cargo_args[@]}" -- "${sift_args[@]}" \
' -- {{args}}
embed-build:
@set -eu; \
local_target="{{justfile_directory()}}/target"; \
manifest="{{justfile_directory()}}/examples/sift-embed/Cargo.toml"; \
cargo build --manifest-path "$manifest"; \
profile_dir=debug; \
source_root="${CARGO_TARGET_DIR:-$local_target}"; \
source_bin="$source_root/$profile_dir/sift-embed"; \
dest_dir="$local_target/$profile_dir"; \
dest_bin="$dest_dir/sift-embed"; \
if [ ! -f "$source_bin" ]; then \
echo "expected build artifact not found: $source_bin" >&2; \
exit 1; \
fi; \
mkdir -p "$dest_dir"; \
if [ "$source_bin" != "$dest_bin" ]; then \
cp -f "$source_bin" "$dest_bin"; \
echo "copied $source_bin -> $dest_bin"; \
fi
embed-sift path query:
cargo run --manifest-path examples/sift-embed/Cargo.toml -- search '{{path}}' '{{query}}'
embed-sift-here query:
cargo run --manifest-path examples/sift-embed/Cargo.toml -- search '{{query}}'
flamegraph *args:
cargo flamegraph --root="-E" -- eval {{args}}
bench:
cargo bench