Skip to content

Commit

Permalink
fix: translate x86_64 to amd64 to keep uniform naming of artifacts.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zurcusa committed Jun 9, 2024
1 parent c8a3b3c commit 92de665
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/java/org/wasmer/Native.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@

package org.wasmer;

import java.io.*;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.URL;
import java.nio.file.Files;
import java.util.logging.Level;
Expand All @@ -19,7 +25,8 @@ public class Native {
LOADED_EMBEDDED_LIBRARY = loadEmbeddedLibrary();
}

private Native() {}
private Native() {
}

public static String getCurrentPlatformIdentifier() {
String osName = System.getProperty("os.name").toLowerCase();
Expand All @@ -28,11 +35,15 @@ public static String getCurrentPlatformIdentifier() {
osName = "windows";
} else if (osName.contains("mac os x")) {
osName = "darwin";
String[] args = new String[] {"/bin/bash", "-c", "uname -m"};
String[] args = new String[]{"/bin/bash", "-c", "uname -m"};
try {
Process proc = new ProcessBuilder(args).start();
BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()));
return osName + "-" + reader.readLine();
String arch = new BufferedReader(new InputStreamReader(proc.getInputStream()))
.readLine().equals("x86_64")
? "amd64"
: "arm64";

return osName + "-" + arch;
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down Expand Up @@ -62,14 +73,14 @@ private static boolean loadEmbeddedLibrary() {

URL nativeLibraryUrl = null;
// loop through extensions, stopping after finding first one
for (String lib: libs) {
for (String lib : libs) {
nativeLibraryUrl = Module.class.getResource(url + lib);

if (nativeLibraryUrl != null) {
break;
}
}

if (nativeLibraryUrl != null) {
// native library found within JAR, extract and load
try {
Expand Down

0 comments on commit 92de665

Please sign in to comment.