@@ -4,19 +4,14 @@ pub fn build(b: *std.Build) void {
4
4
const optimize = b .standardOptimizeOption (.{});
5
5
const target = b .standardTargetOptions (.{});
6
6
7
- _ = b .addModule ("root" , .{
7
+ const zstbi = b .addModule ("root" , .{
8
8
.root_source_file = b .path ("src/zstbi.zig" ),
9
9
});
10
10
11
- const zstbi_lib = b .addStaticLibrary (.{
12
- .name = "zstbi" ,
13
- .target = target ,
14
- .optimize = optimize ,
15
- });
16
- zstbi_lib .addIncludePath (b .path ("libs/stbi" ));
11
+ zstbi .addIncludePath (b .path ("libs/stbi" ));
17
12
if (optimize == .Debug ) {
18
13
// TODO: Workaround for Zig bug.
19
- zstbi_lib .addCSourceFile (.{
14
+ zstbi .addCSourceFile (.{
20
15
.file = b .path ("src/zstbi.c" ),
21
16
.flags = &.{
22
17
"-std=c99" ,
@@ -26,7 +21,7 @@ pub fn build(b: *std.Build) void {
26
21
},
27
22
});
28
23
} else {
29
- zstbi_lib .addCSourceFile (.{
24
+ zstbi .addCSourceFile (.{
30
25
.file = b .path ("src/zstbi.c" ),
31
26
.flags = &.{
32
27
"-std=c99" ,
@@ -36,13 +31,13 @@ pub fn build(b: *std.Build) void {
36
31
}
37
32
38
33
if (target .result .os .tag == .emscripten ) {
39
- zstbi_lib .addIncludePath (.{
34
+ zstbi .addIncludePath (.{
40
35
.cwd_relative = b .pathJoin (&.{ b .sysroot .? , "/include" }),
41
36
});
42
37
} else {
43
- zstbi_lib . linkLibC () ;
38
+ zstbi . link_libc = true ;
44
39
}
45
- b .installArtifact (zstbi_lib );
40
+ b .installArtifact (zstbi );
46
41
47
42
const test_step = b .step ("test" , "Run zstbi tests" );
48
43
@@ -52,7 +47,7 @@ pub fn build(b: *std.Build) void {
52
47
.target = target ,
53
48
.optimize = optimize ,
54
49
});
55
- tests .linkLibrary ( zstbi_lib );
50
+ tests .root_module . addImport ( "zstbi" , zstbi );
56
51
b .installArtifact (tests );
57
52
58
53
test_step .dependOn (& b .addRunArtifact (tests ).step );
0 commit comments