From 955c64efcf30e87ab3d4bdb1520745c1997f0953 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 20 Oct 2008 02:02:27 +0000 Subject: Make Ingen and Patchage relocatable binaries when built as a bundle. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1690 a436a847-0d15-0410-975c-d299462d15a1 --- src/engine/ingen.lv2/ingen_lv2.cpp | 2 ++ src/gui/App.cpp | 3 ++- src/gui/GladeFactory.cpp | 19 +++++++------------ src/gui/LoadPatchWindow.cpp | 4 ++-- src/gui/LoadSubpatchWindow.cpp | 4 ++-- src/ingen/main.cpp | 4 ++++ src/module/Module.cpp | 3 ++- src/shared/wscript | 1 + wscript | 13 +++++++++++-- 9 files changed, 33 insertions(+), 20 deletions(-) diff --git a/src/engine/ingen.lv2/ingen_lv2.cpp b/src/engine/ingen.lv2/ingen_lv2.cpp index 4c81c42b..67b63fc5 100644 --- a/src/engine/ingen.lv2/ingen_lv2.cpp +++ b/src/engine/ingen.lv2/ingen_lv2.cpp @@ -118,6 +118,8 @@ ingen_instantiate(const LV2_Descriptor* descriptor, { IngenPlugin* plugin = (IngenPlugin*)malloc(sizeof(IngenPlugin)); + Shared::bundle_path = bundle_path; + plugin->world = Ingen::Shared::get_world(); plugin->engine = SharedPtr(new Engine(plugin->world)); plugin->world->local_engine = plugin->engine; diff --git a/src/gui/App.cpp b/src/gui/App.cpp index 7e414297..615ac36f 100644 --- a/src/gui/App.cpp +++ b/src/gui/App.cpp @@ -34,6 +34,7 @@ #include "client/PatchModel.hpp" #include "client/ClientStore.hpp" #include "engine/Engine.hpp" +#include "shared/runtime_paths.hpp" #include "NodeModule.hpp" #include "ControlPanel.hpp" #include "SubpatchModule.hpp" @@ -107,7 +108,7 @@ App::run(int argc, char** argv, Ingen::Shared::World* world) _instance->configuration()->apply_settings(); // Set default window icon - const Glib::ustring icon_path = INGEN_DATA_DIR "/ingen.svg"; + const Glib::ustring icon_path = Shared::data_file_path("ingen.svg"); try { if (Glib::file_test(icon_path, Glib::FILE_TEST_EXISTS)) Gtk::Window::set_default_icon_from_file(icon_path); diff --git a/src/gui/GladeFactory.cpp b/src/gui/GladeFactory.cpp index 81640d57..792e67ac 100644 --- a/src/gui/GladeFactory.cpp +++ b/src/gui/GladeFactory.cpp @@ -19,6 +19,7 @@ #include #include #include "config.h" +#include "shared/runtime_paths.hpp" using namespace std; @@ -36,21 +37,15 @@ GladeFactory::find_glade_file() if (env_path) glade_filename = env_path; else - glade_filename = "./ingen_gui.glade"; + glade_filename = Shared::data_file_path("ingen_gui.glade"); ifstream fs(glade_filename.c_str()); - if (fs.fail()) { // didn't find it, check INGEN_DATA_DIR - fs.clear(); - glade_filename = INGEN_DATA_DIR; - glade_filename += "/ingen_gui.glade"; - - fs.open(glade_filename.c_str()); - if (fs.fail()) { - cerr << "[GladeFactory] Unable to find ingen_gui.glade in current directory or " << INGEN_DATA_DIR << "." << endl; - throw; - } - fs.close(); + if (fs.fail()) { + cerr << "Unable to find ingen_gui.glade in " << INGEN_DATA_DIR << endl; + throw; } + + fs.close(); cerr << "[GladeFactory] Loading widgets from " << glade_filename.c_str() << endl; } diff --git a/src/gui/LoadPatchWindow.cpp b/src/gui/LoadPatchWindow.cpp index fdbc3c23..caa6c8bf 100644 --- a/src/gui/LoadPatchWindow.cpp +++ b/src/gui/LoadPatchWindow.cpp @@ -21,6 +21,7 @@ #include "LoadPatchWindow.hpp" #include "interface/EngineInterface.hpp" #include "client/PatchModel.hpp" +#include "shared/runtime_paths.hpp" #include "App.hpp" #include "Configuration.hpp" #include "ThreadedLoader.hpp" @@ -60,8 +61,7 @@ LoadPatchWindow::LoadPatchWindow(BaseObjectType* cobject, const Glib::RefPtr engine_module; SharedPtr engine_http_module; SharedPtr engine_osc_module; diff --git a/src/module/Module.cpp b/src/module/Module.cpp index 2f143443..a42e466b 100644 --- a/src/module/Module.cpp +++ b/src/module/Module.cpp @@ -22,6 +22,7 @@ #include #include #include "raul/SharedPtr.hpp" +#include "shared/runtime_paths.hpp" #include "config.h" using namespace std; @@ -66,7 +67,7 @@ load_module(const string& name) // Try default directory if not found module = new Glib::Module( - Glib::Module::build_path(INGEN_MODULE_DIR, name), + Shared::module_path(name), Glib::MODULE_BIND_LAZY); if (*module) { diff --git a/src/shared/wscript b/src/shared/wscript index d7512559..6a5758a0 100644 --- a/src/shared/wscript +++ b/src/shared/wscript @@ -10,6 +10,7 @@ def build(bld): LV2Features.cpp LV2URIMap.cpp Store.cpp + runtime_paths.cpp ''' if bld.env()['HAVE_LIBLO']: obj.source += ' OSCSender.cpp ' diff --git a/wscript b/wscript index cee783a7..20c24d64 100644 --- a/wscript +++ b/wscript @@ -53,8 +53,17 @@ def configure(conf): conf.define('INGEN_VERSION', INGEN_VERSION) conf.define('BUILD_GUI', build_gui) conf.define('HAVE_JACK_MIDI', conf.env['HAVE_JACK'] == 1) - conf.define('INGEN_DATA_DIR', os.path.normpath(conf.env['DATADIR'] + 'ingen')) - conf.define('INGEN_MODULE_DIR', os.path.normpath(conf.env['LIBDIR'] + 'ingen')) + if conf.env['BUNDLE']: + conf.define('INGEN_DATA_DIR', os.path.normpath( + conf.env['DATADIRNAME'] + 'ingen')) + conf.define('INGEN_MODULE_DIR', os.path.normpath( + conf.env['LIBDIRNAME'] + 'ingen')) + else: + conf.define('INGEN_DATA_DIR', os.path.normpath( + conf.env['DATADIR'] + 'ingen')) + conf.define('INGEN_MODULE_DIR', os.path.normpath( + conf.env['LIBDIR'] + 'ingen')) + conf.write_config_header('config.h') autowaf.print_summary(conf) -- cgit v1.2.1