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); // Widgets demo const widgets_exe = b.addExecutable(.{ .name = "widgets-demo", .root_module = b.createModule(.{ .root_source_file = b.path("examples/widgets_demo.zig"), .target = target, .optimize = optimize, .link_libc = true, .imports = &.{ .{ .name = "zcatgui", .module = zcatgui_mod }, }, }), }); widgets_exe.root_module.linkSystemLibrary("SDL2", .{}); b.installArtifact(widgets_exe); const run_widgets = b.addRunArtifact(widgets_exe); run_widgets.step.dependOn(b.getInstallStep()); const widgets_step = b.step("widgets-demo", "Run widgets demo"); widgets_step.dependOn(&run_widgets.step); // Table demo const table_exe = b.addExecutable(.{ .name = "table-demo", .root_module = b.createModule(.{ .root_source_file = b.path("examples/table_demo.zig"), .target = target, .optimize = optimize, .link_libc = true, .imports = &.{ .{ .name = "zcatgui", .module = zcatgui_mod }, }, }), }); table_exe.root_module.linkSystemLibrary("SDL2", .{}); b.installArtifact(table_exe); const run_table = b.addRunArtifact(table_exe); run_table.step.dependOn(b.getInstallStep()); const table_step = b.step("table-demo", "Run table demo with split panels"); table_step.dependOn(&run_table.step); }