Skip to content

Commit

Permalink
Merge pull request #48 from tresf/riscv
Browse files Browse the repository at this point in the history
Add support for linux_riscv32, linux_riscv64
  • Loading branch information
ctrueden authored Nov 7, 2023
2 parents 21d6c1e + 9a60f24 commit 438b788
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/main/java/org/scijava/nativelib/NativeLibraryUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
* libxxx[-vvv].so
* linux_arm64
* libxxx[-vvv].so
* linux_riscv32
* libxxx[-vvv].so
* linux_riscv64
* libxxx[-vvv].so
* osx_32
* libxxx[-vvv].dylib
* osx_64
Expand Down Expand Up @@ -83,12 +87,13 @@
public class NativeLibraryUtil {

public static enum Architecture {
UNKNOWN, LINUX_32, LINUX_64, LINUX_ARM, LINUX_ARM64, WINDOWS_32, WINDOWS_64, WINDOWS_ARM64,
OSX_32, OSX_64, OSX_PPC, OSX_ARM64, AIX_32, AIX_64
UNKNOWN, LINUX_32, LINUX_64, LINUX_ARM, LINUX_ARM64, LINUX_RISCV32, LINUX_RISCV64,
WINDOWS_32, WINDOWS_64, WINDOWS_ARM64,
OSX_32, OSX_64, OSX_PPC, OSX_ARM64, AIX_32, AIX_64
}

private static enum Processor {
UNKNOWN, INTEL_32, INTEL_64, PPC, PPC_64, ARM, AARCH_64
UNKNOWN, INTEL_32, INTEL_64, PPC, PPC_64, ARM, AARCH_64, RISCV_32, RISCV_64
}

public static final String DELIM = "/";
Expand Down Expand Up @@ -122,6 +127,12 @@ else if (Processor.ARM == processor) {
else if (Processor.AARCH_64 == processor) {
architecture = Architecture.LINUX_ARM64;
}
else if (Processor.RISCV_32 == processor) {
architecture = Architecture.LINUX_RISCV32;
}
else if (Processor.RISCV_64 == processor) {
architecture = Architecture.LINUX_RISCV64;
}
}
else if (name.contains("aix")) {
if (Processor.PPC == processor) {
Expand Down Expand Up @@ -195,6 +206,13 @@ else if (arch.contains("86") || arch.contains("amd")) {
}
processor = (32 == bits) ? Processor.INTEL_32 : Processor.INTEL_64;
}
else if (arch.contains("riscv")) {
bits = 32;
if (arch.contains("64")) {
bits = 64;
}
processor = (32 == bits) ? Processor.RISCV_32 : Processor.RISCV_64;
}
LOGGER.debug("processor is " + processor + " os.arch is " +
System.getProperty("os.arch").toLowerCase(Locale.ENGLISH));
return processor;
Expand Down Expand Up @@ -235,6 +253,8 @@ public static String getPlatformLibraryName(final String libName) {
case LINUX_64:
case LINUX_ARM:
case LINUX_ARM64:
case LINUX_RISCV32:
case LINUX_RISCV64:
name = "lib" + libName + ".so";
break;
case WINDOWS_32:
Expand Down

0 comments on commit 438b788

Please sign in to comment.