Created
June 29, 2024 12:18
-
-
Save shreyassanthu77/f824528a4a9a94db1148462436884261 to your computer and use it in GitHub Desktop.
zig libsql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
pub fn build(b: *std.Build) void { | |
const target = b.standardTargetOptions(.{}); | |
const optimize = b.standardOptimizeOption(.{}); | |
const exe = b.addExecutable(.{ | |
.name = "ziglibsql", | |
.root_source_file = b.path("src/main.zig"), | |
.target = target, | |
.optimize = optimize, | |
.link_libc = true, | |
}); | |
exe.addIncludePath(b.path("include/")); | |
exe.addLibraryPath(b.path("lib/")); | |
exe.linkSystemLibrary2("sql_experimental", .{ | |
.preferred_link_mode = .static, | |
}); | |
b.installArtifact(exe); | |
const run_cmd = b.addRunArtifact(exe); | |
run_cmd.step.dependOn(b.getInstallStep()); | |
if (b.args) |args| { | |
run_cmd.addArgs(args); | |
} | |
const run_step = b.step("run", "Run the app"); | |
run_step.dependOn(&run_cmd.step); | |
const exe_unit_tests = b.addTest(.{ | |
.root_source_file = b.path("src/main.zig"), | |
.target = target, | |
.optimize = optimize, | |
}); | |
const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests); | |
const test_step = b.step("test", "Run unit tests"); | |
test_step.dependOn(&run_exe_unit_tests.step); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
const libsql = @cImport({ | |
@cInclude("libsql.h"); | |
}); | |
pub fn main() !void { | |
var conn: libsql.libsql_database_t = undefined; | |
var err_ptr: [*c]const u8 = undefined; | |
const ret = libsql.libsql_open_ext(":memory:", &conn, &err_ptr); | |
std.debug.print("{d}\n", .{ret}); | |
} | |
test "simple test" {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment