fetch_ml/cli/src/utils/sqlite_embedded.zig
Jeremie Fraeys ff542b533f
feat(cli): embed SQLite and unify commands for local mode
- Add SQLite amalgamation fetch script (make build-sqlite)
- Embed SQLite in release builds, link system lib in dev
- Create sqlite_embedded.zig utility module
- Unify experiment/run/log commands with auto mode detection
- Add Forgejo CI workflow for building with embedded SQLite
- Update READMEs for local mode and build instructions

SQLite follows rsync embedding pattern: assets/sqlite_release_<os>_<arch>/
Zero external dependencies for release builds.
2026-02-20 15:50:04 -05:00

36 lines
1.2 KiB
Zig

const std = @import("std");
const build_options = @import("build_options");
/// SQLite embedding strategy (mirrors rsync pattern)
///
/// For dev builds: link against system SQLite library
/// For release builds: compile SQLite from downloaded amalgamation
///
/// To prepare for release:
/// 1. Run: make build-sqlite
/// 2. Build with: zig build prod
pub const USE_EMBEDDED_SQLITE = build_options.has_sqlite_release;
/// Compile flags for embedded SQLite
pub const SQLITE_FLAGS = &[_][]const u8{
"-DSQLITE_ENABLE_FTS5",
"-DSQLITE_ENABLE_JSON1",
"-DSQLITE_THREADSAFE=1",
"-DSQLITE_USE_URI",
"-DSQLITE_ENABLE_COLUMN_METADATA",
"-DSQLITE_ENABLE_STAT4",
};
/// Get SQLite include path for embedded builds
pub fn getSqliteIncludePath(b: *std.Build) ?std.Build.LazyPath {
if (!USE_EMBEDDED_SQLITE) return null;
return b.path(build_options.sqlite_release_path);
}
/// Get SQLite source file path for embedded builds
pub fn getSqliteSourcePath(b: *std.Build) ?std.Build.LazyPath {
if (!USE_EMBEDDED_SQLITE) return null;
const path = std.fs.path.join(b.allocator, &.{ build_options.sqlite_release_path, "sqlite3.c" }) catch return null;
return b.path(path);
}