git.lucas.co / cce-compositor
Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git

commitb173dfcfc9ed1f950365a895f64f78d554f7f014
parentbc48b42565
authorIsaac Freund <[email protected]>
date2021-03-22 11:54
build: handle null install_prefix correctly

 build.zig        | 26 +++++++++++++++-----------
 deps/zig-wayland |  2 +-
 2 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/build.zig b/build.zig
index d1aa483..bb14e76 100644
--- a/build.zig
+++ b/build.zig
@@ -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
index 5def9c5..f170fe0 160000
--- a/deps/zig-wayland
+++ b/deps/zig-wayland
@@ -1 +1 @@
-Subproject commit 5def9c58107c4803847e37511d16c15ff294b62d
+Subproject commit f170fe0265dfcea6a00f80691fc9464735734860