From 7bcc44459f7c3b76274715565cd659734538921e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 24 May 2012 03:09:06 +0000 Subject: Allow run-time configuation of module directory via environment variable SUIL_MODULE_DIR. git-svn-id: http://svn.drobilla.net/lad/trunk/suil@4457 a436a847-0d15-0410-975c-d299462d15a1 --- NEWS | 2 ++ src/instance.c | 9 ++++++--- suil/suil.h | 6 ++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index fc73aad..69d9dd3 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,8 @@ suil (9999) stable; * Fix crashes when wrapper widget is destroyed by toolkit before suil cleanup function is called * Link Gtk wrappers with 'nodelete' to avoid Glib type errors + * Allow run-time configuation of module directory via environment variable + SUIL_MODULE_DIR -- David Robillard diff --git a/src/instance.c b/src/instance.c index e8af856..2f68692 100644 --- a/src/instance.c +++ b/src/instance.c @@ -85,14 +85,17 @@ open_wrapper(SuilHost* host, return NULL; } - const size_t path_len = strlen(SUIL_MODULE_DIR) + const char* const env_dir = getenv("SUIL_MODULE_DIR"); + const char* const mod_dir = env_dir ? env_dir : SUIL_MODULE_DIR; + + const size_t path_len = strlen(mod_dir) + strlen(module_name) + strlen(SUIL_MODULE_EXT) + 2; char* const path = calloc(path_len, 1); snprintf(path, path_len, "%s%s%s%s", - SUIL_MODULE_DIR, SUIL_DIR_SEP, module_name, SUIL_MODULE_EXT); + mod_dir, SUIL_DIR_SEP, module_name, SUIL_MODULE_EXT); // Open wrap module dlerror(); @@ -181,7 +184,7 @@ suil_instance_new(SuilHost* host, dlclose(lib); return NULL; } - + instance->lib_handle = lib; instance->descriptor = descriptor; diff --git a/suil/suil.h b/suil/suil.h index 3c3ce19..1ffafcc 100644 --- a/suil/suil.h +++ b/suil/suil.h @@ -158,6 +158,12 @@ suil_ui_supported(const char* host_type_uri, /** Instantiate a UI for an LV2 plugin. + + This funcion may load a suil module to adapt the UI to the desired toolkit. + Suil is configured at compile time to load modules from the appropriate + place, but this can be changed at run-time via the environment variable + SUIL_MODULE_DIR. This makes it possible to bundle suil with an application. + @param host Host descriptor. @param controller Opaque host controller pointer. @param container_type_uri URI of the desired host container widget type. -- cgit v1.2.1