mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-15 07:39:00 -04:00
[JRE Launcher] use java.library.path
This commit is contained in:
parent
886c8b8acf
commit
950784f81f
@ -16,6 +16,7 @@ public class JREUtils
|
|||||||
{
|
{
|
||||||
private JREUtils() {}
|
private JREUtils() {}
|
||||||
|
|
||||||
|
public static String LD_LIBRARY_PATH;
|
||||||
private static String nativeLibDir;
|
private static String nativeLibDir;
|
||||||
|
|
||||||
public static String findInLdLibPath(String libName) {
|
public static String findInLdLibPath(String libName) {
|
||||||
@ -127,31 +128,15 @@ public class JREUtils
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static void setJavaEnvironment(Context ctx, int launchType) throws Throwable {
|
|
||||||
nativeLibDir = ctx.getApplicationInfo().nativeLibraryDir;
|
|
||||||
String libName = Tools.currentArch.contains("64") ? "lib64" : "lib";
|
String libName = Tools.currentArch.contains("64") ? "lib64" : "lib";
|
||||||
|
|
||||||
StringBuilder ldLibraryPath = new StringBuilder();
|
StringBuilder ldLibraryPath = new StringBuilder();
|
||||||
/*
|
|
||||||
for (String arch : Tools.currentArch.split("/")) {
|
|
||||||
File f = new File(Tools.homeJreDir + "/lib/" + arch);
|
|
||||||
if (f.exists() && f.isDirectory()) {
|
|
||||||
ldLibraryPath.append(Tools.homeJreDir + "/lib/" + arch + "/server:");
|
|
||||||
ldLibraryPath.append(Tools.homeJreDir + "/lib/" + arch + "/jli:");
|
|
||||||
ldLibraryPath.append(Tools.homeJreDir + "/lib/" + arch + ":");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
ldLibraryPath.append(
|
ldLibraryPath.append(
|
||||||
// To make libjli.so ignore re-execute
|
// To make libjli.so ignore re-execute
|
||||||
Tools.homeJreDir + "/" + Tools.homeJreLib + "/server:" +
|
Tools.homeJreDir + "/" + Tools.homeJreLib + "/server:" +
|
||||||
Tools.homeJreDir + "/" + Tools.homeJreLib + "/jli:" +
|
Tools.homeJreDir + "/" + Tools.homeJreLib + "/jli:" +
|
||||||
Tools.homeJreDir + "/" + Tools.homeJreLib + ":"
|
Tools.homeJreDir + "/" + Tools.homeJreLib + ":"
|
||||||
);
|
);
|
||||||
|
|
||||||
ldLibraryPath.append(
|
ldLibraryPath.append(
|
||||||
"/system/" + libName + ":" +
|
"/system/" + libName + ":" +
|
||||||
"/vendor/" + libName + ":" +
|
"/vendor/" + libName + ":" +
|
||||||
@ -160,12 +145,18 @@ public class JREUtils
|
|||||||
nativeLibDir
|
nativeLibDir
|
||||||
);
|
);
|
||||||
|
|
||||||
|
LD_LIBRARY_PATH = ldLibraryPath.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setJavaEnvironment(Context ctx, int launchType) throws Throwable {
|
||||||
|
nativeLibDir = ctx.getApplicationInfo().nativeLibraryDir;
|
||||||
|
|
||||||
setEnvironment(launchType, "JAVA_HOME", Tools.homeJreDir);
|
setEnvironment(launchType, "JAVA_HOME", Tools.homeJreDir);
|
||||||
setEnvironment(launchType, "HOME", Tools.MAIN_PATH);
|
setEnvironment(launchType, "HOME", Tools.MAIN_PATH);
|
||||||
setEnvironment(launchType, "TMPDIR", ctx.getCacheDir().getAbsolutePath());
|
setEnvironment(launchType, "TMPDIR", ctx.getCacheDir().getAbsolutePath());
|
||||||
setEnvironment(launchType, "LIBGL_MIPMAP", "3");
|
setEnvironment(launchType, "LIBGL_MIPMAP", "3");
|
||||||
setEnvironment(launchType, "MESA_GLSL_CACHE_DIR", ctx.getCacheDir().getAbsolutePath());
|
setEnvironment(launchType, "MESA_GLSL_CACHE_DIR", ctx.getCacheDir().getAbsolutePath());
|
||||||
setEnvironment(launchType, "LD_LIBRARY_PATH", ldLibraryPath.toString());
|
setEnvironment(launchType, "LD_LIBRARY_PATH", LD_LIBRARY_PATH);
|
||||||
setEnvironment(launchType, "PATH", Tools.homeJreDir + "/bin:" + Os.getenv("PATH"));
|
setEnvironment(launchType, "PATH", Tools.homeJreDir + "/bin:" + Os.getenv("PATH"));
|
||||||
|
|
||||||
setEnvironment(launchType, "REGAL_GL_VENDOR", "Android");
|
setEnvironment(launchType, "REGAL_GL_VENDOR", "Android");
|
||||||
@ -189,7 +180,7 @@ public class JREUtils
|
|||||||
|
|
||||||
// REGAL_GL_EXTENSIONS
|
// REGAL_GL_EXTENSIONS
|
||||||
|
|
||||||
setLdLibraryPath(ldLibraryPath.toString());
|
setLdLibraryPath(LD_LIBRARY_PATH);
|
||||||
|
|
||||||
// return ldLibraryPath;
|
// return ldLibraryPath;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ public final class Tools
|
|||||||
String launchClassPath = generateLaunchClassPath(profile.getVersion());
|
String launchClassPath = generateLaunchClassPath(profile.getVersion());
|
||||||
System.out.println("Java Classpath: " + launchClassPath);
|
System.out.println("Java Classpath: " + launchClassPath);
|
||||||
if (LAUNCH_TYPE == LTYPE_CREATEJAVAVM) {
|
if (LAUNCH_TYPE == LTYPE_CREATEJAVAVM) {
|
||||||
javaArgList.add("-Djava.library.path=" + launchClassPath);
|
javaArgList.add("-Djava.class.path=" + launchClassPath);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
if (LAUNCH_TYPE == LTYPE_PROCESS) {
|
if (LAUNCH_TYPE == LTYPE_PROCESS) {
|
||||||
@ -204,6 +204,7 @@ public final class Tools
|
|||||||
|
|
||||||
overrideableArgList.add("-Djava.home=" + Tools.homeJreDir);
|
overrideableArgList.add("-Djava.home=" + Tools.homeJreDir);
|
||||||
overrideableArgList.add("-Djava.io.tmpdir=" + ctx.getCacheDir().getAbsolutePath());
|
overrideableArgList.add("-Djava.io.tmpdir=" + ctx.getCacheDir().getAbsolutePath());
|
||||||
|
overrideableArgList.add("-Djava.library.path=" + JREUtils.LD_LIBRARY_PATH);
|
||||||
|
|
||||||
// Should be compatible?
|
// Should be compatible?
|
||||||
// overrideableArgList.add("-Dos.name=Android");
|
// overrideableArgList.add("-Dos.name=Android");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user