diff options
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 28 |
1 files changed, 23 insertions, 5 deletions
@@ -1929,6 +1929,19 @@ pub fn build(b: *std.Build) void { } } } + + // The test-build programs installed rather than run, for a machine the + // build cannot run them on (`-Dtarget=x86_64-freebsd.15.0`): each into + // <prefix>/test, named for its root file. + const test_install = b.step("test-install", "install the test-build programs into <prefix>/test, to run elsewhere"); + for (test_build.dependencies.items) |dep| { + const t = dep.cast(std.Build.Step.Compile) orelse continue; + const name = switch (t.root_module.root_source_file orelse continue) { + .src_path => |p| std.fs.path.stem(p.sub_path), + else => t.name, + }; + test_install.dependOn(&b.addInstallArtifact(t, .{ .dest_dir = .{ .override = .{ .custom = "test" } }, .dest_sub_path = name }).step); + } } fn testMatch(b: *std.Build, profiler: *std.Build.Step.Compile, filters: []const []const u8, step: *std.Build.Step) ?*std.Build.Step.Run { @@ -1964,7 +1977,8 @@ fn installHome(b: *std.Build, artifact: *std.Build.Step.Compile, home_bin: ?[]co /// file: ghostty opens first and checks after, and the open of a FIFO /// waits for a writer (pardes hung) while a device's open may do /// something. On Linux an O_PATH probe looks, which opens nothing, and -/// the same inode is reopened through /proc/self/fd. +/// the same inode is reopened through /proc/self/fd; elsewhere a stat by +/// path looks first. /// - shared memory is opened non-blocking and must be a regular file, so /// a FIFO in /dev/shm (or a symlink there to one) neither hangs nor maps. /// - an image may be no larger than a screen's storage @@ -1990,14 +2004,15 @@ fn patchGhosttyKitty(b: *std.Build, io: std.Io, dep: *std.Build.Dependency, vt: .{ " const fd = std.c.shm_open(pathz, @as(c_int, @bitCast(std.c.O{ .ACCMODE = .RDONLY })), @as(u16, 0));", \\ // pardes (build.zig): a FIFO there must not hang the open, and - \\ // on Linux nothing but a regular file is opened at all. + \\ // on Linux nothing but a regular file is opened at all. FreeBSD's + \\ // names are no files, and its shm_open refuses O_NONBLOCK. \\ if (comptime builtin.target.os.tag == .linux) if (path.len > 0 and path[0] == '/') { \\ var dev: [std.Io.Dir.max_path_bytes]u8 = undefined; \\ const full = std.fmt.bufPrint(&dev, "/dev/shm{s}", .{path}) catch return error.InvalidData; \\ const shm_stat = std.Io.Dir.cwd().statFile(io, full, .{}) catch return error.InvalidData; \\ if (shm_stat.kind != .file) return error.InvalidData; \\ }; - \\ const fd = std.c.shm_open(pathz, @as(c_int, @bitCast(std.c.O{ .ACCMODE = .RDONLY, .NONBLOCK = true })), @as(u16, 0)); + \\ const fd = std.c.shm_open(pathz, @as(c_int, @bitCast(std.c.O{ .ACCMODE = .RDONLY, .NONBLOCK = builtin.target.os.tag != .freebsd })), @as(u16, 0)); }, .{ " if (stat.size <= 0) return error.InvalidData;", @@ -2011,9 +2026,12 @@ fn patchGhosttyKitty(b: *std.Build, io: std.Io, dep: *std.Build.Dependency, vt: const helper = \\ \\/// pardes (build.zig): `path`, opened for reading only once it is known - \\/// to be a regular file. Elsewhere than Linux, ghostty's open as it was. + \\/// to be a regular file. Elsewhere than Linux, a stat by path first. \\fn pardesOpenRegular(io: std.Io, path: []const u8) !std.Io.File { - \\ if (comptime builtin.target.os.tag != .linux) return std.Io.Dir.cwd().openFile(io, path, .{}); + \\ if (comptime builtin.target.os.tag != .linux) { + \\ if ((try std.Io.Dir.cwd().statFile(io, path, .{})).kind != .file) return error.NotRegularFile; + \\ return std.Io.Dir.cwd().openFile(io, path, .{}); + \\ } \\ const probe = try std.Io.Dir.cwd().openFile(io, path, .{ .path_only = true }); \\ defer probe.close(io); \\ const stat = try probe.stat(io); |
