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 table,
37 text_input,
38 vaxis,
39 view,
40 vt,
41 };
42 const example_option = b.option(Example, "example", "Example to run (default: text_input)") orelse .text_input;
43 const example_step = b.step("example", "Run example");
44 const example = b.addExecutable(.{
45 .name = "example",
46 // future versions should use b.path, see zig PR #19597
47 .root_source_file = b.path(
48 b.fmt("examples/{s}.zig", .{@tagName(example_option)}),
49 ),
50 .target = target,
51 .optimize = optimize,
52 });
53 example.root_module.addImport("vaxis", vaxis_mod);
54
55 const example_run = b.addRunArtifact(example);
56 example_step.dependOn(&example_run.step);
57
58 // Tests
59 const tests_step = b.step("test", "Run tests");
60
61 const tests = b.addTest(.{
62 .root_source_file = b.path("src/main.zig"),
63 .target = target,
64 .optimize = optimize,
65 });
66 tests.root_module.addImport("code_point", zg_dep.module("code_point"));
67 tests.root_module.addImport("grapheme", zg_dep.module("grapheme"));
68 tests.root_module.addImport("DisplayWidth", zg_dep.module("DisplayWidth"));
69 tests.root_module.addImport("zigimg", zigimg_dep.module("zigimg"));
70
71 const tests_run = b.addRunArtifact(tests);
72 b.installArtifact(tests);
73 tests_step.dependOn(&tests_run.step);
74
75 // Docs
76 const docs_step = b.step("docs", "Build the vaxis library docs");
77 const docs_obj = b.addObject(.{
78 .name = "vaxis",
79 .root_source_file = root_source_file,
80 .target = target,
81 .optimize = optimize,
82 });
83 const docs = docs_obj.getEmittedDocs();
84 docs_step.dependOn(&b.addInstallDirectory(.{
85 .source_dir = docs,
86 .install_dir = .prefix,
87 .install_subdir = "docs",
88 }).step);
89}