Something went wrong. Try again.
A charm-like tui library
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129const 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 blush = b.addModule("blush", .{ .root_source_file = b.path("blush/root.zig"), .target = target, }); try addTest(b, "blush", blush);
const matcha = b.addModule("matcha", .{ .root_source_file = b.path("matcha/root.zig"), .target = target, .link_libc = true, }); try addTest(b, "matcha", matcha);
const leaves = b.addModule("leaves", .{ .root_source_file = b.path("leaves/root.zig"), .target = target, .imports = &.{ import("matcha", matcha), import("blush", blush), }, }); try addTest(b, "leaves", leaves);
const zli = b.addModule("zli", .{ .root_source_file = b.path("zli/root.zig"), .target = target, .optimize = optimize, .imports = &.{ import("blush", blush), }, }); try addTest(b, "zli", zli);
const c = b.addTranslateC(.{ .root_source_file = b.path("dream/libssh.h"), .target = target, .optimize = optimize, });
c.linkSystemLibrary("libssh", .{ .use_pkg_config = .yes, .needed = true, .preferred_link_mode = .dynamic, });
const libssh = c.createModule();
const dream = b.addModule("dream", .{ .root_source_file = b.path("dream/root.zig"), .target = target, .optimize = optimize, .link_libc = true, .imports = &.{ import("matcha", matcha), import("zli", zli), import("libssh", libssh), }, }); try addTest(b, "dream", dream);
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("blush", blush), import("leaves", leaves), import("matcha", matcha), import("dream", dream), import("zli", zli), import("libssh", libssh), }, }, ), }); const demo_step = b.step("demo", "run demo"); demo_step.dependOn(&b.addInstallArtifact(demo, .{}).step);}
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 => &.{}, };}