13
0

more cleanups and standardization of fixup_bundle_environment() functions

git-svn-id: svn://localhost/ardour2/branches/3.0@12490 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2012-05-30 14:58:39 +00:00
parent 28e3bc3ac7
commit 1de10f1229

View File

@ -141,35 +141,14 @@ fixup_bundle_environment (int, char* [])
_NSGetExecutablePath (execpath, &pathsz); _NSGetExecutablePath (execpath, &pathsz);
std::string dir_path = Glib::path_get_dirname (execpath);
std::string path; std::string path;
const char *cstr = getenv ("PATH"); std::string exec_dir = Glib::path_get_dirname (execpath);
std::string bundle_dir;
std::string userconfigdir = user_config_directory().to_string();
/* ensure that we find any bundled executables (e.g. JACK), bundle_dir = Glib::path_get_dirname (exec_dir);
and find them before any instances of the same name
elsewhere in PATH
*/
path = dir_path; export_search_path (bundle_dir, "ARDOUR_DLL_PATH", "/lib");
/* JACK is often in /usr/local/bin and since Info.plist refuses to
set PATH, we have to force this in order to discover a running
instance of JACK ...
*/
path += ':';
path += "/usr/local/bin";
if (cstr) {
path += ':';
path += cstr;
}
setenv ("PATH", path.c_str(), 1);
export_search_path (dir_path, "ARDOUR_DLL_PATH", "/../lib");
path += dir_path;
path += "/../Resources";
/* inside an OS X .app bundle, there is no difference /* inside an OS X .app bundle, there is no difference
between DATA and CONFIG locations, since OS X doesn't between DATA and CONFIG locations, since OS X doesn't
@ -177,13 +156,13 @@ fixup_bundle_environment (int, char* [])
machine-independent shared data. machine-independent shared data.
*/ */
export_search_path (dir_path, "ARDOUR_DATA_PATH", "/../Resources"); export_search_path (bundle_dir, "ARDOUR_DATA_PATH", "/Resources");
export_search_path (dir_path, "ARDOUR_CONFIG_PATH", "/../Resources"); export_search_path (bundle_dir, "ARDOUR_CONFIG_PATH", "/Resources");
export_search_path (dir_path, "ARDOUR_INSTANT_XML_PATH", "/../Resources"); export_search_path (bundle_dir, "ARDOUR_INSTANT_XML_PATH", "/Resources");
export_search_path (dir_path, "LADSPA_PATH", "/../Plugins"); export_search_path (bundle_dir, "LADSPA_PATH", "/Plugins");
export_search_path (dir_path, "VAMP_PATH", "/../lib"); export_search_path (bundle_dir, "VAMP_PATH", "/lib");
export_search_path (dir_path, "SUIL_MODULE_DIR", "/../lib"); export_search_path (bundle_dir, "SUIL_MODULE_DIR", "/lib");
export_search_path (dir_path, "GTK_PATH", "/../lib/clearlooks"); export_search_path (bundle_dir, "GTK_PATH", "/lib/clearlooks");
/* unset GTK_RC_FILES so that we only load the RC files that we define /* unset GTK_RC_FILES so that we only load the RC files that we define
*/ */
@ -191,7 +170,7 @@ fixup_bundle_environment (int, char* [])
unsetenv ("GTK_RC_FILES"); unsetenv ("GTK_RC_FILES");
if (!ARDOUR::translations_are_disabled ()) { if (!ARDOUR::translations_are_disabled ()) {
expoirt_search_path (dir_path, "GTK_LOCALEDIR", "/../Resources/locale"); expoirt_search_path (bundle_dir, "GTK_LOCALEDIR", "/Resources/locale");
} }
/* write a pango.rc file and tell pango to use it. we'd love /* write a pango.rc file and tell pango to use it. we'd love
@ -202,52 +181,35 @@ fixup_bundle_environment (int, char* [])
actually exists ... actually exists ...
*/ */
try { if (g_mkdir_with_parents (userconfigdir.c_str(), 0755) < 0) {
sys::create_directories (user_config_directory ()); error << string_compose (_("cannot create user ardour folder %1 (%2)"), userconfigdir, strerror (errno))
} << endmsg;
catch (const sys::filesystem_error& ex) { return;
error << _("Could not create user configuration directory") << endmsg;
} }
sys::path pangopath = user_config_directory(); path = Glib::build_filename (userconfigdir, "pango.rc");
pangopath /= "pango.rc";
path = pangopath.to_string();
std::ofstream pangorc (path.c_str()); std::ofstream pangorc (path.c_str());
if (!pangorc) { if (!pangorc) {
error << string_compose (_("cannot open pango.rc file %1") , path) << endmsg; error << string_compose (_("cannot open pango.rc file %1") , path) << endmsg;
return;
} else { } else {
pangorc << "[Pango]\nModuleFiles="; pangorc << "[Pango]\nModuleFiles="
<< Glib::build_filename (bundle_dir, "Resources/pango.modules")
pangopath = dir_path; << endl;
pangopath /= "..";
pangopath /= "Resources";
pangopath /= "pango.modules";
pangorc << pangopath.to_string() << endl;
pangorc.close (); pangorc.close ();
setenv ("PANGO_RC_FILE", path.c_str(), 1); setenv ("PANGO_RC_FILE", path.c_str(), 1);
} }
// gettext charset aliases // gettext charset aliases XXX do we really need this, since the path
// is totally wrong?
setenv ("CHARSETALIASDIR", path.c_str(), 1); setenv ("CHARSETALIASDIR", path.c_str(), 1);
// font config setenv ("FONTCONFIG_FILE", Glib::build_filename (bundle_dir, "Resources/fonts.conf").c_str(), 1);
export_search_path (dir_path, "FONTCONFIG_FILE", "/../Resources/fonts.conf");
export_search_path (dir_path, "GDK_PIXBUF_MODULE_FILE", "/../Resources/gdk-pixbuf.loaders");
if (getenv ("ARDOUR_WITH_JACK")) { // GDK Pixbuf loader module file
// JACK driver dir
path = dir_path; setenv ("GDK_PIXBUF_MODULE_FILE", Glib::build_filename (bundle_dir, "Resources/gdk-pixbuf.loaders").c_str(), 1);
path += "/../lib";
setenv ("JACK_DRIVER_DIR", path.c_str(), 1);
}
} }
#else #else
@ -265,9 +227,9 @@ fixup_bundle_environment (int /*argc*/, char* argv[])
EnvironmentalProtectionAgency::set_global_epa (new EnvironmentalProtectionAgency (true, "PREBUNDLE_ENV")); EnvironmentalProtectionAgency::set_global_epa (new EnvironmentalProtectionAgency (true, "PREBUNDLE_ENV"));
Glib::ustring dir_path = Glib::path_get_dirname (Glib::path_get_dirname (argv[0])); std::string path;
Glib::ustring path; std::string dir_path = Glib::path_get_dirname (Glib::path_get_dirname (argv[0]));
Glib::ustring userconfigdir = user_config_directory().to_string(); std::string userconfigdir = user_config_directory().to_string();
/* note that this function is POSIX/Linux specific, so using / as /* note that this function is POSIX/Linux specific, so using / as
a dir separator in this context is just fine. a dir separator in this context is just fine.
@ -277,14 +239,11 @@ fixup_bundle_environment (int /*argc*/, char* argv[])
export_search_path (dir_path, "ARDOUR_CONFIG_PATH", "/etc"); export_search_path (dir_path, "ARDOUR_CONFIG_PATH", "/etc");
export_search_path (dir_path, "ARDOUR_INSTANT_XML_PATH", "/share"); export_search_path (dir_path, "ARDOUR_INSTANT_XML_PATH", "/share");
export_search_path (dir_path, "ARDOUR_DATA_PATH", "/share"); export_search_path (dir_path, "ARDOUR_DATA_PATH", "/share");
export_search_path (dir_path, "LADSPA_PATH", "/plugins");
export_search_path (dir_path, "LADSPA_PATH", "/../plugins");
export_search_path (dir_path, "VAMP_PATH", "/lib"); export_search_path (dir_path, "VAMP_PATH", "/lib");
export_search_path (dir_path, "SUIL_MODULE_DIR", "/lib"); export_search_path (dir_path, "SUIL_MODULE_DIR", "/lib");
path = dir_path; export_search_path (dir_path, "GTK_PATH", "/lib/clearlooks");
path += "/lib/clearlooks";
setenv ("GTK_PATH", path.c_str(), 1);
/* unset GTK_RC_FILES so that we only load the RC files that we define /* unset GTK_RC_FILES so that we only load the RC files that we define
*/ */
@ -292,11 +251,7 @@ fixup_bundle_environment (int /*argc*/, char* argv[])
unsetenv ("GTK_RC_FILES"); unsetenv ("GTK_RC_FILES");
if (!ARDOUR::translations_are_disabled ()) { if (!ARDOUR::translations_are_disabled ()) {
path = dir_path; export_search_path (dir_path, "GTK_LOCALEDIR", "/share/locale");
path += "/share/locale";
localedir = strdup (path.c_str());
setenv ("GTK_LOCALEDIR", localedir, 1);
} }
/* Tell fontconfig where to find fonts.conf. Use the system version /* Tell fontconfig where to find fonts.conf. Use the system version
@ -311,8 +266,7 @@ fixup_bundle_environment (int /*argc*/, char* argv[])
path = Glib::build_filename (dir_path, "etc/fonts/fonts.conf"); path = Glib::build_filename (dir_path, "etc/fonts/fonts.conf");
setenv ("FONTCONFIG_FILE", path.c_str(), 1); setenv ("FONTCONFIG_FILE", path.c_str(), 1);
path = Glib::build_filename (dir_path, "etc/fonts"); export_search_path (dir_path, "FONTCONFIG_PATH", "/etc/fonts");
setenv ("FONTCONFIG_PATH", "/etc/fonts", 1);
} }
/* write a pango.rc file and tell pango to use it. we'd love /* write a pango.rc file and tell pango to use it. we'd love
@ -329,18 +283,14 @@ fixup_bundle_environment (int /*argc*/, char* argv[])
return; return;
} }
Glib::ustring mpath;
path = Glib::build_filename (userconfigdir, "pango.rc"); path = Glib::build_filename (userconfigdir, "pango.rc");
std::ofstream pangorc (path.c_str()); std::ofstream pangorc (path.c_str());
if (!pangorc) { if (!pangorc) {
error << string_compose (_("cannot open pango.rc file %1") , path) << endmsg; error << string_compose (_("cannot open pango.rc file %1") , path) << endmsg;
} else { } else {
mpath = Glib::build_filename (userconfigdir, "pango.modules"); pangorc << "[Pango]\nModuleFiles="
<< Glib::build_filename (userconfigdir, "pango.modules")
pangorc << "[Pango]\nModuleFiles="; << endl;
pangorc << mpath << endl;
pangorc.close (); pangorc.close ();
} }
@ -350,8 +300,7 @@ fixup_bundle_environment (int /*argc*/, char* argv[])
to specify where it lives. to specify where it lives.
*/ */
mpath = Glib::build_filename (userconfigdir, "gdk-pixbuf.loaders"); setenv ("GDK_PIXBUF_MODULE_FILE", Glib::build_filename (userconfigdir, "gdk-pixbuf.loaders").c_str(), 1);
setenv ("GDK_PIXBUF_MODULE_FILE", mpath.c_str(), 1);
} }
#endif #endif