aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/util
diff options
context:
space:
mode:
authorhrxi <hrrrxi@gmail.com>2024-06-25 14:01:47 +0200
committerfiaxh <fiaxh@users.noreply.github.com>2024-09-15 21:07:59 +0200
commit65404b24424b2c554c611b24e9ddf7e12ce1a9f4 (patch)
treeec480ae925d9b060c96768d8aec3e6e2267785eb /libdino/src/util
parent228640a881aead53d307775cc2d3726fe64f3fc2 (diff)
downloaddino-65404b24424b2c554c611b24e9ddf7e12ce1a9f4.tar.gz
dino-65404b24424b2c554c611b24e9ddf7e12ce1a9f4.zip
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.
Diffstat (limited to 'libdino/src/util')
-rw-r--r--libdino/src/util/util.vala24
1 files 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");
}
}