aboutsummaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authortsne <tsne.dev@outlook.com>2025-01-01 14:58:28 +0100
committertsne <tsne.dev@outlook.com>2025-10-30 08:32:49 +0100
commit44e5ad763794a438ecfd50c8b7f6ea760ea82da5 (patch)
tree575a1fc72ceb1d7f052cf582abc1e038e27f69a3 /build.zig
downloadporteur-main.tar.gz
initial commitHEADmain
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig45
1 files changed, 45 insertions, 0 deletions
diff --git a/build.zig b/build.zig
new file mode 100644
index 0000000..f93974d
--- /dev/null
+++ b/build.zig
@@ -0,0 +1,45 @@
+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 target = b.standardTargetOptions(.{});
+ const optimize = b.standardOptimizeOption(.{});
+
+ const options = b.addOptions();
+ options.addOption([]const u8, "path_prefix", path_prefix);
+
+ 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);
+
+ const clean_step = b.step("clean", "Clean up");
+ clean_step.dependOn(&b.addRemoveDirTree(.{ .cwd_relative = b.install_path }).step);
+ clean_step.dependOn(&b.addRemoveDirTree(.{ .cwd_relative = b.pathFromRoot("zig-cache") }).step);
+}