Something went wrong. Try again.
A charm-like tui library
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153const std = @import("std");const Build = std.Build;const Module = Build.Module;const Import = Module.Import;const Dir = std.Io.Dir;
pub fn build(b: *Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{});
const infrared = b.addModule("infrared", .{ .root_source_file = b.path("infrared/root.zig"), .target = target, .optimize = optimize, }); try addTest(b, "infrared", infrared);
const matte = b.addModule("matte", .{ .root_source_file = b.path("matte/root.zig"), .target = target, .imports = &.{ import("infrared", infrared), }, }); try addTest(b, "matte", matte);
const black_tea = b.addModule("blacktea", .{ .root_source_file = b.path("blacktea/root.zig"), .target = target, .link_libc = true, }); try addTest(b, "blacktea", black_tea);
const buds = b.addModule("buds", .{ .root_source_file = b.path("buds/root.zig"), .target = target, .imports = &.{ import("blacktea", black_tea), import("matte", matte), }, }); try addTest(b, "buds", buds);
const zli = b.addModule("zli", .{ .root_source_file = b.path("zli/root.zig"), .target = target, .optimize = optimize, .imports = &.{ import("matte", matte), }, }); try addTest(b, "zli", zli);
const c = b.addTranslateC(.{ .root_source_file = b.path("curse/libssh.h"), .target = target, .optimize = optimize, });
c.linkSystemLibrary("libssh", .{ .use_pkg_config = .yes, .needed = true, .preferred_link_mode = .dynamic, });
const libssh = c.createModule();
const curse = b.addModule("curse", .{ .root_source_file = b.path("curse/root.zig"), .target = target, .optimize = optimize, .link_libc = true, .imports = &.{ import("blacktea", black_tea), import("zli", zli), import("libssh", libssh), import("infrared", infrared), }, }); try addTest(b, "curse", curse);
const demo = b.addExecutable(.{ .name = "demo", .linkage = .dynamic, .version = .{ .major = 0, .minor = 0, .patch = 0 }, .root_module = b.createModule( .{ .root_source_file = b.path("demo/main.zig"), .target = target, .optimize = optimize, .link_libc = true, .imports = &.{ import("matte", matte), import("buds", buds), import("blacktea", black_tea), import("curse", curse), import("zli", zli), import("libssh", libssh), }, }, ), }); const demo_step = b.step("demo", "run demo"); demo_step.dependOn(&b.addInstallArtifact(demo, .{}).step);
b.installArtifact(demo);
const run_step = b.step("run", "Run the app");
const run_cmd = b.addRunArtifact(demo); run_step.dependOn(&run_cmd.step);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| { run_cmd.addArgs(args); }}
fn import(name: []const u8, module: *Module) Import { return .{ .name = name, .module = module };}
fn addTest(b: *Build, name: []const u8, module: *Module) !void { const step = if (b.top_level_steps.get("test")) |tls| &tls.step else b.step("test", "Run tests"); const test_module = b.addTest(.{ .name = name, .root_module = module, .filters = try testFilters(b), }); const artifact = b.addRunArtifact(test_module); step.dependOn(&artifact.step);}
fn testFilters(b: *Build) ![]const []const u8 { if (!b.available_options_map.contains("test-filter")) return b.option( []const []const u8, "test-filter", "Skip tests that do not match any filter", ) orelse &.{};
const opt = b.user_input_options.getPtr("test-filter") orelse return &.{}; opt.used = true; return switch (opt.value) { .list => |l| l.items, .scalar => |s| try b.allocator.dupe([]const u8, &.{s}), else => &.{}, };}