From 7e8627f45bc83985bf2809d0379d3d55fe8009ce Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Sun, 3 Sep 2006 06:37:19 +0000 Subject: Fixed run-time breakage due to NativeLibrary usage in JOAL. Added search of Frameworks directory for NativeLibrary on Mac OS X. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/../svn-server-sync/gluegen/trunk@44 a78bb65f-1512-4460-ba86-f6dc96a7bf27 --- .../com/sun/gluegen/runtime/NativeLibrary.java | 27 +++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'src/java') diff --git a/src/java/com/sun/gluegen/runtime/NativeLibrary.java b/src/java/com/sun/gluegen/runtime/NativeLibrary.java index 01148b1..7ae9cdf 100755 --- a/src/java/com/sun/gluegen/runtime/NativeLibrary.java +++ b/src/java/com/sun/gluegen/runtime/NativeLibrary.java @@ -64,7 +64,7 @@ public class NativeLibrary { private static boolean DEBUG; private static int platform; private static DynamicLinker dynLink; - private static String prefix; + private static String[] prefixes; private static String[] suffixes; static { @@ -89,18 +89,18 @@ public class NativeLibrary { switch (platform) { case WINDOWS: dynLink = new WindowsDynamicLinkerImpl(); - prefix = ""; + prefixes = new String[] { "" }; suffixes = new String[] { ".dll" }; break; case UNIX: dynLink = new UnixDynamicLinkerImpl(); - prefix = "lib"; + prefixes = new String[] { "lib" }; suffixes = new String[] { ".so" }; break; case MACOSX: dynLink = new MacOSXDynamicLinkerImpl(); - prefix = "lib"; - suffixes = new String[] { ".dylib", ".jnilib" }; + prefixes = new String[] { "lib", "" }; + suffixes = new String[] { ".dylib", ".jnilib", "" }; break; default: throw new InternalError("Platform not initialized properly"); @@ -260,6 +260,14 @@ public class NativeLibrary { }); addPaths(userDir, baseNames, paths); + // Add probable Mac OS X-specific paths + if (platform == MACOSX) { + // Add historical location + addPaths("/Library/Frameworks/" + libName + ".Framework", baseNames, paths); + // Add current location + addPaths("/System/Library/Frameworks/" + libName + ".Framework", baseNames, paths); + } + if (!searchSystemPathFirst) { // Add just the library names to use the OS's search algorithm for (int i = 0; i < baseNames.length; i++) { @@ -287,9 +295,12 @@ public class NativeLibrary { } private static String[] buildNames(String libName) { - String[] res = new String[suffixes.length]; - for (int i = 0; i < suffixes.length; i++) { - res[i] = prefix + libName + suffixes[i]; + String[] res = new String[prefixes.length * suffixes.length]; + int idx = 0; + for (int i = 0; i < prefixes.length; i++) { + for (int j = 0; j < suffixes.length; j++) { + res[idx++] = prefixes[i] + libName + suffixes[j]; + } } return res; } -- cgit v1.2.3