@@ -4,19 +4,14 @@ pub fn build(b: *std.Build) void {
44 const optimize = b .standardOptimizeOption (.{});
55 const target = b .standardTargetOptions (.{});
66
7- _ = b .addModule ("root" , .{
7+ const zstbi = b .addModule ("root" , .{
88 .root_source_file = b .path ("src/zstbi.zig" ),
99 });
1010
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" ));
1712 if (optimize == .Debug ) {
1813 // TODO: Workaround for Zig bug.
19- zstbi_lib .addCSourceFile (.{
14+ zstbi .addCSourceFile (.{
2015 .file = b .path ("src/zstbi.c" ),
2116 .flags = &.{
2217 "-std=c99" ,
@@ -26,7 +21,7 @@ pub fn build(b: *std.Build) void {
2621 },
2722 });
2823 } else {
29- zstbi_lib .addCSourceFile (.{
24+ zstbi .addCSourceFile (.{
3025 .file = b .path ("src/zstbi.c" ),
3126 .flags = &.{
3227 "-std=c99" ,
@@ -36,13 +31,12 @@ pub fn build(b: *std.Build) void {
3631 }
3732
3833 if (target .result .os .tag == .emscripten ) {
39- zstbi_lib .addIncludePath (.{
34+ zstbi .addIncludePath (.{
4035 .cwd_relative = b .pathJoin (&.{ b .sysroot .? , "/include" }),
4136 });
4237 } else {
43- zstbi_lib . linkLibC () ;
38+ zstbi . link_libc = true ;
4439 }
45- b .installArtifact (zstbi_lib );
4640
4741 const test_step = b .step ("test" , "Run zstbi tests" );
4842
@@ -52,7 +46,7 @@ pub fn build(b: *std.Build) void {
5246 .target = target ,
5347 .optimize = optimize ,
5448 });
55- tests .linkLibrary ( zstbi_lib );
49+ tests .root_module . addImport ( "zstbi" , zstbi );
5650 b .installArtifact (tests );
5751
5852 test_step .dependOn (& b .addRunArtifact (tests ).step );
0 commit comments