diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2012-05-18 17:24:06 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2012-05-18 17:24:06 +0000 |
commit | 813c5f0af9d1dac32b156ef3c72b890a7cf9eab5 (patch) | |
tree | 29aa92a68feb1557c60500969d6d5aeade6a2e9b /libs/ardour | |
parent | 433b6651ee8450da8282330ac35cb7ec1abbab6f (diff) |
major rationalization of use of search paths. ardour now has just 4 functions used to define how external resources are located: ardour_config_search_path() (for system or user specific configuration data), ardour_data_search_path() (for machine, user and system independent data), ardour_dll_directory() (base directory where shared libraries are found) and user_config_directory(). These are now used throughout the code. the config, data and dll paths/directories can be overridden by environment variables. the user config dir is added as the first element of the first two search paths, and use selectively when searching for a few other things.
This commit re-enabes ./waf install, and it is believed that it works fully at this point (more testing likely required)
git-svn-id: svn://localhost/ardour2/branches/3.0@12326 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/ardour/filesystem_paths.h | 17 | ||||
-rw-r--r-- | libs/ardour/control_protocol_manager.cc | 8 | ||||
-rw-r--r-- | libs/ardour/control_protocol_search_path.cc | 4 | ||||
-rw-r--r-- | libs/ardour/filesystem_paths.cc | 79 | ||||
-rw-r--r-- | libs/ardour/globals.cc | 13 | ||||
-rw-r--r-- | libs/ardour/midi_patch_search_path.cc | 2 | ||||
-rw-r--r-- | libs/ardour/panner_search_path.cc | 2 | ||||
-rw-r--r-- | libs/ardour/rc_configuration.cc | 4 | ||||
-rw-r--r-- | libs/ardour/template_utils.cc | 36 | ||||
-rw-r--r-- | libs/ardour/wscript | 8 |
10 files changed, 97 insertions, 76 deletions
diff --git a/libs/ardour/ardour/filesystem_paths.h b/libs/ardour/ardour/filesystem_paths.h index e183193cb0..120ae25f97 100644 --- a/libs/ardour/ardour/filesystem_paths.h +++ b/libs/ardour/ardour/filesystem_paths.h @@ -35,13 +35,20 @@ namespace ARDOUR { * @return the path to the directory that contains the system wide ardour * modules. */ - PBD::sys::path ardour_module_directory (); + PBD::sys::path ardour_dll_directory (); - PBD::SearchPath ardour_search_path (); - - PBD::SearchPath system_config_search_path (); + /** + * @return the search path to be used when looking for per-system + * configuration files. This may include user configuration files. + */ + PBD::SearchPath ardour_config_search_path (); - PBD::SearchPath system_data_search_path (); + /** + * @return the search path to be used when looking for data files + * that could be shared by systems (h/w and configuration independent + * files, such as icons, XML files, etc) + */ + PBD::SearchPath ardour_data_search_path (); } // namespace ARDOUR diff --git a/libs/ardour/control_protocol_manager.cc b/libs/ardour/control_protocol_manager.cc index 59001dce14..2931fe46e5 100644 --- a/libs/ardour/control_protocol_manager.cc +++ b/libs/ardour/control_protocol_manager.cc @@ -210,7 +210,7 @@ ControlProtocolManager::discover_control_protocols () dylib_extension_pattern, cp_modules); DEBUG_TRACE (DEBUG::ControlProtocols, - string_compose (_("looking for control protocols in %1"), control_protocol_search_path().to_string())); + string_compose (_("looking for control protocols in %1\n"), control_protocol_search_path().to_string())); for (vector<sys::path>::iterator i = cp_modules.begin(); i != cp_modules.end(); ++i) { control_protocol_discover ((*i).to_string()); @@ -222,12 +222,14 @@ ControlProtocolManager::control_protocol_discover (string path) { ControlProtocolDescriptor* descriptor; - /* don't load shared objects that are just symlinks to the real thing. +#ifdef __APPLE__ + /* don't load OS X shared objects that are just symlinks to the real thing. */ - if (Glib::file_test (path, Glib::FILE_TEST_IS_SYMLINK)) { + if (path.find (".dylib") && Glib::file_test (path, Glib::FILE_TEST_IS_SYMLINK)) { return 0; } +#endif if ((descriptor = get_descriptor (path)) != 0) { diff --git a/libs/ardour/control_protocol_search_path.cc b/libs/ardour/control_protocol_search_path.cc index 345989277b..157531cbf2 100644 --- a/libs/ardour/control_protocol_search_path.cc +++ b/libs/ardour/control_protocol_search_path.cc @@ -17,6 +17,8 @@ */ +#include <iostream> + #include <glibmm/miscutils.h> #include "ardour/control_protocol_search_path.h" @@ -36,7 +38,7 @@ control_protocol_search_path () { SearchPath spath (user_config_directory ()); - spath += ardour_module_directory (); + spath += ardour_dll_directory (); spath.add_subdirectory_to_paths (surfaces_dir_name); bool surfaces_path_defined = false; diff --git a/libs/ardour/filesystem_paths.cc b/libs/ardour/filesystem_paths.cc index 2d14494764..bc84243c84 100644 --- a/libs/ardour/filesystem_paths.cc +++ b/libs/ardour/filesystem_paths.cc @@ -17,10 +17,11 @@ */ #include <cstdlib> +#include <iostream> #include "pbd/error.h" #include "pbd/compose.h" -#include "pbd/filesystem_paths.h" +#include "pbd/strsplit.h" #include <glibmm/miscutils.h> #include <glibmm/fileutils.h> @@ -90,38 +91,72 @@ user_config_directory () } sys::path -ardour_module_directory () +ardour_dll_directory () { - sys::path module_directory(MODULE_DIR); - module_directory /= "ardour3"; - return module_directory; + std::string s = Glib::getenv("ARDOUR_DLL_PATH"); + if (s.empty()) { + std::cerr << _("ARDOUR_CONFIG_PATH not set in environment - exiting\n"); + ::exit (1); + } + return sys::path (s); } SearchPath -ardour_search_path () +ardour_config_search_path () { - SearchPath spath_env(Glib::getenv("ARDOUR_PATH")); - return spath_env; -} - -SearchPath -system_config_search_path () -{ - SearchPath config_path(system_config_directories()); - - config_path.add_subdirectory_to_paths("ardour3"); + static bool have_path = false; + static SearchPath search_path; + + if (!have_path) { + SearchPath sp (user_config_directory()); + + std::string s = Glib::getenv("ARDOUR_CONFIG_PATH"); + if (s.empty()) { + std::cerr << _("ARDOUR_CONFIG_PATH not set in environment - exiting\n"); + ::exit (1); + } + + std::vector<string> ss; + split (s, ss, ':'); + for (std::vector<string>::iterator i = ss.begin(); i != ss.end(); ++i) { + sp += sys::path (*i); + } + + search_path = sp; + have_path = true; + std::cerr << "CONFIG PATH: " << search_path.to_string() << std::endl; + } - return config_path; + return search_path; } SearchPath -system_data_search_path () +ardour_data_search_path () { - SearchPath data_path(system_data_directories()); - - data_path.add_subdirectory_to_paths("ardour3"); + static bool have_path = false; + static SearchPath search_path; + + if (!have_path) { + SearchPath sp (user_config_directory()); + + std::string s = Glib::getenv("ARDOUR_DATA_PATH"); + if (s.empty()) { + std::cerr << _("ARDOUR_DATA_PATH not set in environment - exiting\n"); + ::exit (1); + } + + std::vector<string> ss; + split (s, ss, ':'); + for (std::vector<string>::iterator i = ss.begin(); i != ss.end(); ++i) { + sp += sys::path (*i); + } + + search_path = sp; + have_path = true; + std::cerr << "DATA PATH: " << search_path.to_string() << std::endl; + } - return data_path; + return search_path; } } // namespace ARDOUR diff --git a/libs/ardour/globals.cc b/libs/ardour/globals.cc index 96d93ea5bc..c6aa660115 100644 --- a/libs/ardour/globals.cc +++ b/libs/ardour/globals.cc @@ -319,14 +319,9 @@ ARDOUR::init (bool use_windows_vst, bool try_optimization) /* Make VAMP look in our library ahead of anything else */ - char *p = getenv ("VAMP_PATH"); - string vamppath = VAMP_DIR; - if (p) { - vamppath += ':'; - vamppath += p; - } - setenv ("VAMP_PATH", vamppath.c_str(), 1); - + SearchPath sp (ardour_dll_directory()); + sp.add_subdirectory_to_paths ("vamp"); + setenv ("VAMP_PATH", sp.to_string().c_str(), 1); setup_hardware_optimization (try_optimization); @@ -400,7 +395,7 @@ void ARDOUR::find_bindings_files (map<string,string>& files) { vector<sys::path> found; - SearchPath spath = ardour_search_path() + user_config_directory() + system_config_search_path(); + SearchPath spath = ardour_config_search_path(); if (getenv ("ARDOUR_SAE")) { Glib::PatternSpec pattern("*SAE-*.bindings"); diff --git a/libs/ardour/midi_patch_search_path.cc b/libs/ardour/midi_patch_search_path.cc index 50f83d852e..3f83375c96 100644 --- a/libs/ardour/midi_patch_search_path.cc +++ b/libs/ardour/midi_patch_search_path.cc @@ -36,7 +36,7 @@ midi_patch_search_path () { SearchPath spath (user_config_directory ()); - spath += ardour_module_directory (); + spath += ardour_dll_directory (); spath.add_subdirectory_to_paths(midi_patch_dir_name); bool midi_patch_path_defined = false; diff --git a/libs/ardour/panner_search_path.cc b/libs/ardour/panner_search_path.cc index 257f9d0c78..debc19c757 100644 --- a/libs/ardour/panner_search_path.cc +++ b/libs/ardour/panner_search_path.cc @@ -36,7 +36,7 @@ panner_search_path () { SearchPath spath (user_config_directory ()); - spath += ardour_module_directory (); + spath += ardour_dll_directory (); spath.add_subdirectory_to_paths(panner_dir_name); bool panner_path_defined = false; diff --git a/libs/ardour/rc_configuration.cc b/libs/ardour/rc_configuration.cc index d5bfc7a9a8..1adde47b2a 100644 --- a/libs/ardour/rc_configuration.cc +++ b/libs/ardour/rc_configuration.cc @@ -84,7 +84,7 @@ RCConfiguration::load_state () /* load system configuration first */ - if (find_file_in_search_path (ardour_search_path() + system_config_search_path(), "ardour_system.rc", system_rc_file)) { + if (find_file_in_search_path (ardour_config_search_path(), "ardour_system.rc", system_rc_file)) { string rcfile = system_rc_file.to_string(); /* stupid XML Parser hates empty files */ @@ -115,7 +115,7 @@ RCConfiguration::load_state () sys::path user_rc_file; - if (find_file_in_search_path (ardour_search_path() + user_config_directory(), "ardour.rc", user_rc_file)) { + if (find_file_in_search_path (ardour_config_search_path(), "ardour.rc", user_rc_file)) { string rcfile = user_rc_file.to_string(); /* stupid XML parser hates empty files */ diff --git a/libs/ardour/template_utils.cc b/libs/ardour/template_utils.cc index 388e09fab1..3e4797dac1 100644 --- a/libs/ardour/template_utils.cc +++ b/libs/ardour/template_utils.cc @@ -19,32 +19,20 @@ using namespace PBD; namespace ARDOUR { -sys::path -system_template_directory () +SearchPath +template_search_path () { - SearchPath spath(system_data_search_path()); + SearchPath spath (ardour_data_search_path()); spath.add_subdirectory_to_paths(templates_dir_name); - - // just return the first directory in the search path that exists - SearchPath::const_iterator i = std::find_if(spath.begin(), spath.end(), sys::exists); - - if (i == spath.end()) return sys::path(); - - return *i; + return spath; } -sys::path -system_route_template_directory () +SearchPath +route_template_search_path () { - SearchPath spath(system_data_search_path()); + SearchPath spath (ardour_data_search_path()); spath.add_subdirectory_to_paths(route_templates_dir_name); - - // just return the first directory in the search path that exists - SearchPath::const_iterator i = std::find_if(spath.begin(), spath.end(), sys::exists); - - if (i == spath.end()) return sys::path(); - - return *i; + return spath; } sys::path @@ -61,7 +49,7 @@ user_route_template_directory () { sys::path p(user_config_directory()); p /= route_templates_dir_name; - + return p; } @@ -100,8 +88,7 @@ find_session_templates (vector<TemplateInfo>& template_names) { vector<string *> *templates; PathScanner scanner; - SearchPath spath (system_template_directory()); - spath += user_template_directory (); + SearchPath spath (template_search_path()); templates = scanner (spath.to_string(), template_filter, 0, true, true); @@ -137,8 +124,7 @@ find_route_templates (vector<TemplateInfo>& template_names) { vector<string *> *templates; PathScanner scanner; - SearchPath spath (system_route_template_directory()); - spath += user_route_template_directory (); + SearchPath spath (route_template_search_path()); templates = scanner (spath.to_string(), route_template_filter, 0, false, true); diff --git a/libs/ardour/wscript b/libs/ardour/wscript index df46d8cc86..c69673ed00 100644 --- a/libs/ardour/wscript +++ b/libs/ardour/wscript @@ -364,11 +364,7 @@ def build(bld): 'PACKAGE="' + I18N_PACKAGE + '"', 'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"', 'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"', - 'MODULE_DIR="' + os.path.normpath(bld.env['LIBDIR']) + '"', - 'LOCALEDIR="' + os.path.join( - os.path.normpath(bld.env['DATADIR']), 'locale') + '"', - 'VAMP_DIR="' + os.path.join( - os.path.normpath(bld.env['LIBDIR']), 'ardour3', 'vamp') + '"', + 'LOCALEDIR="' + os.path.join(os.path.normpath(bld.env['DATADIR']), 'locale') + '"', 'PROGRAM_NAME="' + bld.env['PROGRAM_NAME'] + '"' ] @@ -453,7 +449,6 @@ def build(bld): 'PACKAGE="libardour3test"', 'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"', 'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"', - 'MODULE_DIR="' + os.path.normpath(bld.env['LIBDIR']) + '"', 'LOCALEDIR="' + os.path.join( os.path.normpath(bld.env['DATADIR']), 'locale') + '"', 'VAMP_DIR="' + os.path.join( @@ -485,7 +480,6 @@ def build(bld): 'PACKAGE="libardour3profile"', 'DATA_DIR="' + os.path.normpath(bld.env['DATADIR']) + '"', 'CONFIG_DIR="' + os.path.normpath(bld.env['SYSCONFDIR']) + '"', - 'MODULE_DIR="' + os.path.normpath(bld.env['LIBDIR']) + '"', 'LOCALEDIR="' + os.path.join( os.path.normpath(bld.env['DATADIR']), 'locale') + '"', 'VAMP_DIR="' + os.path.join( |