mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2024-11-21 03:10:58 +08:00
Improve 'Architecture'
This commit is contained in:
parent
7db379492a
commit
f662e983a4
@ -108,8 +108,8 @@ public final class Launcher extends Application {
|
||||
try {
|
||||
LOG.info("*** " + Metadata.TITLE + " ***");
|
||||
LOG.info("Operating System: " + OperatingSystem.SYSTEM_NAME + ' ' + OperatingSystem.SYSTEM_VERSION);
|
||||
LOG.info("System Architecture: " + Architecture.SYSTEM_ARCH);
|
||||
LOG.info("Java Architecture: " + Architecture.CURRENT_ARCH);
|
||||
LOG.info("System Architecture: " + Architecture.SYSTEM_ARCH_NAME);
|
||||
LOG.info("Java Architecture: " + Architecture.CURRENT_ARCH_NAME);
|
||||
LOG.info("Java Version: " + System.getProperty("java.version") + ", " + System.getProperty("java.vendor"));
|
||||
LOG.info("Java VM Version: " + System.getProperty("java.vm.name") + " (" + System.getProperty("java.vm.info") + "), " + System.getProperty("java.vm.vendor"));
|
||||
LOG.info("Java Home: " + System.getProperty("java.home"));
|
||||
|
@ -26,6 +26,7 @@ import org.jackhuang.hmcl.task.Schedulers;
|
||||
import org.jackhuang.hmcl.task.Task;
|
||||
import org.jackhuang.hmcl.util.Lang;
|
||||
import org.jackhuang.hmcl.util.StringUtils;
|
||||
import org.jackhuang.hmcl.util.platform.Architecture;
|
||||
import org.jackhuang.hmcl.util.platform.JavaVersion;
|
||||
import org.jackhuang.hmcl.util.platform.OperatingSystem;
|
||||
import org.jackhuang.hmcl.util.platform.Platform;
|
||||
@ -608,7 +609,7 @@ public final class VersionSetting implements Cloneable {
|
||||
if (checkJava)
|
||||
return JavaVersion.fromExecutable(Paths.get(getJavaDir()));
|
||||
else
|
||||
return new JavaVersion(Paths.get(getJavaDir()), "", Platform.SYSTEM_PLATFORM);
|
||||
return new JavaVersion(Paths.get(getJavaDir()), "", Platform.getPlatform(OperatingSystem.CURRENT_OS, Architecture.UNKNOWN));
|
||||
} catch (IOException | InvalidPathException e) {
|
||||
return null; // Custom Java Directory not found,
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public class GameCrashWindow extends Stage {
|
||||
private final String java;
|
||||
private final LibraryAnalyzer analyzer;
|
||||
private final StringProperty os = new SimpleStringProperty(OperatingSystem.SYSTEM_NAME);
|
||||
private final StringProperty arch = new SimpleStringProperty(Architecture.CURRENT_ARCH_NAME);
|
||||
private final StringProperty arch = new SimpleStringProperty(Architecture.SYSTEM_ARCH.getDisplayName());
|
||||
private final StringProperty reason = new SimpleStringProperty(i18n("game.crash.reason.unknown"));
|
||||
private final BooleanProperty loading = new SimpleBooleanProperty();
|
||||
private final Label feedbackLabel = new Label(i18n("game.crash.feedback"));
|
||||
|
@ -25,6 +25,7 @@ import org.jackhuang.hmcl.ui.CrashWindow;
|
||||
import org.jackhuang.hmcl.upgrade.IntegrityChecker;
|
||||
import org.jackhuang.hmcl.upgrade.UpdateChecker;
|
||||
import org.jackhuang.hmcl.util.io.NetworkUtils;
|
||||
import org.jackhuang.hmcl.util.platform.Architecture;
|
||||
import org.jackhuang.hmcl.util.platform.OperatingSystem;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -109,11 +110,13 @@ public class CrashReporter implements Thread.UncaughtExceptionHandler {
|
||||
String text = "---- Hello Minecraft! Crash Report ----\n" +
|
||||
" Version: " + Metadata.VERSION + "\n" +
|
||||
" Time: " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + "\n" +
|
||||
" Thread: " + t.toString() + "\n" +
|
||||
" Thread: " + t + "\n" +
|
||||
"\n Content: \n " +
|
||||
stackTrace + "\n\n" +
|
||||
"-- System Details --\n" +
|
||||
" Operating System: " + OperatingSystem.SYSTEM_NAME + ' ' + OperatingSystem.SYSTEM_VERSION + "\n" +
|
||||
" System Architecture: " + Architecture.SYSTEM_ARCH_NAME + "\n" +
|
||||
" Java Architecture: " + Architecture.CURRENT_ARCH_NAME + "\n" +
|
||||
" Java Version: " + System.getProperty("java.version") + ", " + System.getProperty("java.vendor") + "\n" +
|
||||
" Java VM Version: " + System.getProperty("java.vm.name") + " (" + System.getProperty("java.vm.info") + "), " + System.getProperty("java.vm.vendor") + "\n" +
|
||||
" JVM Max Memory: " + Runtime.getRuntime().maxMemory() + "\n" +
|
||||
|
@ -72,7 +72,7 @@ public final class OSRestriction {
|
||||
return false;
|
||||
|
||||
if (arch != null)
|
||||
return !Lang.test(() -> !Pattern.compile(arch).matcher(Architecture.CURRENT_ARCH_NAME).matches());
|
||||
return !Lang.test(() -> !Pattern.compile(arch).matcher(Architecture.SYSTEM_ARCH.getCheckedName()).matches());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.jackhuang.hmcl.util.platform.Bits.BIT_32;
|
||||
import static org.jackhuang.hmcl.util.platform.Bits.BIT_64;
|
||||
@ -87,26 +86,30 @@ public enum Architecture {
|
||||
}
|
||||
|
||||
public static final String CURRENT_ARCH_NAME;
|
||||
public static final String SYSTEM_ARCH_NAME;
|
||||
public static final Architecture CURRENT_ARCH;
|
||||
public static final Architecture SYSTEM_ARCH;
|
||||
|
||||
private static final Pattern NORMALIZER = Pattern.compile("[^a-z0-9]+");
|
||||
|
||||
public static Architecture parseArchName(String value) {
|
||||
if (value == null) {
|
||||
return UNKNOWN;
|
||||
}
|
||||
value = NORMALIZER.matcher(value.toLowerCase(Locale.ROOT).trim()).replaceAll("");
|
||||
value = value.trim().toLowerCase(Locale.ROOT);
|
||||
|
||||
switch (value) {
|
||||
case "x8664":
|
||||
case "x86-64":
|
||||
case "x86_64":
|
||||
case "amd64":
|
||||
case "ia32e":
|
||||
case "em64t":
|
||||
case "x64":
|
||||
return X86_64;
|
||||
case "x8632":
|
||||
case "x86-32":
|
||||
case "x86_32":
|
||||
case "x86":
|
||||
case "i86pc":
|
||||
case "i386":
|
||||
case "i486":
|
||||
case "i586":
|
||||
@ -114,6 +117,7 @@ public enum Architecture {
|
||||
case "ia32":
|
||||
case "x32":
|
||||
return X86;
|
||||
case "arm64":
|
||||
case "aarch64":
|
||||
return ARM64;
|
||||
case "arm":
|
||||
@ -130,6 +134,7 @@ public enum Architecture {
|
||||
case "mips32el":
|
||||
return MIPSEL;
|
||||
case "riscv":
|
||||
case "risc-v":
|
||||
return RISCV;
|
||||
case "ia64":
|
||||
case "ia64w":
|
||||
@ -144,20 +149,32 @@ public enum Architecture {
|
||||
case "sparc32":
|
||||
return SPARC;
|
||||
case "ppc64":
|
||||
return PPC64;
|
||||
case "powerpc64":
|
||||
return "little".equals(System.getProperty("sun.cpu.endian")) ? PPC64LE : PPC64;
|
||||
case "ppc64le":
|
||||
case "powerpc64le":
|
||||
return PPC64LE;
|
||||
case "ppc":
|
||||
case "ppc32":
|
||||
case "powerpc":
|
||||
case "powerpc32":
|
||||
return PPC;
|
||||
case "ppcle":
|
||||
case "ppc32le":
|
||||
case "powerpcle":
|
||||
case "powerpc32le":
|
||||
return PPCLE;
|
||||
case "s390":
|
||||
return S390;
|
||||
case "s390x":
|
||||
return S390X;
|
||||
default:
|
||||
if (value.startsWith("armv7")) {
|
||||
return ARM32;
|
||||
}
|
||||
if (value.startsWith("armv8") || value.startsWith("armv9")) {
|
||||
return ARM64;
|
||||
}
|
||||
return UNKNOWN;
|
||||
}
|
||||
}
|
||||
@ -167,16 +184,16 @@ public enum Architecture {
|
||||
|
||||
CURRENT_ARCH = parseArchName(CURRENT_ARCH_NAME);
|
||||
|
||||
Architecture sysArch = UNKNOWN;
|
||||
String sysArchName = null;
|
||||
|
||||
if (OperatingSystem.CURRENT_OS == OperatingSystem.WINDOWS) {
|
||||
sysArch = parseArchName(System.getenv("PROCESSOR_ARCHITECTURE"));
|
||||
sysArchName = System.getenv("PROCESSOR_ARCHITECTURE").trim();
|
||||
} else {
|
||||
try {
|
||||
Process process = Runtime.getRuntime().exec("/usr/bin/arch");
|
||||
if (process.waitFor(1, TimeUnit.SECONDS)) {
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
|
||||
sysArch = parseArchName(reader.readLine());
|
||||
sysArchName = reader.readLine().trim();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -185,6 +202,13 @@ public enum Architecture {
|
||||
}
|
||||
}
|
||||
|
||||
SYSTEM_ARCH = sysArch == UNKNOWN ? CURRENT_ARCH : sysArch;
|
||||
Architecture sysArch = parseArchName(sysArchName);
|
||||
if (sysArch == UNKNOWN) {
|
||||
SYSTEM_ARCH_NAME = CURRENT_ARCH_NAME;
|
||||
SYSTEM_ARCH = CURRENT_ARCH;
|
||||
} else {
|
||||
SYSTEM_ARCH_NAME = sysArchName;
|
||||
SYSTEM_ARCH = sysArch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user