Skip to content

Commit

Permalink
make the build work with zig 0.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
vrischmann committed Dec 22, 2024
1 parent 2a6b0fc commit 5f2a630
Showing 1 changed file with 11 additions and 21 deletions.
32 changes: 11 additions & 21 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,21 @@ pub fn build(b: *std.Build) void {
.optimize = optimize,
});

const mod = b.createModule(.{
const lib = b.addStaticLibrary(.{
.name = "picohttpparser",
.target = target,
.optimize = optimize,
.link_libc = true,
.single_threaded = true,
.sanitize_c = true,
});
mod.addIncludePath(b.path("."));
mod.addCSourceFiles(.{
lib.addIncludePath(b.path("."));
lib.addCSourceFiles(.{
.root = upstream.path("."),
.files = &[_][]const u8{
"picohttpparser.c",
},
.flags = c_flags,
});

const lib = b.addStaticLibrary(.{
.name = "picohttpparser",
.root_module = mod,
});
lib.linkLibC();
lib.installHeader(upstream.path("picohttpparser.h"), "picohttpparser.h");
b.installArtifact(lib);
Expand All @@ -58,36 +53,31 @@ pub fn build(b: *std.Build) void {
const wf = b.addWriteFiles();
_ = wf.addCopyFile(picotest.path("picotest.h"), "picotest/picotest.h");

const test_module = b.createModule(.{
const test_bin = b.addExecutable(.{
.name = "test-bin",
.target = target,
.optimize = optimize,
.link_libc = true,
.single_threaded = true,
.sanitize_c = true,
});
test_module.linkLibrary(lib);
test_module.addIncludePath(upstream.path("."));
test_module.addIncludePath(wf.getDirectory());
test_module.addCSourceFiles(.{
test_bin.linkLibrary(lib);
test_bin.addIncludePath(upstream.path("."));
test_bin.addIncludePath(wf.getDirectory());
test_bin.addCSourceFiles(.{
.root = picotest.path("."),
.files = &[_][]const u8{
"picotest.c",
},
.flags = c_flags,
});
test_module.addCSourceFiles(.{
test_bin.addCSourceFiles(.{
.root = upstream.path("."),
.files = &[_][]const u8{
"test.c",
},
.flags = c_flags,
});

const test_bin = b.addExecutable(.{
.name = "test-bin",
.root_module = test_module,
});

const run_tests = b.addRunArtifact(test_bin);
run_tests.step.dependOn(&wf.step);

Expand Down

0 comments on commit 5f2a630

Please sign in to comment.