forked from zig-gamedev/zig-gamedev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.zig
52 lines (46 loc) · 1.37 KB
/
build.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const std = @import("std");
pub fn build(b: *std.Build) void {
const optimize = b.standardOptimizeOption(.{});
const target = b.standardTargetOptions(.{});
_ = b.addModule("root", .{
.root_source_file = b.path("src/zstbi.zig"),
});
const zstbi_lib = b.addStaticLibrary(.{
.name = "zstbi",
.target = target,
.optimize = optimize,
});
zstbi_lib.addIncludePath(b.path("libs/stbi"));
if (optimize == .Debug) {
// TODO: Workaround for Zig bug.
zstbi_lib.addCSourceFile(.{
.file = b.path("src/zstbi.c"),
.flags = &.{
"-std=c99",
"-fno-sanitize=undefined",
"-g",
"-O0",
},
});
} else {
zstbi_lib.addCSourceFile(.{
.file = b.path("src/zstbi.c"),
.flags = &.{
"-std=c99",
"-fno-sanitize=undefined",
},
});
}
zstbi_lib.linkLibC();
b.installArtifact(zstbi_lib);
const test_step = b.step("test", "Run zstbi tests");
const tests = b.addTest(.{
.name = "zstbi-tests",
.root_source_file = b.path("src/zstbi.zig"),
.target = target,
.optimize = optimize,
});
tests.linkLibrary(zstbi_lib);
b.installArtifact(tests);
test_step.dependOn(&b.addRunArtifact(tests).step);
}