remove native filenames from manifest, add it in code instead

what was I thinking
This commit is contained in:
yugecin 2018-10-02 20:33:06 +02:00
parent dd2ac9c1f2
commit ccf17a849e
No known key found for this signature in database
GPG Key ID: 2C5AC035A7068E44
4 changed files with 12 additions and 29 deletions

View File

@ -119,9 +119,6 @@ then run (code is compiled automatically when you run)
<attribute name="Manifest-Version" value="1.0" />
<attribute name="Built-By" value="${user.name}" />
<attribute name="Main-Class" value="${main}" />
<attribute name="WinNatives" value="OpenAL32.dll,OpenAL64.dll,lwjgl.dll,lwjgl64.dll" />
<attribute name="NixNatives" value="liblwjgl.so,liblwjgl64.so,libopenal.so,libopenal64.so" />
<attribute name="MacNatives" value="liblwjgl.dylib,openal.dylib" />
</manifest>
<fileset dir="${dir.out}/classes" />
<zipfileset src="${dir.out}/lib.jar">

View File

@ -149,9 +149,6 @@
<manifestEntries>
<Main-Class>${mainClassName}</Main-Class>
<Use-XDG>${XDG}</Use-XDG>
<WinNatives>OpenAL32.dll,OpenAL64.dll,lwjgl.dll,lwjgl64.dll</WinNatives>
<NixNatives>liblwjgl.so,liblwjgl64.so,libopenal.so,libopenal64.so</NixNatives>
<MacNatives>liblwjgl.dylib,openal.dylib</MacNatives>
</manifestEntries>
</transformer>
</transformers>

View File

@ -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);
}
}

View File

@ -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);