diff options
author | Robin Watts <robin.watts@artifex.com> | 2015-07-20 13:06:48 +0100 |
---|---|---|
committer | Robin Watts <robin.watts@artifex.com> | 2015-07-20 17:19:07 +0100 |
commit | 47855bdda808c98f7be9ac9eb62ecd296e118116 (patch) | |
tree | cb6246aa6e1bdf496c3d4c2d27515f15d12ae19f /platform | |
parent | 6e6250f0cfda83f8456203a7fd554977259646dd (diff) | |
download | mupdf-47855bdda808c98f7be9ac9eb62ecd296e118116.tar.xz |
Improved Android debugging support.
If we build with DEBUG set, the native section will be built
with debugging enabled.
The debuggable flag in AndroidManifest still needs to be edited
manually, but it's set explicitly false here so we can grep for
it.
Also, send stdout/stderr to text files in DEBUG builds. The path
for this may not work on all phones (it certainly works on the
LG G3, running Lollipop), but it won't hurt on anything.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/android/AndroidManifest.xml | 1 | ||||
-rw-r--r-- | platform/android/jni/Application.mk | 5 | ||||
-rw-r--r-- | platform/android/jni/mupdf.c | 12 |
3 files changed, 15 insertions, 3 deletions
diff --git a/platform/android/AndroidManifest.xml b/platform/android/AndroidManifest.xml index de914658..29c20f84 100644 --- a/platform/android/AndroidManifest.xml +++ b/platform/android/AndroidManifest.xml @@ -3,6 +3,7 @@ package="com.artifex.mupdfdemo" android:versionCode="50" android:versionName="@string/version" + android:debuggable="false" android:installLocation="auto"> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.INTERNET" /> diff --git a/platform/android/jni/Application.mk b/platform/android/jni/Application.mk index 60909b6e..4cedaf8d 100644 --- a/platform/android/jni/Application.mk +++ b/platform/android/jni/Application.mk @@ -28,8 +28,13 @@ ifdef NDK_PROFILER APP_OPTIM := debug APP_CFLAGS := -O2 else +ifdef DEBUG +APP_OPTIM := debug +APP_CFLAGS := -DDEBUG +else APP_OPTIM := release endif +endif ifdef V8_BUILD APP_STL := stlport_static endif diff --git a/platform/android/jni/mupdf.c b/platform/android/jni/mupdf.c index c701edde..a9484866 100644 --- a/platform/android/jni/mupdf.c +++ b/platform/android/jni/mupdf.c @@ -23,9 +23,6 @@ #define LOGT(...) __android_log_print(ANDROID_LOG_INFO,"alert",__VA_ARGS__) #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__) -/* Set to 1 to enable debug log traces. */ -#define DEBUG 0 - /* Enable to log rendering times (render each frame 100 times and time) */ #undef TIME_DISPLAY_LIST @@ -292,6 +289,15 @@ JNI_FN(MuPDFCore_openFile)(JNIEnv * env, jobject thiz, jstring jfilename) glo->resolution = 160; glo->alerts_initialised = 0; +#ifdef DEBUG + /* Try and send stdout/stderr to file in debug builds. This + * path may not work on all platforms, but it works on the + * LG G3, and it's no worse than not redirecting it anywhere + * on anything else. */ + freopen("/storage/emulated/0/Download/stdout.txt", "a", stdout); + freopen("/storage/emulated/0/Download/stderr.txt", "a", stderr); +#endif + filename = (*env)->GetStringUTFChars(env, jfilename, NULL); if (filename == NULL) { |