From 9034e58b1594724a527703ffc0e411c1b3f96f06 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 3 Oct 2014 23:07:45 +0200 Subject: [PATCH] set mingw vamp plugin path --- gtk2_ardour/bundle_env_mingw.cc | 68 ++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/gtk2_ardour/bundle_env_mingw.cc b/gtk2_ardour/bundle_env_mingw.cc index 85fd37b99f..d29c625113 100644 --- a/gtk2_ardour/bundle_env_mingw.cc +++ b/gtk2_ardour/bundle_env_mingw.cc @@ -25,8 +25,10 @@ #include #include #include + #include #include +#include // CSIDL_* #include "ardour/ardour.h" #include "ardour/search_paths.h" @@ -34,11 +36,53 @@ #include "pbd/file_utils.h" #include "pbd/epa.h" +#include "pbd/windows_special_dirs.h" using namespace std; using namespace PBD; using namespace ARDOUR; + +/* query top-level Ardour installation path. + * Typically, this will be somehwere like + * "C:\Program Files (x86)\Ardour" + */ +const std::string +get_install_path () +{ + const gchar* pExeRoot = g_win32_get_package_installation_directory_of_module (0); + + if (0 == pExeRoot) { + HKEY key; + DWORD size = PATH_MAX; + char tmp[PATH_MAX+1]; + if ( +#ifdef __MINGW64__ + (ERROR_SUCCESS == RegOpenKeyExA (HKEY_LOCAL_MACHINE, "Software\\Ardour\\ardour3\\w64", 0, KEY_READ, &key)) +#else + (ERROR_SUCCESS == RegOpenKeyExA (HKEY_LOCAL_MACHINE, "Software\\Ardour\\ardour3\\w32", 0, KEY_READ, &key)) +#endif + &&(ERROR_SUCCESS == RegQueryValueExA (key, "Install_Dir", 0, NULL, reinterpret_cast(tmp), &size)) + ) + { + pExeRoot = Glib::locale_to_utf8(tmp).c_str(); + } + } + + if (0 == pExeRoot) { + const char *program_files = PBD::get_win_special_folder (CSIDL_PROGRAM_FILES); + if (program_files) { + pExeRoot = g_build_filename(program_files, PROGRAM_NAME, NULL); + } + } + + if (pExeRoot && Glib::file_test(pExeRoot, Glib::FILE_TEST_EXISTS|Glib::FILE_TEST_IS_DIR)) { + return std::string (pExeRoot); + } + return ""; +} + + void fixup_bundle_environment (int, char* [], const char** localedir) { @@ -50,9 +94,28 @@ fixup_bundle_environment (int, char* [], const char** localedir) // Unset GTK_RC_FILES so that only ardour specific files are loaded Glib::unsetenv ("GTK_RC_FILES"); + + + std::string path; + const char *cstr; + cstr = getenv ("VAMP_PATH"); + if (cstr) { + path = cstr; + path += G_SEARCHPATH_SEPARATOR; + } else { + path = ""; + } + path += Glib::build_filename(get_install_path(), "lib", "ardour3", "vamp", NULL); + path += G_SEARCHPATH_SEPARATOR; + path += "%ProgramFiles%\\Vamp Plugins"; // default vamp path + path += G_SEARCHPATH_SEPARATOR; + path += "%COMMONPROGRAMFILES%\\Vamp Plugins"; + Glib::setenv ("VAMP_PATH", path, true); } -static __cdecl void unload_custom_fonts() { +static __cdecl void +unload_custom_fonts() +{ std::string ardour_mono_file; if (!find_file (ardour_data_search_path(), "ArdourMono.ttf", ardour_mono_file)) { return; @@ -60,7 +123,8 @@ static __cdecl void unload_custom_fonts() { RemoveFontResource(ardour_mono_file.c_str()); } -void load_custom_fonts() +void +load_custom_fonts() { std::string ardour_mono_file;