this repo has no description
1const std = @import("std");
2
3pub fn build(b: *std.Build) void {
4 const target = b.standardTargetOptions(.{});
5 const optimize = b.standardOptimizeOption(.{});
6 const root_source_file = b.path("src/main.zig");
7
8 // Dependencies
9 const zigimg_dep = b.dependency("zigimg", .{
10 .optimize = optimize,
11 .target = target,
12 });
13 const uucode_dep = b.dependency("uucode", .{
14 .target = target,
15 .optimize = optimize,
16 .fields = @as([]const []const u8, &.{
17 "east_asian_width",
18 "grapheme_break",
19 "general_category",
20 "is_emoji_presentation",
21 }),
22 });
23
24 // Module
25 const vaxis_mod = b.addModule("vaxis", .{
26 .root_source_file = root_source_file,
27 .target = target,
28 .optimize = optimize,
29 });
30 vaxis_mod.addImport("zigimg", zigimg_dep.module("zigimg"));
31 vaxis_mod.addImport("uucode", uucode_dep.module("uucode"));
32
33 // Examples
34 const Example = enum {
35 cli,
36 counter,
37 fuzzy,
38 image,
39 main,
40 scroll,
41 split_view,
42 table,
43 text_input,
44 vaxis,
45 view,
46 vt,
47 };
48 const example_option = b.option(Example, "example", "Example to run (default: text_input)") orelse .text_input;
49 const example_step = b.step("example", "Run example");
50 const example = b.addExecutable(.{
51 .name = "example",
52 .root_module = b.createModule(.{
53 .root_source_file = b.path(
54 b.fmt("examples/{s}.zig", .{@tagName(example_option)}),
55 ),
56 .target = target,
57 .optimize = optimize,
58 .imports = &.{
59 .{ .name = "vaxis", .module = vaxis_mod },
60 },
61 }),
62 });
63
64 const example_run = b.addRunArtifact(example);
65 example_step.dependOn(&example_run.step);
66
67 // Tests
68 const tests_step = b.step("test", "Run tests");
69
70 const tests = b.addTest(.{
71 .root_module = b.createModule(.{
72 .root_source_file = b.path("src/main.zig"),
73 .target = target,
74 .optimize = optimize,
75 .imports = &.{
76 .{ .name = "zigimg", .module = zigimg_dep.module("zigimg") },
77 .{ .name = "uucode", .module = uucode_dep.module("uucode") },
78 },
79 }),
80 });
81
82 const tests_run = b.addRunArtifact(tests);
83 b.installArtifact(tests);
84 tests_step.dependOn(&tests_run.step);
85
86 // Docs
87 const docs_step = b.step("docs", "Build the vaxis library docs");
88 const docs_obj = b.addObject(.{
89 .name = "vaxis",
90 .root_module = b.createModule(.{
91 .root_source_file = root_source_file,
92 .target = target,
93 .optimize = optimize,
94 }),
95 });
96 const docs = docs_obj.getEmittedDocs();
97 docs_step.dependOn(&b.addInstallDirectory(.{
98 .source_dir = docs,
99 .install_dir = .prefix,
100 .install_subdir = "docs",
101 }).step);
102}