From 3e2192236fc28fe8947ec92039dcfc6f32669601 Mon Sep 17 00:00:00 2001 From: Graham Date: Sat, 3 Aug 2019 17:48:37 +0100 Subject: [PATCH] Add jaggl_dri implementation --- gl-dri-natives/pom.xml | 21 ++++++++++- gl-dri-natives/src/main/c/jaggl_dri.c | 29 +++++++++++++++ pom.xml | 51 ++++++++++++++++++++++++++- 3 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 gl-dri-natives/src/main/c/jaggl_dri.c diff --git a/gl-dri-natives/pom.xml b/gl-dri-natives/pom.xml index d7488926..29e8fd2b 100644 --- a/gl-dri-natives/pom.xml +++ b/gl-dri-natives/pom.xml @@ -9,7 +9,26 @@ openrs2-gl-dri-natives - jar + nar OpenRS2 GL DRI Natives + + + + + com.github.maven-nar + nar-maven-plugin + + + + + shared + dl + + + + + + + diff --git a/gl-dri-natives/src/main/c/jaggl_dri.c b/gl-dri-natives/src/main/c/jaggl_dri.c new file mode 100644 index 00000000..520d4e43 --- /dev/null +++ b/gl-dri-natives/src/main/c/jaggl_dri.c @@ -0,0 +1,29 @@ +#include "jaggl_X11_dri.h" + +#include +#include + +static void *jaggl_dri_handle; + +JNIEXPORT jboolean JNICALL Java_jaggl_X11_dri_open(JNIEnv *env, jclass cls, jstring path) { + if (jaggl_dri_handle) { + dlclose(jaggl_dri_handle); + jaggl_dri_handle = NULL; + } + + const char *path_str = (*env)->GetStringUTFChars(env, path, NULL); + jaggl_dri_handle = dlopen(path_str, RTLD_LAZY | RTLD_GLOBAL); + (*env)->ReleaseStringUTFChars(env, path, path_str); + + return jaggl_dri_handle != NULL; +} + +JNIEXPORT jboolean JNICALL Java_jaggl_X11_dri_close(JNIEnv *env, jclass cls) { + if (jaggl_dri_handle) { + dlclose(jaggl_dri_handle); + jaggl_dri_handle = NULL; + return JNI_TRUE; + } + + return JNI_FALSE; +} diff --git a/pom.xml b/pom.xml index 086e699a..3c12c81e 100644 --- a/pom.xml +++ b/pom.xml @@ -16,7 +16,6 @@ deob-annotations fernflower game - gl-dri-natives gl-natives misc-natives util @@ -97,6 +96,11 @@ + + com.github.maven-nar + nar-maven-plugin + 3.6.0 + io.github.zlika reproducible-build-maven-plugin @@ -170,6 +174,25 @@ + + com.github.maven-nar + nar-maven-plugin + true + + + + shared + false + + + + full + + + true + + + io.github.zlika reproducible-build-maven-plugin @@ -261,5 +284,31 @@ nonfree + + unix + + + unix + + + + gl-dri-natives + + + + + com.github.maven-nar + nar-maven-plugin + + + + + + + + + + +