const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); // =========================================== // Main library module // =========================================== const zcatgui_mod = b.createModule(.{ .root_source_file = b.path("src/zcatgui.zig"), .target = target, .optimize = optimize, .link_libc = true, }); // Link SDL2 to the module zcatgui_mod.linkSystemLibrary("SDL2", .{}); // =========================================== // Tests // =========================================== const lib_unit_tests = b.addTest(.{ .root_module = b.createModule(.{ .root_source_file = b.path("src/zcatgui.zig"), .target = target, .optimize = optimize, .link_libc = true, }), }); lib_unit_tests.root_module.linkSystemLibrary("SDL2", .{}); const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests); const test_step = b.step("test", "Run unit tests"); test_step.dependOn(&run_lib_unit_tests.step); // =========================================== // Examples // =========================================== // Hello World example const hello_exe = b.addExecutable(.{ .name = "hello", .root_module = b.createModule(.{ .root_source_file = b.path("examples/hello.zig"), .target = target, .optimize = optimize, .link_libc = true, .imports = &.{ .{ .name = "zcatgui", .module = zcatgui_mod }, }, }), }); hello_exe.root_module.linkSystemLibrary("SDL2", .{}); b.installArtifact(hello_exe); const run_hello = b.addRunArtifact(hello_exe); run_hello.step.dependOn(b.getInstallStep()); const hello_step = b.step("hello", "Run hello world example"); hello_step.dependOn(&run_hello.step); // Macro demo const macro_exe = b.addExecutable(.{ .name = "macro-demo", .root_module = b.createModule(.{ .root_source_file = b.path("examples/macro_demo.zig"), .target = target, .optimize = optimize, .link_libc = true, .imports = &.{ .{ .name = "zcatgui", .module = zcatgui_mod }, }, }), }); macro_exe.root_module.linkSystemLibrary("SDL2", .{}); b.installArtifact(macro_exe); const run_macro = b.addRunArtifact(macro_exe); run_macro.step.dependOn(b.getInstallStep()); const macro_step = b.step("macro-demo", "Run macro recording demo"); macro_step.dependOn(&run_macro.step); }