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);
}
