build: clean up install prefix/config path derivation
This could be cleaned up even further with https://github.com/ziglang/zig/pull/8329
This commit is contained in:
parent
e6f11fc5d2
commit
e1048e6add
1 changed files with 10 additions and 13 deletions
23
build.zig
23
build.zig
|
@ -1,5 +1,7 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
const assert = std.debug.assert;
|
||||||
const fs = std.fs;
|
const fs = std.fs;
|
||||||
|
const mem = std.mem;
|
||||||
const zbs = std.build;
|
const zbs = std.build;
|
||||||
|
|
||||||
const ScanProtocolsStep = @import("deps/zig-wayland/build.zig").ScanProtocolsStep;
|
const ScanProtocolsStep = @import("deps/zig-wayland/build.zig").ScanProtocolsStep;
|
||||||
|
@ -46,20 +48,15 @@ pub fn build(b: *zbs.Builder) !void {
|
||||||
|
|
||||||
const examples = b.option(bool, "examples", "Set to true to build examples") orelse false;
|
const examples = b.option(bool, "examples", "Set to true to build examples") orelse false;
|
||||||
|
|
||||||
const rel_config_path = blk: {
|
// This logic must match std.build.resolveInstallPrefix()
|
||||||
if (b.install_prefix) |prefix| {
|
const prefix = b.install_prefix orelse if (b.dest_dir) |_| "/usr" else b.cache_root;
|
||||||
if (std.mem.eql(u8, try fs.path.resolve(b.allocator, &[_][]const u8{prefix}), "/usr")) {
|
const rel_config_path = if (mem.eql(u8, try fs.path.resolve(b.allocator, &[_][]const u8{prefix}), "/usr"))
|
||||||
break :blk "../etc/river/init";
|
"../etc/river/init"
|
||||||
}
|
else
|
||||||
}
|
"etc/river/init";
|
||||||
break :blk "etc/river/init";
|
|
||||||
};
|
|
||||||
b.installFile("example/init", rel_config_path);
|
b.installFile("example/init", rel_config_path);
|
||||||
const abs_config_path = try fs.path.resolve(b.allocator, &[_][]const u8{
|
const abs_config_path = try fs.path.resolve(b.allocator, &[_][]const u8{ prefix, rel_config_path });
|
||||||
// This logic must match std.build.resolveInstallPrefix()
|
assert(fs.path.isAbsolute(abs_config_path));
|
||||||
b.install_prefix orelse if (b.dest_dir) |_| "/usr" else b.cache_root,
|
|
||||||
rel_config_path,
|
|
||||||
});
|
|
||||||
|
|
||||||
const scanner = ScanProtocolsStep.create(b);
|
const scanner = ScanProtocolsStep.create(b);
|
||||||
scanner.addSystemProtocol("stable/xdg-shell/xdg-shell.xml");
|
scanner.addSystemProtocol("stable/xdg-shell/xdg-shell.xml");
|
||||||
|
|
Loading…
Reference in a new issue