@@ -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,12 @@ 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 );
46
40
47
41
const test_step = b .step ("test" , "Run zstbi tests" );
48
42
@@ -52,7 +46,7 @@ pub fn build(b: *std.Build) void {
52
46
.target = target ,
53
47
.optimize = optimize ,
54
48
});
55
- tests .linkLibrary ( zstbi_lib );
49
+ tests .root_module . addImport ( "zstbi" , zstbi );
56
50
b .installArtifact (tests );
57
51
58
52
test_step .dependOn (& b .addRunArtifact (tests ).step );
0 commit comments