From bdb483b45a68b4453f45c8b7ff65b82bb7719498 Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Tue, 19 Apr 2016 16:27:52 +0300 Subject: [PATCH] android fixes --- .../android/android_native_app_glue_impl.d | 12 ++++++---- examples/android/AndroidManifest.xml | 4 ++-- examples/android/android_app.mk | 2 +- examples/android/build_apk.sh | 22 ++++++++++++++----- examples/android/deploy_apk.sh | 2 +- examples/android/res/values/strings.xml | 4 ++++ examples/android/watch_logs.sh | 6 +++++ 7 files changed, 38 insertions(+), 14 deletions(-) create mode 100644 examples/android/res/values/strings.xml create mode 100755 examples/android/watch_logs.sh diff --git a/3rdparty/android/android_native_app_glue_impl.d b/3rdparty/android/android_native_app_glue_impl.d index dd1d0b2d..0dc641f5 100644 --- a/3rdparty/android/android_native_app_glue_impl.d +++ b/3rdparty/android/android_native_app_glue_impl.d @@ -188,7 +188,7 @@ void app_dummy() { } -extern(C) static void android_app_destroy(android_app* android_app) { +static void android_app_destroy(android_app* android_app) { LOGV("android_app_destroy!"); free_saved_state(android_app); pthread_mutex_lock(&android_app.mutex); @@ -202,7 +202,7 @@ extern(C) static void android_app_destroy(android_app* android_app) { // Can't touch android_app object after this. } -extern(C) static void process_input(android_app* app, android_poll_source* source) { +static void process_input(android_app* app, android_poll_source* source) { AInputEvent* event = null; while (AInputQueue_getEvent(app.inputQueue, &event) >= 0) { LOGV("New input event: type=%d\n", AInputEvent_getType(event)); @@ -215,14 +215,14 @@ extern(C) static void process_input(android_app* app, android_poll_source* sourc } } -extern(C) static void process_cmd(android_app* app, android_poll_source* source) { +static void process_cmd(android_app* app, android_poll_source* source) { byte cmd = android_app_read_cmd(app); android_app_pre_exec_cmd(app, cmd); if (app.onAppCmd != null) app.onAppCmd(app, cmd); android_app_post_exec_cmd(app, cmd); } -extern(C) static void* android_app_entry(void* param) { +void* android_app_entry(void* param) { android_app* android_app = cast(android_app*)param; android_app.config = AConfiguration_new(); @@ -247,7 +247,11 @@ extern(C) static void* android_app_entry(void* param) { pthread_cond_broadcast(&android_app.cond); pthread_mutex_unlock(&android_app.mutex); + + //import core.runtime; + //rt_init(); android_main(android_app); + //rt_term(); android_app_destroy(android_app); return null; diff --git a/examples/android/AndroidManifest.xml b/examples/android/AndroidManifest.xml index 2477af8e..54af5691 100644 --- a/examples/android/AndroidManifest.xml +++ b/examples/android/AndroidManifest.xml @@ -1,7 +1,7 @@ @@ -20,7 +20,7 @@ android:configChanges="orientation|keyboardHidden"> + android:value="dlangui-activity" /> diff --git a/examples/android/android_app.mk b/examples/android/android_app.mk index 530ef26a..bd782455 100644 --- a/examples/android/android_app.mk +++ b/examples/android/android_app.mk @@ -1,7 +1,7 @@ # List application source files here # application library name ("app" -> libapp.so) -LOCAL_MODULE=native-activity +LOCAL_MODULE=dlangui-activity # applicatino source files LOCAL_SRC_FILES="\ diff --git a/examples/android/build_apk.sh b/examples/android/build_apk.sh index 6bfc2b84..87581182 100755 --- a/examples/android/build_apk.sh +++ b/examples/android/build_apk.sh @@ -15,6 +15,9 @@ echo "LDC: $LDC" # application sources . ./android_app.mk +#PLATFORM_DIR=arm +PLATFORM_DIR=armeabi-v7a + echo "\nLOCAL_MODULE: $LOCAL_MODULE" #echo "DLANGUI SOURCES: $DLANGUI_SOURCES" @@ -25,20 +28,27 @@ export CC=$NDK/toolchains/llvm/prebuilt/linux-$NDK_ARCH/bin/clang SOURCES="$LOCAL_SRC_FILES $DLANGUI_SOURCES" SOURCE_PATHS="-I./jni $DLANGUI_SOURCE_PATHS $DLANGUI_IMPORT_PATHS" -TARGET="libs/armeabi-v7a/lib$LOCAL_MODULE.so" -OBJFILE="build/armeabi-v7a/lib$LOCAL_MODULE.o" +TARGET="libs/$PLATFORM_DIR/lib$LOCAL_MODULE.so" +OBJFILE="build/$PLATFORM_DIR/lib$LOCAL_MODULE.o" LIBS="\ -L$NDK/platforms/android-19/arch-arm/usr/lib \ $LDC/lib/libphobos2-ldc.a $LDC/lib/libdruntime-ldc.a \ -lgcc \ --llog -landroid -lEGL -lGLESv3 -lGLESv1_CM -lc -lm \ +-llog \ +-landroid \ +-lEGL \ +-lGLESv3 \ +-lGLESv1_CM \ +-lc -lm \ $LOCAL_LDLIBS \ " +#-lGLESv1_CM \ + LINK_OPTIONS="\ -Wl,-soname,libnative-activity.so \ ---sysroot=$NDK/platforms/android-9/arch-arm \ +--sysroot=$NDK/platforms/android-19/arch-arm \ -gcc-toolchain $NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-$NDK_ARCH \ -no-canonical-prefixes \ -target armv7-none-linux-androideabi \ @@ -51,8 +61,8 @@ LINK_OPTIONS="\ -mthumb \ " -mkdir -p libs/armeabi-v7a/ -mkdir -p build/armeabi-v7a/ +mkdir -p libs/$PLATFORM_DIR/ +mkdir -p build/$PLATFORM_DIR/ #========================================================= echo "\nCompiling $OBJFILE\n" diff --git a/examples/android/deploy_apk.sh b/examples/android/deploy_apk.sh index 6e318dbf..75c4710c 100755 --- a/examples/android/deploy_apk.sh +++ b/examples/android/deploy_apk.sh @@ -1,5 +1,5 @@ #!/bin/sh -export SDK=/home/lve/android-sdk-linux +export SDK=$HOME/android-sdk-linux $SDK/platform-tools/adb install -r bin/NativeActivity-debug.apk diff --git a/examples/android/res/values/strings.xml b/examples/android/res/values/strings.xml new file mode 100644 index 00000000..f6def934 --- /dev/null +++ b/examples/android/res/values/strings.xml @@ -0,0 +1,4 @@ + + + DlangUI Test + diff --git a/examples/android/watch_logs.sh b/examples/android/watch_logs.sh new file mode 100755 index 00000000..7888cad7 --- /dev/null +++ b/examples/android/watch_logs.sh @@ -0,0 +1,6 @@ +#!/bin/sh +export SDK=$HOME/android-sdk-linux + +$SDK/platform-tools/adb logcat | less +#$SDK/platform-tools/adb logcat | grep "native" +