hey, trying to build a C project in zig. it builds fine but it doesnt seem to link it to the tests?
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const upstream = b.dependency("upstream", .{});
const lib_mod = b.createModule(.{
.target = target,
.optimize = optimize,
.link_libc = true,
.strip = false,
});
lib_mod.addCSourceFile(.{
.file = upstream.path("src/yyjson.c"),
.flags = &.{
"-std=c99",
},
});
lib_mod.addIncludePath(upstream.path("src"));
const lib = b.addLibrary(.{
.linkage = .static,
.name = "yyjson",
.root_module = lib_mod,
});
lib.installHeader(upstream.path("src/yyjson.h"), "yyjson.h");
b.installArtifact(lib);
const tests_mod = b.createModule(.{
.root_source_file = b.path("tests.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
});
tests_mod.addIncludePath(upstream.path("src"));
tests_mod.linkLibrary(lib);
const unit_tests = b.addTest(.{
.root_module = tests_mod,
});
const run_unit_tests = b.addRunArtifact(unit_tests);
const test_step = b.step("test", "run tests");
test_step.dependOn(&run_unit_tests.step);
}
am i doing something stupid?
