1const std = @import("std");
2
3pub const requires_symlinks = true;
4
5pub fn build(b: *std.Build) void {
6 const test_step = b.step("test", "Test it");
7 b.default_step = test_step;
8
9 const optimize: std.builtin.Optimize = .debug;
10 const target = b.graph.host;
11
12 if (target.result.os.tag == .netbsd) return; // F_GETPATH not reliable
13 if (target.result.os.tag == .openbsd) return; // F_GETPATH not supported
14
15 const main = b.addExecutable(.{
16 .name = "main",
17 .root_module = b.createModule(.{
18 .root_source_file = b.path("main.zig"),
19 .optimize = optimize,
20 .target = target,
21 }),
22 });
23
24 const create_symlink_exe = b.addExecutable(.{
25 .name = "create-symlink",
26 .root_module = b.createModule(.{
27 .root_source_file = b.path("create-symlink.zig"),
28 .optimize = optimize,
29 .target = target,
30 }),
31 });
32
33 var run_create_symlink = b.addRunArtifact(create_symlink_exe);
34 run_create_symlink.addArtifactArg(main);
35 const symlink_path = run_create_symlink.addOutputFileArg("main-symlink");
36 run_create_symlink.expectExitCode(0);
37 run_create_symlink.skip_foreign_checks = true;
38
39 var run_from_symlink = std.Build.Step.Run.create(b, "run symlink");
40 run_from_symlink.addFileArg(symlink_path);
41 run_from_symlink.expectExitCode(0);
42 run_from_symlink.skip_foreign_checks = true;
43 run_from_symlink.step.dependOn(&run_create_symlink.step);
44
45 test_step.dependOn(&run_from_symlink.step);
46}