summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authorGravatar Tesseract222025-08-09 18:57:19 +0800
committerGravatar Tesseract222025-08-09 18:57:19 +0800
commite011e342420fe1f1f5d2fee932447b194f989032 (patch)
tree01c19ac7f5b7ce540cc3fd98581e29d8f7b782bd /build.zig
parentMerge pull request #188 from gracen-writes-code/master (diff)
downloadzig-sqlite-e011e342420fe1f1f5d2fee932447b194f989032.tar.gz
zig-sqlite-e011e342420fe1f1f5d2fee932447b194f989032.tar.xz
zig-sqlite-e011e342420fe1f1f5d2fee932447b194f989032.zip
chore: update to zig 0.15
Everything other than loadextension works. zig 0.15 remove usingnamespac, so tha whole mechanism has to be reworked, and idk how
Diffstat (limited to '')
-rw-r--r--build.zig35
1 files changed, 25 insertions, 10 deletions
diff --git a/build.zig b/build.zig
index 328679c..f8d9536 100644
--- a/build.zig
+++ b/build.zig
@@ -110,10 +110,15 @@ fn computeTestTargets(isNative: bool, ci: ?bool) ?[]const TestTarget {
110 110
111// This creates a SQLite static library from the SQLite dependency code. 111// This creates a SQLite static library from the SQLite dependency code.
112fn makeSQLiteLib(b: *std.Build, dep: *std.Build.Dependency, c_flags: []const []const u8, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, sqlite_c: enum { with, without }) *std.Build.Step.Compile { 112fn makeSQLiteLib(b: *std.Build, dep: *std.Build.Dependency, c_flags: []const []const u8, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, sqlite_c: enum { with, without }) *std.Build.Step.Compile {
113 const lib = b.addStaticLibrary(.{ 113 const mod = b.addModule("lib-sqlite", .{
114 .name = "sqlite",
115 .target = target, 114 .target = target,
116 .optimize = optimize, 115 .optimize = optimize,
116 .link_libc = true,
117 });
118 const lib = b.addLibrary(.{
119 .name = "sqlite",
120 .linkage = .dynamic,
121 .root_module = mod,
117 }); 122 });
118 123
119 lib.addIncludePath(dep.path(".")); 124 lib.addIncludePath(dep.path("."));
@@ -128,7 +133,6 @@ fn makeSQLiteLib(b: *std.Build, dep: *std.Build.Dependency, c_flags: []const []c
128 .file = b.path("c/workaround.c"), 133 .file = b.path("c/workaround.c"),
129 .flags = c_flags, 134 .flags = c_flags,
130 }); 135 });
131 lib.linkLibC();
132 136
133 return lib; 137 return lib;
134} 138}
@@ -225,13 +229,17 @@ pub fn build(b: *std.Build) !void {
225 229
226 const test_sqlite_lib = makeSQLiteLib(b, sqlite_dep, c_flags, cross_target, optimize, .with); 230 const test_sqlite_lib = makeSQLiteLib(b, sqlite_dep, c_flags, cross_target, optimize, .with);
227 231
228 const tests = b.addTest(.{ 232 const mod = b.addModule(test_name, .{
229 .name = test_name,
230 .target = cross_target, 233 .target = cross_target,
231 .optimize = optimize, 234 .optimize = optimize,
232 .root_source_file = b.path("sqlite.zig"), 235 .root_source_file = b.path("sqlite.zig"),
233 .single_threaded = test_target.single_threaded, 236 .single_threaded = test_target.single_threaded,
234 }); 237 });
238
239 const tests = b.addTest(.{
240 .name = test_name,
241 .root_module = mod,
242 });
235 tests.addIncludePath(b.path("c")); 243 tests.addIncludePath(b.path("c"));
236 tests.addIncludePath(sqlite_dep.path(".")); 244 tests.addIncludePath(sqlite_dep.path("."));
237 tests.linkLibrary(test_sqlite_lib); 245 tests.linkLibrary(test_sqlite_lib);
@@ -282,13 +290,17 @@ fn addPreprocessStep(b: *std.Build, sqlite_dep: *std.Build.Dependency) void {
282} 290}
283 291
284fn addZigcrypto(b: *std.Build, sqlite_mod: *std.Build.Module, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) *std.Build.Step.InstallArtifact { 292fn addZigcrypto(b: *std.Build, sqlite_mod: *std.Build.Module, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) *std.Build.Step.InstallArtifact {
285 const exe = b.addSharedLibrary(.{ 293 const mod = b.addModule("zigcryto", .{
286 .name = "zigcrypto",
287 .root_source_file = b.path("examples/zigcrypto.zig"), 294 .root_source_file = b.path("examples/zigcrypto.zig"),
288 .version = null,
289 .target = getTarget(target), 295 .target = getTarget(target),
290 .optimize = optimize, 296 .optimize = optimize,
291 }); 297 });
298 const exe = b.addLibrary(.{
299 .name = "zigcrypto",
300 .root_module = mod,
301 .version = null,
302 .linkage = .dynamic,
303 });
292 exe.root_module.addImport("sqlite", sqlite_mod); 304 exe.root_module.addImport("sqlite", sqlite_mod);
293 305
294 const install_artifact = b.addInstallArtifact(exe, .{}); 306 const install_artifact = b.addInstallArtifact(exe, .{});
@@ -298,12 +310,15 @@ fn addZigcrypto(b: *std.Build, sqlite_mod: *std.Build.Module, target: std.Build.
298} 310}
299 311
300fn addZigcryptoTestRun(b: *std.Build, sqlite_mod: *std.Build.Module, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) *std.Build.Step.Run { 312fn addZigcryptoTestRun(b: *std.Build, sqlite_mod: *std.Build.Module, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) *std.Build.Step.Run {
301 const zigcrypto_test = b.addExecutable(.{ 313 const mod = b.addModule("zigcryto-test", .{
302 .name = "zigcrypto-test",
303 .root_source_file = b.path("examples/zigcrypto_test.zig"), 314 .root_source_file = b.path("examples/zigcrypto_test.zig"),
304 .target = getTarget(target), 315 .target = getTarget(target),
305 .optimize = optimize, 316 .optimize = optimize,
306 }); 317 });
318 const zigcrypto_test = b.addExecutable(.{
319 .name = "zigcrypto-test",
320 .root_module = mod,
321 });
307 zigcrypto_test.root_module.addImport("sqlite", sqlite_mod); 322 zigcrypto_test.root_module.addImport("sqlite", sqlite_mod);
308 323
309 const install = b.addInstallArtifact(zigcrypto_test, .{}); 324 const install = b.addInstallArtifact(zigcrypto_test, .{});