const std = @import("std"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); const root_source_file = b.path("src/main.zig"); // Dependencies const zigimg_dep = b.dependency("zigimg", .{ .optimize = optimize, .target = target, }); const uucode_dep = b.dependency("uucode", .{ .target = target, .optimize = optimize, .fields = @as([]const []const u8, &.{ "east_asian_width", "grapheme_break", "general_category", "is_emoji_presentation", }), }); // Module const vaxis_mod = b.addModule("vaxis", .{ .root_source_file = root_source_file, .target = target, .optimize = optimize, }); vaxis_mod.addImport("zigimg", zigimg_dep.module("zigimg")); vaxis_mod.addImport("uucode", uucode_dep.module("uucode")); // Examples const Example = enum { cli, counter, fuzzy, image, main, scroll, split_view, table, text_input, vaxis, view, vt, }; const example_option = b.option(Example, "example", "Example to run (default: text_input)") orelse .text_input; const example_step = b.step("example", "Run example"); const example = b.addExecutable(.{ .name = "example", .root_module = b.createModule(.{ .root_source_file = b.path( b.fmt("examples/{s}.zig", .{@tagName(example_option)}), ), .target = target, .optimize = optimize, .imports = &.{ .{ .name = "vaxis", .module = vaxis_mod }, }, }), }); const example_run = b.addRunArtifact(example); example_step.dependOn(&example_run.step); // Tests const tests_step = b.step("test", "Run tests"); const tests = b.addTest(.{ .root_module = b.createModule(.{ .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, .imports = &.{ .{ .name = "zigimg", .module = zigimg_dep.module("zigimg") }, .{ .name = "uucode", .module = uucode_dep.module("uucode") }, }, }), }); const tests_run = b.addRunArtifact(tests); b.installArtifact(tests); tests_step.dependOn(&tests_run.step); // Docs const docs_step = b.step("docs", "Build the vaxis library docs"); const docs_obj = b.addObject(.{ .name = "vaxis", .root_module = b.createModule(.{ .root_source_file = root_source_file, .target = target, .optimize = optimize, }), }); const docs = docs_obj.getEmittedDocs(); docs_step.dependOn(&b.addInstallDirectory(.{ .source_dir = docs, .install_dir = .prefix, .install_subdir = "docs", }).step); }