diff options
| author | Isaac Freund <ifreund@ifreund.xyz> | 2021-03-22 11:54:02 +0100 |
|---|---|---|
| committer | Isaac Freund <ifreund@ifreund.xyz> | 2021-03-22 11:54:51 +0100 |
| commit | 6438f193ae709115dafb76a0c7488416ae78cee5 (patch) | |
| tree | d411fe2bf4fcce7363fcf3d6375f383207f620b3 | |
| parent | 8627a2fefffaf0195c0e1d85b899d95e3ae5e851 (diff) | |
| download | river-6438f193ae709115dafb76a0c7488416ae78cee5.tar.gz river-6438f193ae709115dafb76a0c7488416ae78cee5.tar.xz | |
build: handle null install_prefix correctly
| -rw-r--r-- | build.zig | 26 | ||||
| m--------- | deps/zig-wayland | 0 |
2 files changed, 15 insertions, 11 deletions
@@ -1,4 +1,5 @@ const std = @import("std"); +const fs = std.fs; const zbs = std.build; const ScanProtocolsStep = @import("deps/zig-wayland/build.zig").ScanProtocolsStep; @@ -45,16 +46,19 @@ pub fn build(b: *zbs.Builder) !void { const examples = b.option(bool, "examples", "Set to true to build examples") orelse false; - const resolved_prefix = try std.fs.path.resolve(b.allocator, &[_][]const u8{b.install_prefix.?}); - const rel_config_path = if (std.mem.eql(u8, resolved_prefix, "/usr")) - "../etc/river/init" - else - "etc/river/init"; + const rel_config_path = blk: { + if (b.install_prefix) |prefix| { + if (std.mem.eql(u8, try fs.path.resolve(b.allocator, &[_][]const u8{prefix}), "/usr")) { + break :blk "../etc/river/init"; + } + } + break :blk "etc/river/init"; + }; b.installFile("example/init", rel_config_path); - const default_config_path = try std.fs.path.resolve( - b.allocator, - &[_][]const u8{ resolved_prefix, rel_config_path }, - ); + const abs_config_path = try fs.path.resolve(b.allocator, &[_][]const u8{ + b.install_prefix orelse b.cache_root, + rel_config_path, + }); const scanner = ScanProtocolsStep.create(b); scanner.addSystemProtocol("stable/xdg-shell/xdg-shell.xml"); @@ -72,7 +76,7 @@ pub fn build(b: *zbs.Builder) !void { river.setTarget(target); river.setBuildMode(mode); river.addBuildOption(bool, "xwayland", xwayland); - river.addBuildOption([]const u8, "default_config_path", default_config_path); + river.addBuildOption([]const u8, "default_config_path", abs_config_path); addServerDeps(river, scanner); @@ -229,7 +233,7 @@ const ScdocStep = struct { for (scd_paths) |path| { const path_no_ext = path[0..(path.len - 4)]; - const basename_no_ext = std.fs.path.basename(path_no_ext); + const basename_no_ext = fs.path.basename(path_no_ext); const section = path_no_ext[(path_no_ext.len - 1)..]; const output = try std.fmt.allocPrint( diff --git a/deps/zig-wayland b/deps/zig-wayland -Subproject 5def9c58107c4803847e37511d16c15ff294b62 +Subproject f170fe0265dfcea6a00f80691fc946473573486 |
