From ccf17a849e836b418ec72f1b48c7ecc269d60218 Mon Sep 17 00:00:00 2001 From: yugecin Date: Tue, 2 Oct 2018 20:33:06 +0200 Subject: [PATCH] remove native filenames from manifest, add it in code instead what was I thinking --- build.xml | 3 -- pom.xml | 5 +-- src/itdelatrisu/opsu/NativeLoader.java | 31 ++++++------------- .../opsudance/core/InstanceContainer.java | 2 +- 4 files changed, 12 insertions(+), 29 deletions(-) diff --git a/build.xml b/build.xml index b24b89de..b670232c 100644 --- a/build.xml +++ b/build.xml @@ -119,9 +119,6 @@ then run (code is compiled automatically when you run) - - - diff --git a/pom.xml b/pom.xml index 4411ac30..79cdcbe6 100644 --- a/pom.xml +++ b/pom.xml @@ -149,9 +149,6 @@ ${mainClassName} ${XDG} - OpenAL32.dll,OpenAL64.dll,lwjgl.dll,lwjgl64.dll - liblwjgl.so,liblwjgl64.so,libopenal.so,libopenal64.so - liblwjgl.dylib,openal.dylib @@ -264,4 +261,4 @@ - \ No newline at end of file + diff --git a/src/itdelatrisu/opsu/NativeLoader.java b/src/itdelatrisu/opsu/NativeLoader.java index 840fc9b5..c6338619 100644 --- a/src/itdelatrisu/opsu/NativeLoader.java +++ b/src/itdelatrisu/opsu/NativeLoader.java @@ -19,7 +19,6 @@ package itdelatrisu.opsu; import org.newdawn.slick.util.Log; -import yugecin.opsudance.utils.ManifestWrapper; import java.io.File; import java.io.IOException; @@ -50,42 +49,32 @@ public class NativeLoader { * Unpacks natives for the current operating system to the natives directory. * @throws IOException if an I/O exception occurs */ - public static void loadNatives(JarFile jarfile, ManifestWrapper manifest) throws IOException { + public static void loadNatives(JarFile jarfile) throws IOException { if (!config.NATIVE_DIR.exists() && !config.NATIVE_DIR.mkdir()) { String msg = String.format("Could not create folder '%s'", config.NATIVE_DIR.getAbsolutePath()); throw new RuntimeException(msg); } - String osName = System.getProperty("os.name"); - String nativekey = null; + final String osName = System.getProperty("os.name"); + final String[] files; if (osName.startsWith("Win")) { - nativekey = "WinNatives"; + files = new String[] { "OpenAL32.dll", "OpenAL64.dll", "lwjgl.dll", "lwjgl64.dll" }; } else if (osName.startsWith("Linux")) { - nativekey = "NixNatives"; + files = new String[] { "liblwjgl.so", "liblwjgl64.so", "libopenal.so", "libopenal64.so" }; } else if (osName.startsWith("Mac") || osName.startsWith("Darwin")) { - nativekey = "MacNatives"; - } - - if (nativekey == null) { + files = new String[] { "liblwjgl.dylib", "openal.dylib" }; + } else { Log.warn("Cannot determine natives for os " + osName); return; } - String natives = manifest.valueOrDefault(null, nativekey, null); - if (natives == null) { - String msg = String.format("No entry for '%s' in manifest, jar is badly packed or damaged", - nativekey); - throw new RuntimeException(msg); - } - - String[] nativefiles = natives.split(","); - for (String nativefile : nativefiles) { - File unpackedFile = new File(config.NATIVE_DIR, nativefile); + for (String file : files) { + File unpackedFile = new File(config.NATIVE_DIR, file); if (unpackedFile.exists()) { continue; } - Utils.unpackFromJar(jarfile, unpackedFile, nativefile); + Utils.unpackFromJar(jarfile, unpackedFile, file); } } diff --git a/src/yugecin/opsudance/core/InstanceContainer.java b/src/yugecin/opsudance/core/InstanceContainer.java index 7195b4cf..6d2913a7 100644 --- a/src/yugecin/opsudance/core/InstanceContainer.java +++ b/src/yugecin/opsudance/core/InstanceContainer.java @@ -92,7 +92,7 @@ public class InstanceContainer { config = new Configuration(manifest); if (jarfile != null) { try { - NativeLoader.loadNatives(jarfile, manifest); + NativeLoader.loadNatives(jarfile); } catch (IOException e) { String msg = String.format("Could not unpack native(s): %s", e.getMessage()); throw new RuntimeException(msg, e);