diff options
author | Robin Watts <robin.watts@artifex.com> | 2016-11-15 17:41:15 +0000 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2016-11-15 18:30:57 +0000 |
commit | 0c28c2aad6bfebf436c13a06db70413166d15d6d (patch) | |
tree | f19d3465c12b572ebb283cdb4748149e0adade07 | |
parent | e84b0b0354a7ecf474600f55e1799d72affc2dfd (diff) | |
download | mupdf-0c28c2aad6bfebf436c13a06db70413166d15d6d.tar.xz |
Update JNI code to load 32 or 64 bit DLL as appropriate.
Make the JNI code detect whether it is running on a 32 or
64 bit machine, and change the name of the DLL appropriately.
Update Android Makefile to make mupdf_java32 instead of mupdf_java.
Update Java Makefile to make mupdf_java32 or mupdf_java64 based
on the system it is running on. This choice can be overruled by
defining BITS to be "32" or "64" before calling make.
Update Windows Solution to make mupdf_java32 or mupdf_java64 as
appropriate.
-rw-r--r-- | platform/android/example/Readme.txt | 4 | ||||
-rw-r--r-- | platform/android/viewer/jni/Android.mk | 2 | ||||
-rw-r--r-- | platform/android/viewer/jni/mupdf.c | 4 | ||||
-rw-r--r-- | platform/android/viewer/src/com/artifex/mupdfdemo/MuPDFCore.java | 2 | ||||
-rw-r--r-- | platform/java/Makefile | 7 | ||||
-rw-r--r-- | platform/java/src/com/artifex/mupdf/fitz/Context.java | 14 | ||||
-rw-r--r-- | platform/win32/javaviewerlib.vcproj | 4 |
7 files changed, 28 insertions, 9 deletions
diff --git a/platform/android/example/Readme.txt b/platform/android/example/Readme.txt index e87baf8a..7138ddcf 100644 --- a/platform/android/example/Readme.txt +++ b/platform/android/example/Readme.txt @@ -11,11 +11,11 @@ mupdf/platform/android/example - build instructions 4. copy the resulting .so file: mkdir -p ../example/mupdf/libs/armeabi-v7a - rm -f ../example/mupdf/libs/armeabi-v7a/libmupdf_java.so + rm -f ../example/mupdf/libs/armeabi-v7a/libmupdf_java32.so cp ./libs/armeabi-v7a/libmupdf_java.so ../example/mupdf/libs/armeabi-v7a/ 5. Open the example in Android Studio 6. build and run -If you modify C code, do steps 3, 4 and 6 as needed
\ No newline at end of file +If you modify C code, do steps 3, 4 and 6 as needed diff --git a/platform/android/viewer/jni/Android.mk b/platform/android/viewer/jni/Android.mk index 27f481a8..4e6038d4 100644 --- a/platform/android/viewer/jni/Android.mk +++ b/platform/android/viewer/jni/Android.mk @@ -19,7 +19,7 @@ LOCAL_C_INCLUDES := \ $(MUPDF_ROOT)/source/pdf \ $(MUPDF_ROOT)/platform/java LOCAL_CFLAGS := -DHAVE_ANDROID -LOCAL_MODULE := mupdf_java +LOCAL_MODULE := mupdf_java32 LOCAL_SRC_FILES := \ mupdf.c \ diff --git a/platform/android/viewer/jni/mupdf.c b/platform/android/viewer/jni/mupdf.c index 701390a6..581da497 100644 --- a/platform/android/viewer/jni/mupdf.c +++ b/platform/android/viewer/jni/mupdf.c @@ -290,7 +290,7 @@ JNI_FN(MuPDFCore_openFile)(JNIEnv * env, jobject thiz, jstring jfilename) jclass clazz; #ifdef NDK_PROFILER - monstartup("libmupdf_java.so"); + monstartup("libmupdf_java32.so"); #endif clazz = (*env)->GetObjectClass(env, thiz); @@ -441,7 +441,7 @@ JNI_FN(MuPDFCore_openBuffer)(JNIEnv * env, jobject thiz, jstring jmagic) const char *magic; #ifdef NDK_PROFILER - monstartup("libmupdf_java.so"); + monstartup("libmupdf_java32.so"); #endif clazz = (*env)->GetObjectClass(env, thiz); diff --git a/platform/android/viewer/src/com/artifex/mupdfdemo/MuPDFCore.java b/platform/android/viewer/src/com/artifex/mupdfdemo/MuPDFCore.java index 9d5f3818..6c105e0d 100644 --- a/platform/android/viewer/src/com/artifex/mupdfdemo/MuPDFCore.java +++ b/platform/android/viewer/src/com/artifex/mupdfdemo/MuPDFCore.java @@ -12,7 +12,7 @@ public class MuPDFCore private static boolean gs_so_available = false; static { System.out.println("Loading dll"); - System.loadLibrary("mupdf_java"); + System.loadLibrary("mupdf_java32"); System.out.println("Loaded dll"); if (gprfSupportedInternal()) { diff --git a/platform/java/Makefile b/platform/java/Makefile index 1762c512..7b4ea380 100644 --- a/platform/java/Makefile +++ b/platform/java/Makefile @@ -1,12 +1,15 @@ OS ?= $(shell uname) ifeq "$(OS)" "Darwin" -MUPDF_JAVA := libmupdf_java.jnilib +MUPDF_JAVA := libmupdf_java64.jnilib JAVA_CFLAGS := \ -I /Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/include \ -I /Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/include/darwin else -MUPDF_JAVA := libmupdf_java.so + +BITS := $(shell getconf LONG_BIT) + +MUPDF_JAVA := libmupdf_java$(BITS).so JAVA_CFLAGS := \ -I /usr/lib/jvm/java-7-openjdk-i386/include \ -I /usr/lib/jvm/java-7-openjdk-i386/include/linux \ diff --git a/platform/java/src/com/artifex/mupdf/fitz/Context.java b/platform/java/src/com/artifex/mupdf/fitz/Context.java index d8edf378..3ee91822 100644 --- a/platform/java/src/com/artifex/mupdf/fitz/Context.java +++ b/platform/java/src/com/artifex/mupdf/fitz/Context.java @@ -15,12 +15,24 @@ public class Context public static void init() { if (!inited) { inited = true; - System.loadLibrary("mupdf_java"); + System.loadLibrary(getLibraryName()); if (initNative() < 0) throw new RuntimeException("cannot initialize mupdf library"); } } + private static String getLibraryName(void) { + /* Mac OS always uses 64bit DLLs for any JDK 1.7 or above */ + if (System.getProperty("os.name").toLowerCase().contains("mac os")) { + return "mupdf_java64"; + } + String val = System.getProperty("sun.arch.data.model"); + if (val != null && val.equals("32")) { + return "mupdf_java32" + } + return "mupdf_java64"; + } + static { init(); } // FIXME: We should support the store size being changed dynamically. diff --git a/platform/win32/javaviewerlib.vcproj b/platform/win32/javaviewerlib.vcproj index 1af255e0..4a829c27 100644 --- a/platform/win32/javaviewerlib.vcproj +++ b/platform/win32/javaviewerlib.vcproj @@ -64,6 +64,7 @@ /> <Tool Name="VCLinkerTool" + OutputFile="$(OutDir)\$(ProjectName)32.dll" LinkIncremental="2" GenerateDebugInformation="true" SubSystem="2" @@ -141,6 +142,7 @@ /> <Tool Name="VCLinkerTool" + OutputFile="$(OutDir)\$(ProjectName)64.dll" LinkIncremental="1" GenerateDebugInformation="true" SubSystem="2" @@ -215,6 +217,7 @@ /> <Tool Name="VCLinkerTool" + OutputFile="$(OutDir)\$(ProjectName)32.dll" LinkIncremental="1" GenerateDebugInformation="true" SubSystem="2" @@ -292,6 +295,7 @@ /> <Tool Name="VCLinkerTool" + OutputFile="$(OutDir)\$(ProjectName)64.dll" LinkIncremental="1" GenerateDebugInformation="true" SubSystem="2" |