From 6aa37194f497f279ab474e69e854641eeec7db70 Mon Sep 17 00:00:00 2001 From: nicola Date: Mon, 26 Jul 2010 14:08:22 +0000 Subject: [PATCH] Added hack that should allow to load class lists of frameworks with a relative path (eg, if you have ../../MyFrameworks/ in your LD_LIBRARY_PATH you may be to load a framework with a relative path) git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@31037 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 8 ++++++++ Source/NSBundle.m | 23 ++++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index a6f234e9e..cc3ee3f69 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-07-26 Nicola Pero + + * Source/NSBundle.m ([+_addFrameworkFromClass:]): Added support + for class lists of frameworks with a relative path. If the + framework path is relative, convert it to absolute by prepending + the launch directory to it, since that must be how the dynamic + linker located the framework to load it. + 2010-07-22 Richard Frith-Macdonald * Source/NSString.m: Change to use ([-isKindOfClass:]) in a couple diff --git a/Source/NSBundle.m b/Source/NSBundle.m index 4da48f60f..a384936fc 100644 --- a/Source/NSBundle.m +++ b/Source/NSBundle.m @@ -556,11 +556,24 @@ _find_main_bundle_for_tool(NSString *toolName) { NSString *pathComponent; + /* bundlePath should really be an absolute path; we + * recommend you use only absolute paths in LD_LIBRARY_PATH. + * + * If it isn't, we try to survive the situation; we assume + * it's relative to the launch directory. That's how the + * dynamic linker would have found it after all. This is + * fragile though, so please use absolute paths. + */ + if ([bundlePath isAbsolutePath] == NO) + { + bundlePath = [_launchDirectory + stringByAppendingPathComponent: bundlePath]; + + } + /* Dereference symlinks, and standardize path. This will * only work properly if the original bundlePath is - * absolute. This should normally be the case if, as - * recommended, you use only absolute paths in - * LD_LIBRARY_PATH. + * absolute. */ bundlePath = [bundlePath stringByStandardizingPath]; @@ -607,7 +620,8 @@ _find_main_bundle_for_tool(NSString *toolName) [NSString stringWithFormat: @"%@%@", name, @".framework"]]; } #else - /* There are no Versions on MinGW. Skip the Versions check here. */ + /* There are no Versions on MinGW. So the version check is only + * done on non-MinGW. */ /* version name */ bundlePath = [bundlePath stringByDeletingLastPathComponent]; @@ -686,7 +700,6 @@ _find_main_bundle_for_tool(NSString *toolName) Class class = NSClassFromString(*fmClasses); value = [NSValue valueWithPointer: (void*)class]; - [bundle->_bundleClasses addObject: value]; fmClasses++;