Put aarch64 libfdb_java in the right place for fat jar

This commit is contained in:
Andrew Noyes 2021-05-13 23:13:14 +00:00
parent 061afda2ec
commit 4163270c02
2 changed files with 19 additions and 15 deletions

View File

@ -141,8 +141,6 @@ endif()
target_include_directories(fdb_java PRIVATE ${JNI_INCLUDE_DIRS})
# libfdb_java.so is loaded by fdb-java.jar and doesn't need to depened on jvm shared libraries.
target_link_libraries(fdb_java PRIVATE fdb_c)
set_target_properties(fdb_java PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib/${SYSTEM_NAME}/amd64/)
if(APPLE)
set_target_properties(fdb_java PROPERTIES SUFFIX ".jnilib")
endif()
@ -217,7 +215,11 @@ if(NOT OPEN_FOR_IDE)
elseif(APPLE)
set(lib_destination "osx/x86_64")
else()
set(lib_destination "linux/amd64")
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
set(lib_destination "linux/aarch64")
else()
set(lib_destination "linux/amd64")
endif()
endif()
set(lib_destination "${unpack_dir}/lib/${lib_destination}")
set(jni_package "${CMAKE_BINARY_DIR}/packages/lib")

View File

@ -36,11 +36,7 @@ class JNIUtil {
private static final String TEMPFILE_PREFIX = "fdbjni";
private static final String TEMPFILE_SUFFIX = ".library";
private enum OS {
WIN32("windows", "amd64", false),
LINUX("linux", "amd64", true),
OSX("osx", "x86_64", true);
private static class OS {
private final String name;
private final String arch;
private final boolean canDeleteEager;
@ -171,13 +167,19 @@ class JNIUtil {
private static OS getRunningOS() {
String osname = System.getProperty("os.name").toLowerCase();
if(osname.startsWith("windows"))
return OS.WIN32;
if(osname.startsWith("linux"))
return OS.LINUX;
if(osname.startsWith("mac") || osname.startsWith("darwin"))
return OS.OSX;
throw new IllegalStateException("Unknown or unsupported OS: " + osname);
String arch = System.getProperty("os.arch");
if (arch != "amd64" && arch != "x86_64" && arch != "aarch64") {
throw new IllegalStateException("Unknown or unsupported arch: " + arch);
}
if (osname.startsWith("windows")) {
return new OS("windows", arch, /* canDeleteEager */ false);
} else if (osname.startsWith("linux")) {
return new OS("linux", arch, /* canDeleteEager */ true);
} else if (osname.startsWith("mac") || osname.startsWith("darwin")) {
return new OS("osx", arch, /* canDeleteEager */ true);
} else {
throw new IllegalStateException("Unknown or unsupported OS: " + osname);
}
}
private JNIUtil() {}