@@ -17,31 +17,32 @@ pub fn build(b: *std.Build) !void {
1717 const zigwin32_dep = b .dependency ("zigwin32" , .{});
1818 const nanovg_dep = b .dependency ("nanovg" , .{ .target = target , .optimize = optimize });
1919
20- // const nanovg = b.createModule(.{ .source_file = .{ .path = "deps/nanovg-zig/src/nanovg.zig" } });
21- const nanovg = nanovg_dep .module ("nanovg" );
22- const gui = b .createModule (.{ .source_file = .{ .path = "src/gui/gui.zig" }, .dependencies = &.{.{ .name = "nanovg" , .module = nanovg }} });
20+ const nanovg_mod = nanovg_dep .module ("nanovg" );
21+ const gui_mod = b .createModule (.{ .root_source_file = .{ .path = "src/gui/gui.zig" } });
22+ gui_mod .addImport ("nanovg" , nanovg_mod );
23+ const data_mod = b .createModule (.{ .root_source_file = .{ .path = "data/data.zig" } });
24+
2325
2426 const exe = b .addExecutable (.{
2527 .name = "minipixel" ,
2628 .root_source_file = .{ .path = "src/main.zig" },
27- .main_mod_path = .{ .path = "." },
2829 .target = target ,
2930 .optimize = optimize ,
3031 });
3132
3233 const exe_options = b .addOptions ();
33- exe .addOptions ("build_options" , exe_options );
34+ exe .root_module . addOptions ("build_options" , exe_options );
3435 exe_options .addOption (bool , "automated_testing" , automated_testing );
3536
3637 exe .addIncludePath (.{ .path = "lib/gl2/include" });
37- if (exe . target .isWindows () ) {
38- exe .addVcpkgPaths (.dynamic ) catch @panic ("vcpkg not installed" );
39- if (exe .vcpkg_bin_path ) | bin_path | {
40- for (&[_ ][]const u8 { "libpng16.dll" , "zlib1.dll" }) | dll | {
41- const src_dll = try std .fs .path .join (b .allocator , &.{ bin_path , dll });
42- b .installBinFile (src_dll , dll );
43- }
44- }
38+ if (target .result . os . tag == .windows ) {
39+ // exe.addVcpkgPaths(.dynamic) catch @panic("vcpkg not installed");
40+ // if (exe.vcpkg_bin_path) |bin_path| {
41+ // for (&[_][]const u8{ "libpng16.dll", "zlib1.dll" }) |dll| {
42+ // const src_dll = try std.fs.path.join(b.allocator, &.{ bin_path, dll });
43+ // b.installBinFile(src_dll, dll);
44+ // }
45+ // }
4546 exe .subsystem = .Windows ;
4647 exe .linkSystemLibrary ("shell32" );
4748 std .fs .cwd ().access ("minipixel.o" , .{}) catch {
@@ -50,7 +51,7 @@ pub fn build(b: *std.Build) !void {
5051 return error .FileNotFound ;
5152 };
5253 exe .addObjectFile (.{ .path = "minipixel.o" }); // add icon
53- } else if (exe . target .isDarwin () ) {
54+ } else if (target .result . os . tag == .macos ) {
5455 exe .addCSourceFile (.{ .file = .{ .path = "src/c/sdl_hacks.m" }, .flags = &.{} });
5556 }
5657 const c_flags : []const []const u8 = if (optimize == .Debug )
@@ -59,28 +60,27 @@ pub fn build(b: *std.Build) !void {
5960 &.{ "-std=c99" , "-D_CRT_SECURE_NO_WARNINGS" };
6061 exe .addCSourceFile (.{ .file = .{ .path = "src/c/png_image.c" }, .flags = &.{"-std=c99" } });
6162 exe .addCSourceFile (.{ .file = .{ .path = "lib/gl2/src/glad.c" }, .flags = c_flags });
62- exe .addModule ("win32" , zigwin32_dep .module ("zigwin32" ));
63- exe .addModule ("nfd" , nfd_dep .module ("nfd" ));
64- exe .addModule ("nanovg" , nanovg );
65- exe .addModule ("gui" , gui );
66- exe .linkLibrary (nanovg_dep .artifact ("nanovg" ));
67- exe .linkLibrary (nfd_dep .artifact ("nfd" ));
63+ exe .root_module .addImport ("win32" , zigwin32_dep .module ("zigwin32" ));
64+ exe .root_module .addImport ("nfd" , nfd_dep .module ("nfd" ));
65+ exe .root_module .addImport ("nanovg" , nanovg_mod );
66+ exe .root_module .addImport ("gui" , gui_mod );
67+ exe .root_module .addImport ("data" , data_mod );
6868 exe .linkLibrary (sdl_dep .artifact ("SDL2" ));
69- if (exe . target .isWindows () ) {
69+ if (target .result . os . tag == .windows ) {
7070 // Workaround for CI: Zig detects pkg-config and resolves -lpng16 which doesn't exist
71- exe .linkSystemLibraryName ("libpng16" );
72- } else if (exe . target .isDarwin () ) {
71+ exe .linkSystemLibrary ("libpng16" );
72+ } else if (target .result . os . tag == .macos ) {
7373 exe .addIncludePath (.{ .path = "/opt/homebrew/include" });
7474 exe .addLibraryPath (.{ .path = "/opt/homebrew/lib" });
7575 exe .linkSystemLibrary ("png" );
7676 } else {
7777 exe .linkSystemLibrary ("libpng16" );
7878 }
79- if (exe . target .isDarwin () ) {
79+ if (target .result . os . tag == .macos ) {
8080 exe .linkFramework ("OpenGL" );
81- } else if (exe . target .isWindows () ) {
81+ } else if (target .result . os . tag == .windows ) {
8282 exe .linkSystemLibrary ("opengl32" );
83- } else if (exe . target .isLinux () ) {
83+ } else if (target .result . os . tag == .linux ) {
8484 exe .linkSystemLibrary ("gl" );
8585 exe .linkSystemLibrary ("X11" );
8686 }
0 commit comments