summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-04-14 09:52:21 +0200
committerDavid Robillard <d@drobilla.net>2019-04-14 11:18:00 +0200
commit1403d34fca93ee75a84347fd838506539fb20625 (patch)
tree24e6655494c3f6688d60f6cedf9ccd5dc405813c
parentb788af9d049c43b274befc8424a487515d122b0b (diff)
downloadlilv-1403d34fca93ee75a84347fd838506539fb20625.tar.gz
lilv-1403d34fca93ee75a84347fd838506539fb20625.tar.bz2
lilv-1403d34fca93ee75a84347fd838506539fb20625.zip
Add option to override LV2_PATH in applications
-rw-r--r--NEWS3
-rw-r--r--lilv/lilv.h8
-rw-r--r--src/lilv_internal.h5
-rw-r--r--src/world.c11
4 files changed, 23 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index fa335a9..e84bf05 100644
--- a/NEWS
+++ b/NEWS
@@ -4,8 +4,9 @@ lilv (0.24.5) unstable;
* Fix creating directories across drives on Windows
* Don't print errors when saving state if correct links already exist
* Fix issues with loading state with saved files from the model
+ * Add option to override LV2_PATH in applications
- -- David Robillard <d@drobilla.net> Sun, 16 Sep 2018 11:36:45 +0200
+ -- David Robillard <d@drobilla.net> Sun, 14 Apr 2019 09:52:48 +0200
lilv (0.24.4) stable;
diff --git a/lilv/lilv.h b/lilv/lilv.h
index 52493ed..6ce93d0 100644
--- a/lilv/lilv.h
+++ b/lilv/lilv.h
@@ -530,11 +530,19 @@ lilv_world_new(void);
#define LILV_OPTION_DYN_MANIFEST "http://drobilla.net/ns/lilv#dyn-manifest"
/**
+ Set application-specific LV2_PATH. This overrides the LV2_PATH from the
+ environment, so that lilv will only look inside the given path. This can be
+ used to make self-contained applications.
+*/
+#define LILV_OPTION_LV2_PATH "http://drobilla.net/ns/lilv#lv2-path"
+
+/**
Set an option option for `world`.
Currently recognized options:
@ref LILV_OPTION_FILTER_LANG
@ref LILV_OPTION_DYN_MANIFEST
+ @ref LILV_OPTION_LV2_PATH
*/
LILV_API void
lilv_world_set_option(LilvWorld* world,
diff --git a/src/lilv_internal.h b/src/lilv_internal.h
index 2f95a59..da38d05 100644
--- a/src/lilv_internal.h
+++ b/src/lilv_internal.h
@@ -146,8 +146,9 @@ struct LilvInstancePimpl {
};
typedef struct {
- bool dyn_manifest;
- bool filter_language;
+ bool dyn_manifest;
+ bool filter_language;
+ char* lv2_path;
} LilvOptions;
struct LilvWorldImpl {
diff --git a/src/world.c b/src/world.c
index 0d9c5e3..29c16d0 100644
--- a/src/world.c
+++ b/src/world.c
@@ -178,6 +178,7 @@ lilv_world_free(LilvWorld* world)
sord_world_free(world->world);
world->world = NULL;
+ free(world->opt.lv2_path);
free(world);
}
@@ -196,6 +197,11 @@ lilv_world_set_option(LilvWorld* world,
world->opt.filter_language = lilv_node_as_bool(value);
return;
}
+ } else if (!strcmp(uri, LILV_OPTION_LV2_PATH)) {
+ if (lilv_node_is_string(value)) {
+ world->opt.lv2_path = lilv_strdup(lilv_node_as_string(value));
+ return;
+ }
}
LILV_WARNF("Unrecognized or invalid option `%s'\n", uri);
}
@@ -1031,7 +1037,10 @@ lilv_world_load_plugin_classes(LilvWorld* world)
LILV_API void
lilv_world_load_all(LilvWorld* world)
{
- const char* lv2_path = getenv("LV2_PATH");
+ const char* lv2_path = world->opt.lv2_path;
+ if (!lv2_path) {
+ lv2_path = getenv("LV2_PATH");
+ }
if (!lv2_path) {
lv2_path = LILV_DEFAULT_LV2_PATH;
}