NOISSUE No more symlinks for LWJGL.
This commit is contained in:
parent
4ae0d8e0af
commit
7778c84121
@ -233,7 +233,15 @@ public class Utils
|
||||
public static void unzipNatives(File source, File targetFolder) throws IOException
|
||||
{
|
||||
ZipFile zip = new ZipFile(source);
|
||||
Set <String> toProcess = new HashSet<String>();
|
||||
|
||||
boolean applyHacks = false;
|
||||
String[] javaVersionElements = System.getProperty("java.version").split("\\.");
|
||||
int major = Integer.parseInt(javaVersionElements[1]);
|
||||
if (major >= 8)
|
||||
{
|
||||
applyHacks = true;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Enumeration entries = zip.entries();
|
||||
@ -243,7 +251,12 @@ public class Utils
|
||||
ZipEntry entry = (ZipEntry) entries.nextElement();
|
||||
|
||||
String entryName = entry.getName();
|
||||
File targetFile = new File(targetFolder, entryName);
|
||||
String fileName = entryName;
|
||||
if(applyHacks)
|
||||
{
|
||||
fileName = replaceSuffix(entryName, ".jnilib", ".dylib");
|
||||
}
|
||||
File targetFile = new File(targetFolder, fileName);
|
||||
if (targetFile.getParentFile() != null)
|
||||
{
|
||||
targetFile.getParentFile().mkdirs();
|
||||
@ -253,57 +266,11 @@ public class Utils
|
||||
continue;
|
||||
|
||||
copyStream(zip.getInputStream(entry), new BufferedOutputStream(new FileOutputStream(targetFile)));
|
||||
toProcess.add(entryName);
|
||||
}
|
||||
} finally
|
||||
{
|
||||
zip.close();
|
||||
}
|
||||
|
||||
// For java <= 7, do not do symlink hackery below.
|
||||
String[] javaVersionElements = System.getProperty("java.version").split("\\.");
|
||||
int major = Integer.parseInt(javaVersionElements[1]);
|
||||
if (major <= 7)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// for >= 8, do hackery
|
||||
for (String entryName : toProcess)
|
||||
{
|
||||
// check if we need a symlink
|
||||
String suffixFrom = null;
|
||||
String suffixTo = null;
|
||||
if(entryName.endsWith(".dylib"))
|
||||
{
|
||||
suffixFrom = ".dylib";
|
||||
suffixTo = ".jnilib";
|
||||
}
|
||||
else if(entryName.endsWith(".jnilib"))
|
||||
{
|
||||
suffixFrom = ".jnilib";
|
||||
suffixTo = ".dylib";
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
String linkName = replaceSuffix(entryName, suffixFrom, suffixTo);
|
||||
File targetFile = new File(targetFolder, entryName);
|
||||
File symlinkFile = new File(targetFolder, linkName);
|
||||
|
||||
// if the link file exists already for whatever reason, do not create symlinks
|
||||
if(symlinkFile.exists())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// create a symlink. This means we always have .jnilib and .dylib variants of the same libs.
|
||||
Path linkLink = symlinkFile.toPath();
|
||||
Path linkTarget = targetFile.toPath();
|
||||
Files.createSymbolicLink(linkLink, linkTarget);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user