You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
main-executable: when ANDROID_ROOT is not set, load art core libs from @libdir@/java/dex/art
This commit is contained in:
@@ -11,6 +11,10 @@
|
|||||||
// generated by meson
|
// generated by meson
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
// TODO: arguably we shouldn't rely on our install prefix being the same as art's install prefix
|
||||||
|
// maybe we can have art export a function returning it's install prefix for us
|
||||||
|
#define INSTALL_DEXDIR INSTALL_LIBDIR "/java/dex/"
|
||||||
|
|
||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
|
|
||||||
// standard Gtk Application stuff, more or less
|
// standard Gtk Application stuff, more or less
|
||||||
@@ -49,14 +53,21 @@ char *construct_classpath(char *prefix, char *path_to_prepend, char **cp_array,
|
|||||||
|
|
||||||
char *construct_boot_classpath(char *prefix, char **cp_array, size_t len)
|
char *construct_boot_classpath(char *prefix, char **cp_array, size_t len)
|
||||||
{
|
{
|
||||||
char *android_root_path = getenv("ANDROID_ROOT");
|
char *framework_dir_path;
|
||||||
char *framework_dir = "/framework/";
|
const char *android_root_path = getenv("ANDROID_ROOT");
|
||||||
char *framework_dir_path = malloc(strlen(android_root_path) + strlen(framework_dir) + 1);
|
if(!android_root_path) { // look in PREFIX by default
|
||||||
strcpy(framework_dir_path, android_root_path);
|
framework_dir_path = INSTALL_DEXDIR "/art/";
|
||||||
strcat(framework_dir_path, framework_dir);
|
}
|
||||||
|
else { // if ANDROID_ROOT is set, look there
|
||||||
|
const char *framework_dir = "/framework/";
|
||||||
|
framework_dir_path = malloc(strlen(android_root_path) + strlen(framework_dir) + 1);
|
||||||
|
strcpy(framework_dir_path, android_root_path);
|
||||||
|
strcat(framework_dir_path, framework_dir);
|
||||||
|
}
|
||||||
|
|
||||||
char *result = construct_classpath(prefix, framework_dir_path, cp_array, len);
|
char *result = construct_classpath(prefix, framework_dir_path, cp_array, len);
|
||||||
free(framework_dir_path);
|
if(android_root_path) // otherwise it's not allocated dynamically
|
||||||
|
free(framework_dir_path);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -74,10 +85,7 @@ JNIEnv* create_vm(char *api_impl_jar, char *apk_classpath, char *microg_apk) {
|
|||||||
"apache-xml-hostdex.jar",
|
"apache-xml-hostdex.jar",
|
||||||
"core-junit-hostdex.jar",
|
"core-junit-hostdex.jar",
|
||||||
"core-libart-hostdex.jar",
|
"core-libart-hostdex.jar",
|
||||||
"dex-host.jar",
|
|
||||||
"dx.jar",
|
|
||||||
"hamcrest-hostdex.jar",
|
"hamcrest-hostdex.jar",
|
||||||
"jarjar.jar",
|
|
||||||
};
|
};
|
||||||
options[0].optionString = construct_boot_classpath("-Xbootclasspath:", boot_cp_arr, ARRAY_SIZE(boot_cp_arr));
|
options[0].optionString = construct_boot_classpath("-Xbootclasspath:", boot_cp_arr, ARRAY_SIZE(boot_cp_arr));
|
||||||
|
|
||||||
@@ -107,10 +115,10 @@ JNIEnv* create_vm(char *api_impl_jar, char *apk_classpath, char *microg_apk) {
|
|||||||
// which we use to inject our JNI library into the correct classloader without having to load it from java code
|
// which we use to inject our JNI library into the correct classloader without having to load it from java code
|
||||||
bool HAXX__JavaVMExt__LoadNativeLibrary(JNIEnv* env, char *path, jobject class_loader, char** error_msg);
|
bool HAXX__JavaVMExt__LoadNativeLibrary(JNIEnv* env, char *path, jobject class_loader, char** error_msg);
|
||||||
|
|
||||||
#define API_IMPL_JAR_PATH_LIBDIR INSTALL_LIBDIR "/java/dex/api-impl.jar"
|
#define API_IMPL_JAR_PATH_LIBDIR INSTALL_DEXDIR "/translation-layer/api-impl.jar"
|
||||||
#define API_IMPL_JAR_PATH_LOCAL "./api-impl.jar"
|
#define API_IMPL_JAR_PATH_LOCAL "./api-impl.jar"
|
||||||
|
|
||||||
#define MICROG_APK_PATH_LIBDIR INSTALL_LIBDIR "/java/dex/com.google.android.gms.apk"
|
#define MICROG_APK_PATH_LIBDIR INSTALL_DEXDIR "/microg/com.google.android.gms.apk"
|
||||||
#define MICROG_APK_PATH_LOCAL "./com.google.android.gms.apk"
|
#define MICROG_APK_PATH_LOCAL "./com.google.android.gms.apk"
|
||||||
|
|
||||||
struct jni_callback_data { char *apk_main_activity_class; uint32_t window_width; uint32_t window_height;};
|
struct jni_callback_data { char *apk_main_activity_class; uint32_t window_width; uint32_t window_height;};
|
||||||
@@ -137,6 +145,7 @@ static void open(GtkApplication *app, GFile** files, gint nfiles, const gchar* h
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct stat dont_care;
|
struct stat dont_care;
|
||||||
|
// check for api-impl.jar and com.google.android.gms.apk in './' first (for running from builddir), and in system install path second
|
||||||
ret = stat(API_IMPL_JAR_PATH_LOCAL, &dont_care);
|
ret = stat(API_IMPL_JAR_PATH_LOCAL, &dont_care);
|
||||||
errno_localdir = errno;
|
errno_localdir = errno;
|
||||||
if(!ret) {
|
if(!ret) {
|
||||||
|
|||||||
Reference in New Issue
Block a user