From 65404b24424b2c554c611b24e9ddf7e12ce1a9f4 Mon Sep 17 00:00:00 2001 From: hrxi Date: Tue, 25 Jun 2024 14:01:47 +0200 Subject: Discover plugins in Meson build directories If the environment looks like a Meson build dir (parent directory is called "main"), then also look for plugins in `../plugins/*`. Fixes #1591. --- libdino/src/util/util.vala | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/libdino/src/util/util.vala b/libdino/src/util/util.vala index c691a279..553ebbfe 100644 --- a/libdino/src/util/util.vala +++ b/libdino/src/util/util.vala @@ -33,10 +33,30 @@ public class SearchPathGenerator { if (!exec_path.contains(Path.DIR_SEPARATOR_S)) { exec_path = Environment.find_program_in_path(this.exec_path); } - if (Path.get_dirname(exec_path).contains("dino") || Path.get_dirname(exec_path) == "." || Path.get_dirname(exec_path).contains("build")) { + string dirname = Path.get_dirname(exec_path); + // Does our environment look like a CMake build dir? + if (dirname.contains("dino") || dirname == "." || dirname.contains("build") || Path.get_basename(dirname) == "main") { search_paths += Path.build_filename(Path.get_dirname(exec_path), "plugins"); } - if (Path.get_basename(Path.get_dirname(exec_path)) == "bin") { + // Does our environment look like a meson build dir? + if (dirname == "." || Path.get_basename(dirname) == "main") { + try { + Dir plugin_dir = Dir.open(Path.build_path(Path.DIR_SEPARATOR_S, dirname, "..", "plugins")); + string? entry = null; + while ((entry = plugin_dir.read_name()) != null) { + string plugin_subdir = Path.build_path(Path.DIR_SEPARATOR_S, dirname, "..", "plugins", entry); + try { + Dir.open(plugin_subdir); + search_paths += plugin_subdir; + } catch (FileError e) { + // ignore + } + } + } catch (FileError e) { + // ignore + } + } + if (Path.get_basename(dirname) == "bin") { search_paths += Path.build_filename(Path.get_dirname(Path.get_dirname(exec_path)), SYSTEM_LIBDIR_NAME, "dino", "plugins"); } } -- cgit v1.2.3-70-g09d2