aboutsummaryrefslogtreecommitdiff
path: root/build.zig
blob: d1d4c0c328f3fabd3767c906ba6e88a3f387013d (plain) (blame)
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
const std = @import("std");

pub fn build(b: *std.Build) void {
    const path_prefix = b.option([]const u8, "path-prefix", "The prefix which is set for porteur's data directories.") orelse b.getInstallPath(.prefix, ".");
    const version = b.option([]const u8, "version", "The version used for porteur.") orelse "dev";

    const target = b.standardTargetOptions(.{});
    const optimize = b.standardOptimizeOption(.{});

    const options = b.addOptions();
    options.addOption([]const u8, "path_prefix", path_prefix);
    options.addOption([]const u8, "version", version);

    const exe = b.addExecutable(.{
        .name = "porteur",
        .root_module = b.createModule(.{
            .root_source_file = b.path("src/main.zig"),
            .target = target,
            .optimize = optimize,
        }),
    });
    exe.root_module.addOptions("options", options);
    b.installArtifact(exe);

    const run_cmd = b.addRunArtifact(exe);
    run_cmd.step.dependOn(b.getInstallStep());
    if (b.args) |args| {
        run_cmd.addArgs(args);
    }

    const tests = b.addTest(.{
        .root_module = b.createModule(.{
            .root_source_file = b.path("src/main.zig"),
            .target = target,
            .optimize = optimize,
        }),
    });
    tests.root_module.addOptions("options", options);

    const run_test = b.addRunArtifact(tests);
    const test_step = b.step("test", "Run unit tests");
    test_step.dependOn(&run_test.step);
}