Skip to content

Commit

Permalink
Replace .jnilib with .dylib on OS X with JDK 6. Resolve #100
Browse files Browse the repository at this point in the history
  • Loading branch information
Spasi committed Nov 28, 2014
1 parent 4567863 commit 8cdaf59
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
17 changes: 16 additions & 1 deletion src/java/org/lwjgl/LWJGLUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,21 @@ public static String getPlatformName() {
}
}

/**
* Wraps {@link System#mapLibraryName}. On OS X with JDK 6, the .jnilib file
* extension will be replaced with .dylib.
*
* @param name the name of the library.
*
* @return a platform-dependent native library name.
*/
public static String mapLibraryName(String name) {
String libName = System.mapLibraryName(name);
return LWJGLUtil.getPlatform() == LWJGLUtil.PLATFORM_MACOSX && libName.endsWith(".jnilib")
? libName.substring(0, libName.length() - ".jnilib".length()) + ".dylib"
: libName;
}

/**
* Locates the paths required by a library.
*
Expand Down Expand Up @@ -421,7 +436,7 @@ public String run() {
*/
private static String getPathFromClassLoader(final String libname, final ClassLoader classloader) {
Class<?> c = null;

try {
log("getPathFromClassLoader: searching for: " + libname);
c = classloader.getClass();
Expand Down
3 changes: 1 addition & 2 deletions src/java/org/lwjgl/Sys.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ private static void doLoadLibrary(final String lib_name) {
public Object run() {
String library_path = System.getProperty("org.lwjgl.librarypath");
if (library_path != null) {
System.load(library_path + File.separator +
System.mapLibraryName(lib_name));
System.load(library_path + File.separator + LWJGLUtil.mapLibraryName(lib_name));
} else {
System.loadLibrary(lib_name);
}
Expand Down
4 changes: 3 additions & 1 deletion src/java/org/lwjgl/util/applet/AppletLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
*/
package org.lwjgl.util.applet;

import org.lwjgl.LWJGLUtil;

import java.applet.Applet;
import java.applet.AppletStub;
import java.awt.BorderLayout;
Expand Down Expand Up @@ -1219,7 +1221,7 @@ else if ( "file".equals(codesource.getLocation().getProtocol()) ) {

// allow non lwjgl native to be found from cache directory
protected String findLibrary (String libname) {
String libPath = path + "natives" + File.separator + System.mapLibraryName(libname);
String libPath = path + "natives" + File.separator + LWJGLUtil.mapLibraryName(libname);

if (new File(libPath).exists()) {
return libPath;
Expand Down

0 comments on commit 8cdaf59

Please sign in to comment.