From f93fe4b0a5f73db221e89ab96a621f874a34e361 Mon Sep 17 00:00:00 2001 From: Vincent Rischmann Date: Mon, 18 Sep 2023 22:06:21 +0200 Subject: update readme for latest zig --- README.md | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 40c8d0c..d338331 100644 --- a/README.md +++ b/README.md @@ -136,7 +136,9 @@ If you want to use the system sqlite library, add the following to your `build.z ```zig exe.linkLibC(); exe.linkSystemLibrary("sqlite3"); -exe.addPackage(.{ .name = "sqlite", .path = "third_party/zig-sqlite/sqlite.zig" }); +exe.addAnonymousModule("sqlite", .{ + .source_file = .{ .path = "third_party/zig-sqlite/sqlite.zig" }, +}); ``` ## Using the bundled sqlite source code file @@ -144,8 +146,18 @@ exe.addPackage(.{ .name = "sqlite", .path = "third_party/zig-sqlite/sqlite.zig" If you want to use the bundled sqlite source code file, first you need to add it as a static library in your `build.zig` file: ```zig -const sqlite = b.addStaticLibrary("sqlite", null); -sqlite.addCSourceFile("third_party/zig-sqlite/c/sqlite3.c", &[_][]const u8{"-std=c99"}); +const sqlite = b.addStaticLibrary(.{ + .name = "sqlite", + .target = target, + .optimize = optimize, +}); +sqlite.addCSourceFile(.{ + .file = .{ .path = "third_party/zig-sqlite/c/sqlite3.c" }, + .flags = &[_][]const u8{ + "-std=c99", + }, +}); +sqlite.addIncludePath(.{ .path = "third_party/zig-sqlite/c" }); sqlite.linkLibC(); ``` @@ -155,8 +167,10 @@ Now it's just a matter of linking your `build.zig` target(s) to this library ins ```zig exe.linkLibrary(sqlite); -exe.addPackagePath("sqlite", "third_party/zig-sqlite/sqlite.zig"); -exe.addIncludeDir("third_party/zig-sqlite/c"); +exe.addIncludePath(.{ .path = "third_party/zig-sqlite/c" }); +exe.addAnonymousModule("sqlite", .{ + .source_file = .{ .path = "third_party/zig-sqlite/sqlite.zig" }, +}); ``` If you're building with glibc you must make sure that the version used is at least 2.28. -- cgit v1.2.3