diff options
| author | patrick-scho | 2024-10-22 02:06:07 +0200 |
|---|---|---|
| committer | patrick-scho | 2024-10-22 02:06:07 +0200 |
| commit | 87c8242a16663bebfa1e2314f372ce4b4bccceaa (patch) | |
| tree | 9255d9ed5504dd1fa1e18dc30a368f76108f6f8f /build.zig | |
| parent | 1adf3709493825c0d304efb99ba520740d8d69e3 (diff) | |
| download | ziglmdb-87c8242a16663bebfa1e2314f372ce4b4bccceaa.tar.gz ziglmdb-87c8242a16663bebfa1e2314f372ce4b4bccceaa.zip | |
refactor
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 19 |
1 files changed, 16 insertions, 3 deletions
@@ -19,12 +19,12 @@ pub fn build(b: *std.Build) void { .name = "lmdb", // In this case the main source file is merely a path, however, in more // complicated build scripts, this could be a generated file. - .root_source_file = .{ .path = "src/main.zig" }, + .root_source_file = .{ .cwd_relative = "src/main.zig" }, .target = target, .optimize = optimize, }); - exe.addIncludePath(.{ .path = "./lmdb/libraries/liblmdb" }); + exe.addIncludePath(.{ .cwd_relative = "./lmdb/libraries/liblmdb" }); exe.addCSourceFiles(.{ .files = &.{ "./lmdb/libraries/liblmdb/midl.c", @@ -64,11 +64,22 @@ pub fn build(b: *std.Build) void { // Creates a step for unit testing. This only builds the test executable // but does not run it. const unit_tests = b.addTest(.{ - .root_source_file = .{ .path = "src/main.zig" }, + .root_source_file = .{ .cwd_relative = "src/main.zig" }, .target = target, .optimize = optimize, }); + unit_tests.addIncludePath(.{ .cwd_relative = "./lmdb/libraries/liblmdb" }); + + unit_tests.addCSourceFiles(.{ .files = &.{ + "./lmdb/libraries/liblmdb/midl.c", + "./lmdb/libraries/liblmdb/mdb.c", + } }); + + unit_tests.linkLibC(); + + const test_bin = b.addInstallBinFile(unit_tests.getEmittedBin(), "./lmdb_test"); + const run_unit_tests = b.addRunArtifact(unit_tests); // Similar to creating the run step earlier, this exposes a `test` step to @@ -76,4 +87,6 @@ pub fn build(b: *std.Build) void { // running the unit tests. const test_step = b.step("test", "Run unit tests"); test_step.dependOn(&run_unit_tests.step); + test_step.dependOn(&unit_tests.step); + test_step.dependOn(&test_bin.step); } |
