Skip to content

Commit ca79121

Browse files
committed
Default systemIntegrationOption for gtk4-layer-shell to true
- Add an absolute rpath entry in Debug mode only to test gtk4-layer-shell when not using the system package * Prefer using ldconfig to discover installed libs in custom prefixes Fix variable name cases
1 parent 8a9ed09 commit ca79121

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

src/build/Config.zig

+11-3
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,8 @@ pub fn init(b: *std.Build) !Config {
337337
target.result.os.tag == .macos and
338338
config.app_runtime == .none and
339339
(!config.emit_bench and
340-
!config.emit_test_exe and
341-
!config.emit_helpgen);
340+
!config.emit_test_exe and
341+
!config.emit_helpgen);
342342

343343
//---------------------------------------------------------------
344344
// System Packages
@@ -361,7 +361,6 @@ pub fn init(b: *std.Build) !Config {
361361
"libpng",
362362
"zlib",
363363
"oniguruma",
364-
"gtk4-layer-shell",
365364
}) |dep| {
366365
_ = b.systemIntegrationOption(
367366
dep,
@@ -387,6 +386,15 @@ pub fn init(b: *std.Build) !Config {
387386
}) |dep| {
388387
_ = b.systemIntegrationOption(dep, .{ .default = false });
389388
}
389+
390+
// These are dynamic libraries we default to true, preferring
391+
// to use system packages over building and installing libs
392+
// as they require additional ldconfig of library paths or
393+
// patching the rpath of the program to discover the dynamic library
394+
// at runtime
395+
for (&[_][]const u8{"gtk4-layer-shell"}) |dep| {
396+
_ = b.systemIntegrationOption(dep, .{ .default = true });
397+
}
390398
}
391399

392400
return config;

src/build/SharedDeps.zig

+12-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ help_strings: HelpStrings,
1414
metallib: ?*MetallibStep,
1515
unicode_tables: UnicodeTables,
1616
framedata: GhosttyFrameData,
17-
steps: []*std.Build.Step,
1817

1918
/// Used to keep track of a list of file sources.
2019
pub const LazyPathList = std.ArrayList(std.Build.LazyPath);
@@ -649,12 +648,19 @@ fn addGTK(
649648
} else {
650649
// gtk4-layer-shell *must* be dynamically linked,
651650
// so we don't add it as a static library
652-
const sharedLib = gtk4_layer_shell.artifact("gtk4-layer-shell");
653-
const artifact: *std.Build.Step.InstallArtifact = b.addInstallArtifact(sharedLib, .{});
651+
const shared_lib = gtk4_layer_shell.artifact("gtk4-layer-shell");
652+
const artifact: *std.Build.Step.InstallArtifact = b.addInstallArtifact(shared_lib, .{});
654653
b.getInstallStep().dependOn(&artifact.step);
655-
// Lookup dynamic libs from installed location
656-
step.root_module.addRPathSpecial(b.getInstallPath(artifact.dest_dir.?, ""));
657-
step.linkLibrary(sharedLib);
654+
step.linkLibrary(shared_lib);
655+
if (self.config.optimize == .Debug) {
656+
// Lookup dynamic libs from installed location
657+
const install_path = b.getInstallPath(artifact.dest_dir.?, "");
658+
if (!std.fs.path.isAbsolute(install_path)) {
659+
// Using a relative path as an rpath is almost useless
660+
return error.UndesirableRelativePath;
661+
}
662+
step.root_module.addRPathSpecial(install_path);
663+
}
658664
}
659665
}
660666

0 commit comments

Comments
 (0)