Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 79 additions & 34 deletions jme3-core/src/main/java/com/jme3/system/JmeSystemDelegate.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ public boolean showSettingsDialog(AppSettings settings, boolean loadFromRegistry
}


private boolean is64Bit(String arch) {
if (arch.equals("x86")) {
return false;
private boolean is64Bit(String arch) {
if (arch.equals("x86")) {
return false;
} else if (arch.equals("amd64")) {
return true;
} else if (arch.equals("x86_64")) {
Expand All @@ -240,37 +240,82 @@ private boolean is64Bit(String arch) {
return false;
} else {
throw new UnsupportedOperationException("Unsupported architecture: " + arch);
}
}

public Platform getPlatform() {
String os = System.getProperty("os.name").toLowerCase();
String arch = System.getProperty("os.arch").toLowerCase();
boolean is64 = is64Bit(arch);
if (os.contains("windows")) {
if (arch.startsWith("arm") || arch.startsWith("aarch")) {
return is64 ? Platform.Windows_ARM64 : Platform.Windows_ARM32;
} else {
return is64 ? Platform.Windows64 : Platform.Windows32;
}
} else if (os.contains("linux") || os.contains("freebsd")
|| os.contains("sunos") || os.contains("unix")) {
if (arch.startsWith("arm") || arch.startsWith("aarch")) {
return is64 ? Platform.Linux_ARM64 : Platform.Linux_ARM32;
} else {
return is64 ? Platform.Linux64 : Platform.Linux32;
}
} else if (os.contains("mac os x") || os.contains("darwin")) {
if (arch.startsWith("ppc")) {
return is64 ? Platform.MacOSX_PPC64 : Platform.MacOSX_PPC32;
} else if (arch.startsWith("aarch")) {
return Platform.MacOSX_ARM64; // no 32-bit version
} else {
return is64 ? Platform.MacOSX64 : Platform.MacOSX32;
}
} else {
throw new UnsupportedOperationException("The specified platform: " + os + " is not supported.");
}
}
}

private boolean isArmArchitecture(String arch) {
return arch.startsWith("arm") || arch.startsWith("aarch");
}

private boolean isX86Architecture(String arch) {
return arch.equals("x86")
|| arch.equals("amd64")
|| arch.equals("x86_64")
|| arch.equals("i386")
|| arch.equals("i686")
|| arch.equals("universal");
}

private UnsupportedOperationException unsupported32Bit(String osName) {
return new UnsupportedOperationException("32-bit " + osName + " is not supported.");
}

private Platform getWindowsPlatform(String arch, boolean is64) {
if (isArmArchitecture(arch)) {
if (!is64) {
throw unsupported32Bit("Windows");
}
return Platform.Windows_ARM64;
}
if (isX86Architecture(arch)) {
if (!is64) {
throw unsupported32Bit("Windows");
}
return Platform.Windows64;
}
throw new UnsupportedOperationException("Unsupported architecture: " + arch);
}

private Platform getLinuxPlatform(String arch, boolean is64) {
if (isArmArchitecture(arch)) {
return is64 ? Platform.Linux_ARM64 : Platform.Linux_ARM32;
}
if (isX86Architecture(arch)) {
if (!is64) {
throw unsupported32Bit("Linux");
}
return Platform.Linux64;
}
throw new UnsupportedOperationException("Unsupported architecture: " + arch);
}

private Platform getMacPlatform(String arch, boolean is64) {
if (arch.startsWith("aarch")) {
return Platform.MacOSX_ARM64; // no 32-bit version
}
if (isX86Architecture(arch)) {
if (!is64) {
throw unsupported32Bit("macOS");
}
return Platform.MacOSX64;
}
throw new UnsupportedOperationException("Unsupported architecture: " + arch);
}

public Platform getPlatform() {
String os = System.getProperty("os.name").toLowerCase();
String arch = System.getProperty("os.arch").toLowerCase();
boolean is64 = is64Bit(arch);
if (os.contains("windows")) {
return getWindowsPlatform(arch, is64);
} else if (os.contains("linux") || os.contains("freebsd")
|| os.contains("sunos") || os.contains("unix")) {
return getLinuxPlatform(arch, is64);
} else if (os.contains("mac os x") || os.contains("darwin")) {
return getMacPlatform(arch, is64);
} else {
throw new UnsupportedOperationException("The specified platform: " + os + " is not supported.");
}
}

public String getBuildInfo() {
Expand Down
92 changes: 31 additions & 61 deletions jme3-core/src/main/java/com/jme3/system/Platform.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,74 +36,44 @@
*/
public enum Platform {

/**
* Microsoft Windows 32-bit AMD/Intel
*/
Windows32(Os.Windows),

/**
* Microsoft Windows 64-bit AMD/Intel
*/
Windows64(Os.Windows, true),

/**
* Microsoft Windows 32-bit ARM
*/
Windows_ARM32(Os.Windows),

/**
* Microsoft Windows 64-bit ARM
*/
Windows_ARM64(Os.Windows, true),

/**
* Linux 32-bit Intel
*/
Linux32(Os.Linux),

/**
* Linux 64-bit Intel
*/
Linux64(Os.Linux, true),

/**
* Linux 32-bit ARM
*/
Linux_ARM32(Os.Linux),

/**
* Linux 64-bit ARM
*/
Linux_ARM64(Os.Linux, true),

/**
* Apple Mac OS X 32-bit Intel
*/
MacOSX32(Os.MacOS),

/**
* Apple Mac OS X 64-bit Intel
*/
/**
* Microsoft Windows 64-bit AMD/Intel
*/
Windows64(Os.Windows, true),

/**
* Microsoft Windows 64-bit ARM
*/
Windows_ARM64(Os.Windows, true),

/**
* Linux 64-bit Intel
*/
Linux64(Os.Linux, true),

/**
* Linux 32-bit ARM
*/
Linux_ARM32(Os.Linux),

/**
* Linux 64-bit ARM
*/
Linux_ARM64(Os.Linux, true),

/**
* Apple Mac OS X 64-bit Intel
*/
MacOSX64(Os.MacOS, true),

/**
* Apple Mac OS X 64-bit ARM
*/
MacOSX_ARM64(Os.MacOS, true),

/**
* Apple Mac OS X 32 bit PowerPC
*/
MacOSX_PPC32(Os.MacOS),

/**
* Apple Mac OS X 64 bit PowerPC
*/
MacOSX_PPC64(Os.MacOS, true),

/**
* Android ARM5
*/
/**
* Android ARM5
*/
Android_ARM5(Os.Android),

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,28 +60,22 @@ public static void main(String[] args) {
}
if (args.length < 2) {
System.err.println("Usage: ExtractNativeLibraries Platform ExtractionPath");
System.err.println("Where 'Platform' is either Windows32, Windows64, Linux32, Linux64, MacOSX32 or MacOSX64");
System.err.println("Where 'Platform' is either Windows64, Linux64, or MacOSX64");
System.err.println("'ExtractionPath' is a folder to extract the binaries to.");
System.err.println("You can also use ExtractNativeLibraries getjarexcludes to get a list of excludes for the jar files that contain binaries.");
System.exit(1);
}
String path = args[1].replace('/', File.separatorChar);
File folder = new File(path);
try {
if ("Windows32".equals(args[0])) {
NativeLibraryLoader.extractNativeLibraries(Platform.Windows32, folder);
} else if ("Windows64".equals(args[0])) {
if ("Windows64".equals(args[0])) {
NativeLibraryLoader.extractNativeLibraries(Platform.Windows64, folder);
} else if ("Linux32".equals(args[0])) {
NativeLibraryLoader.extractNativeLibraries(Platform.Linux32, folder);
} else if ("Linux64".equals(args[0])) {
NativeLibraryLoader.extractNativeLibraries(Platform.Linux64, folder);
} else if ("MacOSX32".equals(args[0])) {
NativeLibraryLoader.extractNativeLibraries(Platform.MacOSX32, folder);
} else if ("MacOSX64".equals(args[0])) {
NativeLibraryLoader.extractNativeLibraries(Platform.MacOSX64, folder);
} else {
System.err.println("Please specify a platform, Windows32, Windows64, Linux32, Linux64, MacOSX32 or MacOSX64");
System.err.println("Please specify a platform, Windows64, Linux64, or MacOSX64");
System.exit(3);
}
} catch (IOException ex) {
Expand Down
15 changes: 0 additions & 15 deletions jme3-desktop/src/main/java/com/jme3/system/NativeLibraries.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,8 @@ public enum NativeLibraries {
// Delegate loading to lwjgl.
System.setProperty("org.lwjgl.librarypath",
Paths.get(libPath).getParent().toAbsolutePath().toString()))
.addNativeVariant(Platform.Windows32, "lwjgl.dll")
.addNativeVariant(Platform.Windows64, "lwjgl64.dll")
.addNativeVariant(Platform.Linux32, "liblwjgl.so")
.addNativeVariant(Platform.Linux64, "liblwjgl64.so")
.addNativeVariant(Platform.MacOSX32, "liblwjgl.dylib")
.addNativeVariant(Platform.MacOSX64, "liblwjgl.dylib")
),

Expand All @@ -68,26 +65,20 @@ public enum NativeLibraries {
* Native OpenAL audio libraries for LWJGL 2 required by jme3-lwjgl backend.
*/
OpenAL(new LibraryInfo("openal")
.addNativeVariant(Platform.Windows32, "OpenAL32.dll")
.addNativeVariant(Platform.Windows64, "OpenAL64.dll")
.addNativeVariant(Platform.Linux32, "libopenal.so")
.addNativeVariant(Platform.Linux64, "libopenal64.so")
.addNativeVariant(Platform.MacOSX32, "openal.dylib", "libopenal.dylib")
.addNativeVariant(Platform.MacOSX64, "openal.dylib", "libopenal.dylib")
),

/**
* Native bullet physics libraries required by Minie library.
*/
BulletJme(new LibraryInfo("bulletjme")
.addNativeVariant(Platform.Windows32, "native/windows/x86/bulletjme.dll", "bulletjme-x86.dll")
.addNativeVariant(Platform.Windows64, "native/windows/x86_64/bulletjme.dll", "bulletjme-x86_64.dll")
.addNativeVariant(Platform.Windows_ARM64, "native/windows/arm64/bulletjme.dll", "bulletjme-arm64.dll")
.addNativeVariant(Platform.Linux32, "native/linux/x86/libbulletjme.so", "libbulletjme-x86.so")
.addNativeVariant(Platform.Linux64, "native/linux/x86_64/libbulletjme.so", "libbulletjme-x86_64.so")
.addNativeVariant(Platform.Linux_ARM32, "native/linux/arm32/libbulletjme.so", "libbulletjme-arm32.so")
.addNativeVariant(Platform.Linux_ARM64, "native/linux/arm64/libbulletjme.so", "libbulletjme-arm64.so")
.addNativeVariant(Platform.MacOSX32, "native/osx/x86/libbulletjme.dylib", "libbulletjme-x86.dylib")
.addNativeVariant(Platform.MacOSX64, "native/osx/x86_64/libbulletjme.dylib", "libbulletjme-x86_64.dylib")
.addNativeVariant(Platform.MacOSX_ARM64, "native/osx/arm64/libbulletjme.dylib", "libbulletjme-arm64.dylib")
),
Expand All @@ -100,11 +91,8 @@ public enum NativeLibraries {
// Delegate loading to jinput.
System.setProperty("net.java.games.input.librarypath",
Paths.get(libPath).getParent().toAbsolutePath().toString()))
.addNativeVariant(Platform.Windows32, "jinput-raw.dll")
.addNativeVariant(Platform.Windows64, "jinput-raw_64.dll")
.addNativeVariant(Platform.Linux32, "libjinput-linux.so")
.addNativeVariant(Platform.Linux64, "libjinput-linux64.so")
.addNativeVariant(Platform.MacOSX32, "libjinput-osx.jnilib", "libjinput-osx.dylib")
.addNativeVariant(Platform.MacOSX64, "libjinput-osx.jnilib", "libjinput-osx.dylib")
),

Expand All @@ -113,11 +101,8 @@ public enum NativeLibraries {
* (only required on Windows)
*/
JInputDX8(new LibraryInfo("jinput-dx8")
.addNativeVariant(Platform.Windows32, "jinput-dx8.dll", null)
.addNativeVariant(Platform.Windows64, "jinput-dx8_64.dll", null)
.addNativeVariant(Platform.Linux32, null)
.addNativeVariant(Platform.Linux64, null)
.addNativeVariant(Platform.MacOSX32, null)
.addNativeVariant(Platform.MacOSX64, null)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,12 @@
* You can then extract this library (depending on platform), by
* using {@link #loadNativeLibrary(java.lang.String, boolean) }.
* <br>
* Example:<br>
* <pre>
* NativeLibraryLoader.registerNativeLibrary("mystuff", Platform.Windows32, "native/windows/mystuff.dll");
* NativeLibraryLoader.registerNativeLibrary("mystuff", Platform.Windows64, "native/windows/mystuff64.dll");
* NativeLibraryLoader.registerNativeLibrary("mystuff", Platform.Linux32, "native/linux/libmystuff.so");
* NativeLibraryLoader.registerNativeLibrary("mystuff", Platform.Linux64, "native/linux/libmystuff64.so");
* NativeLibraryLoader.registerNativeLibrary("mystuff", Platform.MacOSX32, "native/macosx/libmystuff.jnilib");
* NativeLibraryLoader.registerNativeLibrary("mystuff", Platform.MacOSX64, "native/macosx/libmystuff.jnilib");
* </pre>
* Example:<br>
* <pre>
* NativeLibraryLoader.registerNativeLibrary("mystuff", Platform.Windows64, "native/windows/mystuff64.dll");
* NativeLibraryLoader.registerNativeLibrary("mystuff", Platform.Linux64, "native/linux/libmystuff64.so");
* NativeLibraryLoader.registerNativeLibrary("mystuff", Platform.MacOSX64, "native/macosx/libmystuff.jnilib");
* </pre>
* <br>
* This will register the library. Load it via: <br>
* <pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,7 @@ protected void destroyContext() {
// freezes the application.
// On Mac it freezes the application.
// On Linux it fixes a crash with X Window System.
if (
JmeSystem.getPlatform() == Platform.Windows32 ||
JmeSystem.getPlatform() == Platform.Windows64
) {
if (JmeSystem.getPlatform() == Platform.Windows64) {
// Display.setParent(null);
}
// } catch (LWJGLException ex) {
Expand Down
Loading
Loading