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 zg_dep = b.dependency("zg", .{
10 .optimize = optimize,
11 .target = target,
12 });
13 const zigimg_dep = b.dependency("zigimg", .{
14 .optimize = optimize,
15 .target = target,
16 });
17
18 // Module
19 const vaxis_mod = b.addModule("vaxis", .{
20 .root_source_file = root_source_file,
21 .target = target,
22 .optimize = optimize,
23 });
24 vaxis_mod.addImport("code_point", zg_dep.module("code_point"));
25 vaxis_mod.addImport("grapheme", zg_dep.module("grapheme"));
26 vaxis_mod.addImport("DisplayWidth", zg_dep.module("DisplayWidth"));
27 vaxis_mod.addImport("zigimg", zigimg_dep.module("zigimg"));
28
29 // Examples
30 const Example = enum {
31 cli,
32 counter,
33 fuzzy,
34 image,
35 main,
36 scroll,
37 split_view,
38 table,
39 text_input,
40 vaxis,
41 view,
42 vt,
43 };
44 const example_option = b.option(Example, "example", "Example to run (default: text_input)") orelse .text_input;
45 const example_step = b.step("example", "Run example");
46 const example = b.addExecutable(.{
47 .name = "example",
48 // future versions should use b.path, see zig PR #19597
49 .root_source_file = b.path(
50 b.fmt("examples/{s}.zig", .{@tagName(example_option)}),
51 ),
52 .target = target,
53 .optimize = optimize,
54 });
55 example.root_module.addImport("vaxis", vaxis_mod);
56
57 const example_run = b.addRunArtifact(example);
58 example_step.dependOn(&example_run.step);
59
60 // Tests
61 const tests_step = b.step("test", "Run tests");
62
63 const tests = b.addTest(.{
64 .root_source_file = b.path("src/main.zig"),
65 .target = target,
66 .optimize = optimize,
67 });
68 tests.root_module.addImport("code_point", zg_dep.module("code_point"));
69 tests.root_module.addImport("grapheme", zg_dep.module("grapheme"));
70 tests.root_module.addImport("DisplayWidth", zg_dep.module("DisplayWidth"));
71 tests.root_module.addImport("zigimg", zigimg_dep.module("zigimg"));
72
73 const tests_run = b.addRunArtifact(tests);
74 b.installArtifact(tests);
75 tests_step.dependOn(&tests_run.step);
76
77 // Docs
78 const docs_step = b.step("docs", "Build the vaxis library docs");
79 const docs_obj = b.addObject(.{
80 .name = "vaxis",
81 .root_source_file = root_source_file,
82 .target = target,
83 .optimize = optimize,
84 });
85 const docs = docs_obj.getEmittedDocs();
86 docs_step.dependOn(&b.addInstallDirectory(.{
87 .source_dir = docs,
88 .install_dir = .prefix,
89 .install_subdir = "docs",
90 }).step);
91}