mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-26 23:10:38 +00:00
Invert dependency to avoid compile issues
This commit is contained in:
parent
a3e5e475cd
commit
ab6fafb6eb
@ -28,6 +28,27 @@
|
||||
#include "Common/Thread/ThreadUtil.h"
|
||||
#include "Common/Data/Encoding/Utf8.h"
|
||||
|
||||
AttachDetachFunc g_attach;
|
||||
AttachDetachFunc g_detach;
|
||||
|
||||
void AttachThreadToJNI() {
|
||||
if (g_attach) {
|
||||
g_attach();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DetachThreadFromJNI() {
|
||||
if (g_detach) {
|
||||
g_detach();
|
||||
}
|
||||
}
|
||||
|
||||
void RegisterAttachDetach(AttachDetachFunc attach, AttachDetachFunc detach) {
|
||||
g_attach = attach;
|
||||
g_detach = detach;
|
||||
}
|
||||
|
||||
#if (PPSSPP_PLATFORM(ANDROID) || PPSSPP_PLATFORM(LINUX)) && !defined(_GNU_SOURCE)
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
@ -67,23 +88,6 @@ static EXCEPTION_DISPOSITION NTAPI ignore_handler(EXCEPTION_RECORD *rec,
|
||||
}
|
||||
#endif
|
||||
|
||||
void AttachThreadToJNI() {
|
||||
#if PPSSPP_PLATFORM(ANDROID)
|
||||
Android_AttachThreadToJNI();
|
||||
#else
|
||||
// Do nothing
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void DetachThreadFromJNI() {
|
||||
#if PPSSPP_PLATFORM(ANDROID)
|
||||
Android_DetachThreadFromJNI();
|
||||
#else
|
||||
// Do nothing
|
||||
#endif
|
||||
}
|
||||
|
||||
#if PPSSPP_PLATFORM(WINDOWS) && !PPSSPP_PLATFORM(UWP)
|
||||
typedef HRESULT (WINAPI *TSetThreadDescription)(HANDLE, PCWSTR);
|
||||
|
||||
|
@ -14,6 +14,10 @@ const char *GetCurrentThreadName();
|
||||
// exactly what it is is badly specified and not useful for anything.
|
||||
int GetCurrentThreadIdForDebug();
|
||||
|
||||
typedef void (*AttachDetachFunc)();
|
||||
|
||||
void RegisterAttachDetach(AttachDetachFunc attach, AttachDetachFunc detach);
|
||||
|
||||
// When you know that a thread potentially will make JNI calls, call this after setting its name.
|
||||
void AttachThreadToJNI();
|
||||
|
||||
|
@ -1,6 +1,20 @@
|
||||
================================================================
|
||||
|
||||
NOTE: These are legacy instructions for building using ndk-build.
|
||||
|
||||
We mostly only use this on CI because it's faster than gradle.
|
||||
There might also be some holdouts around still using eclipse.
|
||||
|
||||
================================================================
|
||||
|
||||
First, build the C++ static library:
|
||||
|
||||
> cd android
|
||||
> ./ab.sh
|
||||
Or
|
||||
> ./ab.cmd
|
||||
|
||||
as appropriate.
|
||||
|
||||
Start Eclipse, import the android directory as an existing project
|
||||
You need to also load the "native" project into your eclipse workspace
|
||||
|
@ -246,22 +246,6 @@ jclass findClass(const char* name) {
|
||||
return static_cast<jclass>(getEnv()->CallObjectMethod(gClassLoader, gFindClassMethod, getEnv()->NewStringUTF(name)));
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *pjvm, void *reserved) {
|
||||
INFO_LOG(SYSTEM, "JNI_OnLoad");
|
||||
gJvm = pjvm; // cache the JavaVM pointer
|
||||
auto env = getEnv();
|
||||
//replace with one of your classes in the line below
|
||||
auto randomClass = env->FindClass("org/ppsspp/ppsspp/NativeActivity");
|
||||
jclass classClass = env->GetObjectClass(randomClass);
|
||||
auto classLoaderClass = env->FindClass("java/lang/ClassLoader");
|
||||
auto getClassLoaderMethod = env->GetMethodID(classClass, "getClassLoader",
|
||||
"()Ljava/lang/ClassLoader;");
|
||||
gClassLoader = env->NewGlobalRef(env->CallObjectMethod(randomClass, getClassLoaderMethod));
|
||||
gFindClassMethod = env->GetMethodID(classLoaderClass, "findClass",
|
||||
"(Ljava/lang/String;)Ljava/lang/Class;");
|
||||
return JNI_VERSION_1_6;
|
||||
}
|
||||
|
||||
void Android_AttachThreadToJNI() {
|
||||
JNIEnv *env;
|
||||
int status = gJvm->GetEnv((void **)&env, JNI_VERSION_1_6);
|
||||
@ -289,6 +273,24 @@ void Android_DetachThreadFromJNI() {
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *pjvm, void *reserved) {
|
||||
INFO_LOG(SYSTEM, "JNI_OnLoad");
|
||||
gJvm = pjvm; // cache the JavaVM pointer
|
||||
auto env = getEnv();
|
||||
//replace with one of your classes in the line below
|
||||
auto randomClass = env->FindClass("org/ppsspp/ppsspp/NativeActivity");
|
||||
jclass classClass = env->GetObjectClass(randomClass);
|
||||
auto classLoaderClass = env->FindClass("java/lang/ClassLoader");
|
||||
auto getClassLoaderMethod = env->GetMethodID(classClass, "getClassLoader",
|
||||
"()Ljava/lang/ClassLoader;");
|
||||
gClassLoader = env->NewGlobalRef(env->CallObjectMethod(randomClass, getClassLoaderMethod));
|
||||
gFindClassMethod = env->GetMethodID(classLoaderClass, "findClass",
|
||||
"(Ljava/lang/String;)Ljava/lang/Class;");
|
||||
|
||||
RegisterAttachDetach(&Android_AttachThreadToJNI, &Android_DetachThreadFromJNI);
|
||||
return JNI_VERSION_1_6;
|
||||
}
|
||||
|
||||
// Only used in OpenGL mode.
|
||||
static void EmuThreadFunc() {
|
||||
JNIEnv *env;
|
||||
|
@ -27,8 +27,5 @@ public:
|
||||
};
|
||||
#endif
|
||||
|
||||
void Android_AttachThreadToJNI();
|
||||
void Android_DetachThreadFromJNI();
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user