-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunmetobuildeverything
More file actions
executable file
·609 lines (527 loc) · 21.9 KB
/
Copy pathrunmetobuildeverything
File metadata and controls
executable file
·609 lines (527 loc) · 21.9 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
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
#!/bin/bash
set -e
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR"
[ -x /opt/homebrew/bin/brew ] && eval "$(/opt/homebrew/bin/brew shellenv)" 2>/dev/null || true
[ -d "${HOME}/.cargo/bin" ] && export PATH="${HOME}/.cargo/bin:$PATH"
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
info() { echo -e "${GREEN}[INFO]${NC} $1"; }
warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
error() { echo -e "${RED}[ERROR]${NC} $1"; exit 1; }
step() { echo -e "\n${BLUE}==============================${NC}"; echo -e "${BLUE} $1${NC}"; echo -e "${BLUE}==============================${NC}"; }
sync_scripts_dir() {
local sha="$1"
local scripts_dir="$SCRIPT_DIR/scripts"
mkdir -p "$scripts_dir"
local contents_url="https://api.github.com/repos/chtugha/coding.agent/contents/scripts?ref=${sha}"
local api_resp
api_resp=$(curl -fsSL --max-time 15 "$contents_url" 2>/dev/null)
[ -z "$api_resp" ] && return 0
local file_list
file_list=$(python3 -c "
import json, sys
items = json.loads(sys.stdin.read())
if isinstance(items, list):
for item in items:
if item.get('type') == 'file':
print(item['name'])
" <<< "$api_resp" 2>/dev/null)
[ -z "$file_list" ] && return 0
local f
while IFS= read -r f; do
[ -z "$f" ] && continue
local raw_url="https://raw.githubusercontent.com/chtugha/coding.agent/${sha}/scripts/${f}"
curl -fsSL --max-time 60 "$raw_url" -o "$scripts_dir/$f" 2>/dev/null || true
done <<< "$file_list"
}
_sync_gh_dir() {
local sha="$1" subpath="$2" local_dir="$3"
mkdir -p "$local_dir"
local contents_url="https://api.github.com/repos/chtugha/coding.agent/contents/${subpath}?ref=${sha}"
local api_resp
api_resp=$(curl -fsSL --max-time 15 "$contents_url" 2>/dev/null)
[ -z "$api_resp" ] && return 0
local file_list
file_list=$(python3 -c "
import json, sys
items = json.loads(sys.stdin.read())
if isinstance(items, list):
for item in items:
if item.get('type') == 'file':
print(item['name'])
" <<< "$api_resp" 2>/dev/null)
[ -z "$file_list" ] && return 0
local f
while IFS= read -r f; do
[ -z "$f" ] && continue
local raw_url="https://raw.githubusercontent.com/chtugha/coding.agent/${sha}/${subpath}/${f}"
local dest="$local_dir/$f"
if [ ! -f "$dest" ] || [ "${FORCE_SYNC:-0}" = "1" ]; then
curl -fsSL --max-time 60 "$raw_url" -o "$dest" 2>/dev/null || true
fi
done <<< "$file_list"
}
sync_source_files() {
local sha="$1"
local skip_dirs="|bin|whisper-cpp|llama-cpp|third_party|moshi-rust|moshi-rag|scripts|.git|.zenflow|"
local contents_url="https://api.github.com/repos/chtugha/coding.agent/contents/?ref=${sha}"
local api_response
api_response=$(curl -fsSL --max-time 20 "$contents_url" 2>/dev/null)
if [ -z "$api_response" ]; then
return 0
fi
local file_names
file_names=$(python3 -c "
import json, sys
items = json.loads(sys.stdin.read())
for item in items:
if item.get('type') == 'file':
print(item['name'])
" <<< "$api_response" 2>/dev/null)
[ -z "$file_names" ] && return 0
local name
while IFS= read -r name; do
[ -z "$name" ] && continue
[[ "$skip_dirs" == *"|${name}|"* ]] && continue
if [ ! -f "$SCRIPT_DIR/$name" ] || [ "${FORCE_SYNC:-0}" = "1" ]; then
local raw_url="https://raw.githubusercontent.com/chtugha/coding.agent/${sha}/${name}"
curl -fsSL --max-time 60 "$raw_url" -o "$SCRIPT_DIR/$name" 2>/dev/null || true
fi
done <<< "$file_names"
_sync_gh_dir "$sha" "tests" "$SCRIPT_DIR/tests"
_sync_gh_dir "$sha" "libpiper" "$SCRIPT_DIR/libpiper"
_sync_gh_dir "$sha" "libpiper/include" "$SCRIPT_DIR/libpiper/include"
_sync_gh_dir "$sha" "libpiper/src" "$SCRIPT_DIR/libpiper/src"
_sync_gh_dir "$sha" "third_party/hnswlib" "$SCRIPT_DIR/third_party/hnswlib"
}
self_update() {
echo -e "${BLUE}[INFO]${NC} Checking for updates..."
local script_name
script_name="$(basename "$0")"
local script_path="$SCRIPT_DIR/$script_name"
local version_file="$SCRIPT_DIR/.build_version"
local head_api_url="https://api.github.com/repos/chtugha/coding.agent/commits/main"
local latest_sha
latest_sha=$(curl -fsSL --max-time 15 "$head_api_url" 2>/dev/null \
| grep -m1 '"sha"' \
| sed 's/.*"sha"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/')
if [ -z "$latest_sha" ]; then
echo -e "${YELLOW}[INFO]${NC} Could not reach GitHub — skipping update check"
return 0
fi
local local_sha=""
[ -f "$version_file" ] && local_sha=$(cat "$version_file" | tr -d '[:space:]')
local needs_source_sync=false
[ ! -f "$SCRIPT_DIR/CMakeLists.txt" ] && needs_source_sync=true
[ ! -f "$SCRIPT_DIR/third_party/hnswlib/hnswlib.h" ] && needs_source_sync=true
[ ! -d "$SCRIPT_DIR/tests" ] && needs_source_sync=true
if [ "$local_sha" = "$latest_sha" ] && [ "$needs_source_sync" = "false" ]; then
echo -e "${GREEN}[INFO]${NC} Already up to date (${latest_sha:0:7})"
return 0
fi
if [ "$local_sha" != "$latest_sha" ]; then
echo -e "${YELLOW}[INFO]${NC} New version available — updating to ${latest_sha:0:7}..."
FORCE_SYNC=1
fi
sync_scripts_dir "$latest_sha"
sync_source_files "$latest_sha"
FORCE_SYNC=0
local tmp_script
tmp_script="$(mktemp /tmp/prodigy-build-update.XXXXXX)" || {
echo -e "${YELLOW}[INFO]${NC} Could not create temp file — skipping update"
echo "$latest_sha" > "$version_file" 2>/dev/null || true
return 0
}
local raw_url="https://raw.githubusercontent.com/chtugha/coding.agent/${latest_sha}/${script_name}"
if ! curl -fsSL --max-time 30 "$raw_url" -o "$tmp_script" 2>/dev/null; then
echo -e "${YELLOW}[WARN]${NC} Script download failed — re-run to retry the update"
rm -f "$tmp_script"
return 0
fi
if diff -q "$tmp_script" "$script_path" &>/dev/null; then
rm -f "$tmp_script"
echo "$latest_sha" > "$version_file" 2>/dev/null || true
echo -e "${GREEN}[INFO]${NC} Scripts synced (${latest_sha:0:7})"
return 0
fi
chmod +x "$tmp_script"
cp "$tmp_script" "$script_path"
rm -f "$tmp_script"
echo "$latest_sha" > "$version_file" 2>/dev/null || true
echo -e "${GREEN}[INFO]${NC} Update applied (${latest_sha:0:7}). Re-launching..."
exec "$script_path" "$@"
}
NCPU=$(sysctl -n hw.ncpu 2>/dev/null || echo 4)
FORCE_REBUILD=0
SKIP_DEPS=0
BUILD_TESTS=ON
ORIG_ARGS=("$@")
while [[ $# -gt 0 ]]; do
case "$1" in
--force) FORCE_REBUILD=1; shift ;;
--skip-deps) SKIP_DEPS=1; shift ;;
--no-tests) BUILD_TESTS=OFF; shift ;;
-h|--help)
echo "Prodigy - Build Everything"
echo ""
echo "Usage: ./runmetobuildeverything [OPTIONS]"
echo ""
echo "Options:"
echo " --force Force rebuild even if libraries already exist"
echo " --skip-deps Skip building whisper.cpp and llama.cpp"
echo " --no-tests Skip building tests"
echo " -h, --help Show this help"
echo ""
echo "Build order:"
echo " 1. whisper.cpp (CoreML + Metal, static libs)"
echo " 2. llama.cpp (Metal, static libs)"
echo " 3. moshi-rag-service (Rust, cargo build, Metal)"
echo " 4. SQLCipher (auto-updated from GitHub master)"
echo " 5. Prodigy main project (all services)"
echo ""
echo "SQLCipher (database encryption):"
echo " Source is fetched from https://github.com/sqlcipher/sqlcipher"
echo " branch: master — updated on every build run."
echo " Compiled with SQLITE_HAS_CODEC + SQLCIPHER_CRYPTO_OPENSSL."
echo " Statically linked into 'frontend' and 'tomedo-crawl' binaries."
echo " Encryption key: auto-generated 256-bit AES, stored in macOS"
echo " Keychain (Secure Enclave-backed on Apple Silicon)."
echo " To pin SQLCipher to a specific commit, pass to cmake:"
echo " -DFETCHCONTENT_UPDATES_DISCONNECTED=ON"
echo ""
echo "Prerequisites: run ./runmetoinstalleverythingfirst"
exit 0
;;
*) error "Unknown option: $1. Use --help for usage." ;;
esac
done
setup_macos_env() {
local clt_sdk="/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
local clt_cc="/Library/Developer/CommandLineTools/usr/bin/cc"
if [[ -d "$clt_sdk" && -x "$clt_cc" ]]; then
export SDKROOT="$clt_sdk"
export CC="$clt_cc"
export CXX="/Library/Developer/CommandLineTools/usr/bin/c++"
fi
}
CMAKE_GEN=""
if command -v ninja &> /dev/null; then CMAKE_GEN="-G Ninja"; fi
clear_stale_cache() {
local bdir="$1"
local cache="$bdir/CMakeCache.txt"
[ -f "$cache" ] || return 0
if [ -n "$CMAKE_GEN" ]; then
if ! grep -q 'CMAKE_GENERATOR:INTERNAL=Ninja' "$cache" 2>/dev/null; then
warn "Removing stale CMake cache in $bdir (generator mismatch)"
rm -rf "$bdir"
fi
else
if grep -q 'CMAKE_GENERATOR:INTERNAL=Ninja' "$cache" 2>/dev/null; then
warn "Removing stale CMake cache in $bdir (generator mismatch)"
rm -rf "$bdir"
fi
fi
}
preflight_check() {
step "Preflight checks"
if [[ "$(uname -s)" != "Darwin" || "$(uname -m)" != "arm64" ]]; then
error "macOS Apple Silicon required"
fi
if ! command -v cmake &> /dev/null; then
error "cmake not found. Run ./runmetoinstalleverythingfirst first."
fi
if [ ! -d "whisper-cpp/.git" ] && [ ! -f "whisper-cpp/CMakeLists.txt" ]; then
error "whisper-cpp not found. Run ./runmetoinstalleverythingfirst first."
fi
if [ ! -d "llama-cpp/.git" ] && [ ! -f "llama-cpp/CMakeLists.txt" ]; then
error "llama-cpp not found. Run ./runmetoinstalleverythingfirst first."
fi
setup_macos_env
info "All prerequisites OK"
}
build_whisper_cpp() {
step "Building whisper.cpp"
local lib="whisper-cpp/build/src/libwhisper.a"
if [ -f "$lib" ] && [ "$FORCE_REBUILD" != "1" ]; then
info "whisper.cpp already built (use --force to rebuild)"
return
fi
clear_stale_cache whisper-cpp/build
info "Configuring whisper.cpp (CoreML + Metal, static, Release)..."
# shellcheck disable=SC2086
cmake $CMAKE_GEN -S whisper-cpp -B whisper-cpp/build \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DWHISPER_COREML=ON \
-DGGML_METAL=ON \
-DGGML_CCACHE=OFF \
-DGGML_OPENMP=OFF \
-DWHISPER_BUILD_TESTS=OFF \
-DWHISPER_BUILD_EXAMPLES=OFF
info "Building whisper.cpp (-j${NCPU})..."
cmake --build whisper-cpp/build --config Release -j"${NCPU}"
if [ -f "$lib" ]; then
info "whisper.cpp built: $lib"
else
error "whisper.cpp build failed: $lib not found"
fi
}
build_llama_cpp() {
step "Building llama.cpp"
local lib="llama-cpp/build/src/libllama.a"
if [ -f "$lib" ] && [ "$FORCE_REBUILD" != "1" ]; then
info "llama.cpp already built (use --force to rebuild)"
return
fi
clear_stale_cache llama-cpp/build
info "Configuring llama.cpp (Metal, static, Release)..."
# shellcheck disable=SC2086
cmake $CMAKE_GEN -S llama-cpp -B llama-cpp/build \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DGGML_METAL=ON \
-DGGML_OPENMP=OFF
info "Building llama.cpp (-j${NCPU})..."
cmake --build llama-cpp/build --config Release -j"${NCPU}"
if [ -f "$lib" ]; then
info "llama.cpp built: $lib"
else
error "llama.cpp build failed: $lib not found"
fi
}
build_sqlcipher_amalgamation() {
# ──────────────────────────────────────────────────────────────────────────
# SQLCipher amalgamation build
#
# WHY THIS IS DONE HERE (not inside CMake)
# SQLCipher's GitHub repo contains raw C source files, not the final
# sqlite3.c amalgamation. Building the amalgamation requires the SQLCipher
# autoconf toolchain:
# ./configure --with-crypto-lib=openssl (needs tclsh + OpenSSL headers)
# make sqlite3.c (concatenates ~100 source files)
# CMake cannot run arbitrary shell pipelines during configure without
# ExternalProject_Add, which makes the generated file unavailable until
# the build phase — too late to list it as a source file. Running this
# step in the shell script before cmake is invoked keeps things simple
# and reliable.
#
# CACHING STRATEGY
# The git SHA of the cloned master commit is recorded in
# third_party/sqlcipher/.sqlcipher_sha. If the SHA hasn't changed since
# the last build AND --force was not passed, the (expensive) autoconf +
# make step is skipped. Passing --force deletes the SHA file and forces
# a full rebuild.
#
# OUTPUT
# third_party/sqlcipher/sqlite3.c — amalgamation (compiled by frontend +
# tomedo-crawl with SQLITE_HAS_CODEC)
# third_party/sqlcipher/sqlite3.h — header with sqlite3_key() declarations
#
# DEPENDENCIES
# git, tclsh (ships with macOS Xcode CLT), openssl@3 (brew)
# ──────────────────────────────────────────────────────────────────────────
step "Building SQLCipher amalgamation (latest master)"
local src_dir="${SCRIPT_DIR}/third_party/sqlcipher/sqlcipher-src"
local out_dir="${SCRIPT_DIR}/third_party/sqlcipher"
local sha_file="${out_dir}/.sqlcipher_sha"
# Locate OpenSSL (Homebrew arm64 path)
local openssl_prefix
openssl_prefix=$(brew --prefix openssl@3 2>/dev/null) || true
if [ -z "$openssl_prefix" ] || [ ! -d "$openssl_prefix/include" ]; then
error "openssl@3 not found. Run ./runmetoinstalleverythingfirst first."
fi
# Verify tclsh is available (required by SQLCipher's amalgamation generator)
if ! command -v tclsh &> /dev/null; then
error "tclsh not found. Install Xcode Command Line Tools: xcode-select --install"
fi
# Clone or update SQLCipher from GitHub master
mkdir -p "$(dirname "$src_dir")"
if [ -d "$src_dir/.git" ]; then
info "Pulling latest SQLCipher from GitHub master..."
git -C "$src_dir" fetch --depth=1 origin master 2>/dev/null \
&& git -C "$src_dir" reset --hard origin/master 2>/dev/null \
|| warn "SQLCipher git pull failed — using cached source"
else
info "Cloning SQLCipher from GitHub..."
git clone --depth=1 https://github.com/sqlcipher/sqlcipher.git "$src_dir"
fi
local current_sha
current_sha=$(git -C "$src_dir" rev-parse HEAD 2>/dev/null || echo "unknown")
local cached_sha=""
[ -f "$sha_file" ] && cached_sha=$(cat "$sha_file")
if [ "$current_sha" = "$cached_sha" ] \
&& [ -f "${out_dir}/sqlite3.c" ] \
&& [ "$FORCE_REBUILD" != "1" ]; then
info "SQLCipher amalgamation is up to date (commit ${current_sha:0:8})"
return
fi
info "Generating SQLCipher amalgamation (commit ${current_sha:0:8})..."
info " configure --with-crypto-lib=openssl CPPFLAGS=-I${openssl_prefix}/include"
local orig_dir="$PWD"
cd "$src_dir"
# Run SQLCipher's autosetup-based configure to generate the Makefile.
# Note: --with-crypto-lib is NOT a valid option in the SQLCipher master
# branch (it was removed when the build system switched from autoconf to
# autosetup). The crypto backend (OpenSSL vs CommonCrypto) is selected
# at compile time via -DSQLCIPHER_CRYPTO_OPENSSL in CMakeLists.txt, not
# at configure time. All backend source files are included in the
# amalgamation unconditionally; the preprocessor picks one at build time.
./configure \
--with-tempstore=yes \
CPPFLAGS="-DSQLITE_HAS_CODEC -I${openssl_prefix}/include" \
LDFLAGS="-L${openssl_prefix}/lib" \
> /tmp/sqlcipher-configure.log 2>&1 \
|| { cat /tmp/sqlcipher-configure.log; error "SQLCipher ./configure failed"; }
info " make sqlite3.c (amalgamation generator)"
make sqlite3.c -j"${NCPU}" > /dev/null 2>&1 \
|| error "SQLCipher make sqlite3.c failed"
cd "$orig_dir"
# Copy outputs to third_party/sqlcipher/
mkdir -p "$out_dir"
cp "${src_dir}/sqlite3.c" "${out_dir}/sqlite3.c"
cp "${src_dir}/sqlite3.h" "${out_dir}/sqlite3.h"
# sqlcipher.h is included by sqlite3.c at compile time via SQLITE_HAS_CODEC
[ -f "${src_dir}/sqlcipher.h" ] && cp "${src_dir}/sqlcipher.h" "${out_dir}/sqlcipher.h" || true
echo "$current_sha" > "$sha_file"
info "SQLCipher amalgamation built successfully ($(wc -l < "${out_dir}/sqlite3.c") lines)"
info "Output: ${out_dir}/sqlite3.c + sqlite3.h"
}
build_moshi_rag_service() {
step "Building moshi-rag-service (Rust)"
local cargo_dir="$SCRIPT_DIR/moshi-rag/rust"
if ! command -v cargo &> /dev/null; then
warn "Rust/Cargo not found — skipping moshi-rag-service build"
warn " Install Rust: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh"
warn " Then re-run this script."
return
fi
if [ ! -d "$cargo_dir" ]; then
warn "$cargo_dir not found — skipping moshi-rag-service build"
return
fi
local bin_out="$SCRIPT_DIR/bin/moshi-rag-service"
if [ -f "$bin_out" ] && [ "$FORCE_REBUILD" != "1" ]; then
info "moshi-rag-service already built (use --force to rebuild)"
return
fi
for _dep in pkg-config sentencepiece; do
if ! brew list "$_dep" &>/dev/null; then
info "Installing $_dep (required by moshi-rag-service)..."
brew install "$_dep"
fi
done
info "Building moshi-rag-service (cargo build --release, Metal)..."
(
export PKG_CONFIG_PATH="/opt/homebrew/lib/pkgconfig:/opt/homebrew/share/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
export CMAKE_POLICY_VERSION_MINIMUM=3.5
cd "$cargo_dir"
cargo build --features metal --bin moshi-backend --release 2>&1
)
local built="$cargo_dir/target/release/moshi-backend"
if [ -f "$built" ]; then
mkdir -p "$(dirname "$bin_out")"
cp "$built" "$bin_out"
info "moshi-rag-service built: $bin_out ($(du -h "$bin_out" | cut -f1))"
else
warn "moshi-rag-service build failed — check Rust/Cargo output above"
warn " To build manually: cd moshi-rag/rust && cargo build --features metal --bin moshi-backend --release"
fi
}
build_main_project() {
step "Building Prodigy"
for _dep in nlohmann-json; do
if ! brew list "$_dep" &>/dev/null; then
info "Installing $_dep (required by libpiper)..."
brew install "$_dep"
fi
done
build_sqlcipher_amalgamation
clear_stale_cache build
if [ -f build/CMakeCache.txt ] && grep -q 'NOTFOUND' build/CMakeCache.txt 2>/dev/null; then
info "Clearing stale CMake cache (contains NOTFOUND entries from missing deps)"
rm -rf build
fi
info "Configuring Prodigy (CoreML, Release, tests=${BUILD_TESTS})..."
# shellcheck disable=SC2086
cmake $CMAKE_GEN -S . -B build \
-DCMAKE_BUILD_TYPE=Release \
-DKOKORO_COREML=ON \
-DBUILD_TESTS="${BUILD_TESTS}"
info "Building Prodigy (-j${NCPU})..."
cmake --build build --config Release -j"${NCPU}"
info "Prodigy build complete"
}
verify_binaries() {
step "Verifying binaries"
SERVICES=(
"bin/sip-client"
"bin/inbound-audio-processor"
"bin/vad-service"
"bin/outbound-audio-processor"
"bin/whisper-service"
"bin/llama-service"
"bin/tts-service"
"bin/kokoro-service"
"bin/neutts-service"
"bin/frontend"
"bin/tomedo-crawl"
)
OPTIONAL_SERVICES=(
"bin/vits2-service"
"bin/matcha-service"
"bin/moshi-rag-service"
)
ALL_OK=true
for svc in "${SERVICES[@]}"; do
if [ -f "$svc" ]; then
info " $svc ($(du -h "$svc" | cut -f1))"
else
warn " MISSING: $svc"
ALL_OK=false
fi
done
for svc in "${OPTIONAL_SERVICES[@]}"; do
if [ -f "$svc" ]; then
info " $svc ($(du -h "$svc" | cut -f1)) [optional]"
else
warn " not built: $svc (optional — check CMake output for missing dependencies)"
fi
done
echo ""
if $ALL_OK; then
echo -e "${GREEN}===============================================${NC}"
echo -e "${GREEN} Build Complete - All binaries ready!${NC}"
echo -e "${GREEN}===============================================${NC}"
echo ""
info "Start with: cd bin && ./frontend"
info "Web UI: http://localhost:8080"
if [ "$BUILD_TESTS" = "ON" ]; then
echo ""
info "Run tests: cd build && ctest --output-on-failure"
fi
else
echo -e "${YELLOW}===============================================${NC}"
echo -e "${YELLOW} Build finished with missing binaries${NC}"
echo -e "${YELLOW}===============================================${NC}"
warn "Some binaries are missing. Check warnings above."
return 1
fi
}
echo -e "${BLUE}===============================================${NC}"
echo -e "${BLUE} Prodigy - Build Everything${NC}"
echo -e "${BLUE}===============================================${NC}"
self_update "${ORIG_ARGS[@]}"
preflight_check
if [ "$SKIP_DEPS" != "1" ]; then
build_whisper_cpp
build_llama_cpp
else
info "Skipping dependency builds (--skip-deps)"
fi
build_moshi_rag_service
build_main_project
verify_binaries