mirror of https://github.com/rusefi/rusefi.git
attempt macos lib copying
This commit is contained in:
parent
8d808f546c
commit
4b18ec8047
|
@ -1,5 +1,13 @@
|
|||
package com.rusefi.maintenance;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
|
||||
public final class OpenbltJni {
|
||||
public interface OpenbltCallbacks
|
||||
{
|
||||
|
@ -10,8 +18,28 @@ public final class OpenbltJni {
|
|||
void setPhase(String title, boolean hasProgress);
|
||||
}
|
||||
|
||||
private static final String OS_NAME = System.getProperty("os.name").toLowerCase(Locale.ROOT);
|
||||
private static final boolean IS_MAC = OS_NAME.contains("mac") || OS_NAME.contains("darwin");
|
||||
|
||||
static {
|
||||
System.loadLibrary("openblt_jni");
|
||||
|
||||
if (IS_MAC) {
|
||||
// MacOS won't run load a dylib from the current directory, it has
|
||||
// to be copied to the user's library first
|
||||
String targetDir = "~/Library/Java/Extensions";
|
||||
new File(targetDir).mkdirs();
|
||||
|
||||
String[] libs = { "libopenblt.dylib", "libopenblt_jni.dylib" };
|
||||
|
||||
try {
|
||||
for (String l : libs) {
|
||||
Files.copy(Paths.get(l), Paths.get(targetDir + "/" + l), StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static native void flashSerial(String filename, String serialPort, OpenbltCallbacks callbacks);
|
||||
|
|
Loading…
Reference in New Issue