summaryrefslogtreecommitdiff
path: root/src/build/GhosttyBench.zig
blob: c9cd5dd3375b48cf00493321d22edc4f05f1ac4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! GhosttyBench generates all the Ghostty benchmark helper binaries.
const GhosttyBench = @This();

const std = @import("std");
const Config = @import("Config.zig");
const SharedDeps = @import("SharedDeps.zig");

steps: []*std.Build.Step.Compile,

pub fn init(
    b: *std.Build,
    deps: *const SharedDeps,
) !GhosttyBench {
    var steps: std.ArrayList(*std.Build.Step.Compile) = .empty;
    errdefer steps.deinit(b.allocator);

    // Our synthetic data generator
    {
        const exe = b.addExecutable(.{
            .name = "ghostty-gen",
            .root_module = b.createModule(.{
                .root_source_file = b.path("src/main_gen.zig"),
                .target = deps.config.target,
                // We always want our datagen to be fast because it
                // takes awhile to run.
                .optimize = .ReleaseFast,
            }),
        });
        exe.linkLibC();
        _ = try deps.add(exe);
        try steps.append(b.allocator, exe);
    }

    // Our benchmarking application.
    {
        const exe = b.addExecutable(.{
            .name = "ghostty-bench",
            .root_module = b.createModule(.{
                .root_source_file = b.path("src/main_bench.zig"),
                .target = deps.config.target,
                // We always want our benchmarks to be in release mode.
                .optimize = .ReleaseFast,
            }),
        });
        exe.linkLibC();
        _ = try deps.add(exe);
        try steps.append(b.allocator, exe);
    }

    return .{ .steps = steps.items };
}

pub fn install(self: *const GhosttyBench) void {
    const b = self.steps[0].step.owner;
    for (self.steps) |step| b.installArtifact(step);
}