master
1const std = @import("std");
2
3pub fn build(b: *std.Build) void {
4 const test_step = b.step("test", "Test it");
5 b.default_step = test_step;
6
7 const optimize: std.builtin.OptimizeMode = .Debug;
8
9 const foo = b.addLibrary(.{
10 .linkage = .static,
11 .name = "foo",
12 .root_module = b.createModule(.{
13 .root_source_file = null,
14 .optimize = optimize,
15 .target = b.graph.host,
16 }),
17 });
18 foo.root_module.addCSourceFile(.{ .file = b.path("foo.c"), .flags = &[_][]const u8{} });
19 foo.root_module.addIncludePath(b.path("."));
20
21 const test_exe = b.addTest(.{ .root_module = b.createModule(.{
22 .root_source_file = b.path("foo.zig"),
23 .target = b.graph.host,
24 .optimize = optimize,
25 }) });
26 test_exe.root_module.linkLibrary(foo);
27 test_exe.root_module.addIncludePath(b.path("."));
28
29 test_step.dependOn(&b.addRunArtifact(test_exe).step);
30}