From 33e07c87c90242cf529dce6975538ced58242fdc Mon Sep 17 00:00:00 2001 From: azhn Date: Mon, 14 Apr 2025 19:56:22 +1000 Subject: [PATCH] deps: Default gtk4-layer-shell system integration to true We default system-integration to true as this is a shared library that must be installed on a library path and it is recommended to use the system package. If the system does not package gtk4-layer-shell then doing `zig build -fno-sys` will now correctly build and install the shared library under a lib/ subdirectory of the output prefix. The output prefix should be a default library path (`/lib`, `/usr/lib`, or a lib64 variant) otherwise a custom library path can be configured using ldconfig (see `man ld.so 8`) --- src/build/Config.zig | 10 +++++++++- src/build/SharedDeps.zig | 9 ++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/build/Config.zig b/src/build/Config.zig index e55da3860..5f8780af9 100644 --- a/src/build/Config.zig +++ b/src/build/Config.zig @@ -361,7 +361,6 @@ pub fn init(b: *std.Build) !Config { "libpng", "zlib", "oniguruma", - "gtk4-layer-shell", }) |dep| { _ = b.systemIntegrationOption( dep, @@ -387,6 +386,15 @@ pub fn init(b: *std.Build) !Config { }) |dep| { _ = b.systemIntegrationOption(dep, .{ .default = false }); } + + // These are dynamic libraries we default to true, preferring + // to use system packages over building and installing libs + // as they require additional ldconfig of library paths or + // patching the rpath of the program to discover the dynamic library + // at runtime + for (&[_][]const u8{"gtk4-layer-shell"}) |dep| { + _ = b.systemIntegrationOption(dep, .{ .default = true }); + } } return config; diff --git a/src/build/SharedDeps.zig b/src/build/SharedDeps.zig index acd3ed1d8..ec97a9c9f 100644 --- a/src/build/SharedDeps.zig +++ b/src/build/SharedDeps.zig @@ -652,14 +652,13 @@ fn addGTK( // IMPORTANT: gtk4-layer-shell must be linked BEFORE // wayland-client, as it relies on shimming libwayland's APIs. if (b.systemIntegrationOption("gtk4-layer-shell", .{})) { - step.linkSystemLibrary2( - "gtk4-layer-shell-0", - dynamic_link_opts, - ); + step.linkSystemLibrary2("gtk4-layer-shell-0", dynamic_link_opts); } else { // gtk4-layer-shell *must* be dynamically linked, // so we don't add it as a static library - step.linkLibrary(gtk4_layer_shell.artifact("gtk4-layer-shell")); + const shared_lib = gtk4_layer_shell.artifact("gtk4-layer-shell"); + b.installArtifact(shared_lib); + step.linkLibrary(shared_lib); } }