Skip to content

Commit

Permalink
native lib loading
Browse files Browse the repository at this point in the history
  • Loading branch information
redrezo committed Jul 30, 2020
1 parent 05b4670 commit 7b54fd7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static void require() {
}

private static void initOnce() {
NativeUtil.loadLibrary(DriftCPP.class, "driftcpp");
NativeUtil.loadLibrary(DriftCPP.class, "driftcpp", System::loadLibrary, System::load);
init(classLoader == null ? DriftCPP.class.getClassLoader() : classLoader);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ public static void require() {
}

public static void initOnce() {
NativeUtil.loadLibrary(DriftFX.class, "driftfx");
NativeUtil.loadLibrary(DriftFX.class, "driftfx", System::loadLibrary, System::load);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.function.Consumer;

import org.eclipse.fx.drift.internal.Log;

Expand Down Expand Up @@ -42,11 +43,12 @@ public static boolean isMacOs() {
return getOsName().toLowerCase().contains("mac");
}

public static void loadLibrary(Class<?> context, String libname) {
public static void loadLibrary(Class<?> context, String libname, Consumer<String> loadLibrary, Consumer<String> load) {
if (USE_JAVA_LIBRARY_PATH || osgi) {
// osgi will take care of it
Log.info("loading " + libname + " via system call");
System.loadLibrary(libname);
// System.loadLibrary(libname);
loadLibrary.accept(libname);
}
else {

Expand All @@ -68,7 +70,8 @@ public static void loadLibrary(Class<?> context, String libname) {
}

Log.info("loading " + libname + " from extracted location (" + extractPath + ")");
System.load(extractPath.toString());
// System.load(extractPath.toString());
load.accept(extractPath.toString());
}
}

Expand Down

0 comments on commit 7b54fd7

Please sign in to comment.