From 225e326420744e8b60ed57ba5f70d5c5cd62629a Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 18 Nov 2014 09:39:43 -0800 Subject: [PATCH] being to rebuild gvr-interface deploy with androiddeployqt --- cmake/android/AndroidManifest.xml.in | 41 +++++++++++++--- cmake/android/Apk.cmake | 6 +-- cmake/android/QtCreateAPK.cmake | 68 +++++++++++++++++++++++++++ cmake/android/deployment-file.json.in | 14 ++++++ cmake/android/strings.xml.in | 2 +- gvr-interface/CMakeLists.txt | 43 ++--------------- 6 files changed, 122 insertions(+), 52 deletions(-) create mode 100644 cmake/android/QtCreateAPK.cmake create mode 100644 cmake/android/deployment-file.json.in diff --git a/cmake/android/AndroidManifest.xml.in b/cmake/android/AndroidManifest.xml.in index a5f7bd01ce..0030ee3e27 100755 --- a/cmake/android/AndroidManifest.xml.in +++ b/cmake/android/AndroidManifest.xml.in @@ -2,15 +2,42 @@ - - - - - + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cmake/android/Apk.cmake b/cmake/android/Apk.cmake index 3b70cc22d4..d5466da87b 100755 --- a/cmake/android/Apk.cmake +++ b/cmake/android/Apk.cmake @@ -72,11 +72,7 @@ macro(android_create_apk name apk_directory shared_libraries static_libraries ja if(ANDROID_APK_CREATE) # Construct the current package name and theme set(ANDROID_APK_PACKAGE "${ANDROID_APK_TOP_LEVEL_DOMAIN}.${ANDROID_APK_DOMAIN}.${ANDROID_APK_SUBDOMAIN}") - if(ANDROID_APK_FULLSCREEN) - set(ANDROID_APK_THEME "android:theme=\"@android:style/Theme.NoTitleBar.Fullscreen\"") - else() - set(ANDROID_APK_THEME "") - endif() + set(ANDROID_NAME ${name}) if(CMAKE_BUILD_TYPE MATCHES Debug) set(ANDROID_APK_DEBUGGABLE "true") diff --git a/cmake/android/QtCreateAPK.cmake b/cmake/android/QtCreateAPK.cmake new file mode 100644 index 0000000000..47bb22586b --- /dev/null +++ b/cmake/android/QtCreateAPK.cmake @@ -0,0 +1,68 @@ +# +# QtCreateAPK.cmake +# +# Created by Stephen Birarda on 11/18/14. +# Copyright 2013 High Fidelity, Inc. +# +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# + +# +# OPTIONS +# These options will modify how QtCreateAPK behaves. May be useful if somebody wants to fork. +# For High Fidelity purposes these should not need to be changed. +# +set(ANDROID_APK_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/apk") + + +set(ANDROID_THIS_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) # Directory this CMake file is in + +macro(qt_create_apk) + if(ANDROID_APK_FULLSCREEN) + set(ANDROID_APK_THEME "android:theme=\"@android:style/Theme.NoTitleBar.Fullscreen\"") + else() + set(ANDROID_APK_THEME "") + endif() + + if (CMAKE_BUILD_TYPE MATCHES Debug) + set(ANDROID_APK_DEBUGGABLE "true") + set(ANDROID_APK_RELEASE_LOCAL "0") + else () + set(ANDROID_APK_DEBUGGABLE "false") + set(ANDROID_APK_RELEASE_LOCAL ${ANDROID_APK_RELEASE}) + endif () + + # Create "AndroidManifest.xml" + configure_file("${ANDROID_THIS_DIRECTORY}/AndroidManifest.xml.in" "${ANDROID_APK_DIRECTORY}/AndroidManifest.xml") + + # Create "res/values/strings.xml" + configure_file("${ANDROID_THIS_DIRECTORY}/strings.xml.in" "${ANDROID_APK_DIRECTORY}/res/values/strings.xml") + + # figure out where the qt dir is + get_filename_component(_QT_DIR "${QT_CMAKE_PREFIX_PATH}/../../../" ABSOLUTE) + + # find androiddeployqt + find_program(ANDROID_DEPLOY_QT androiddeployqt HINTS "${_QT_DIR}/bin") + + # set the path to our app shared library + set(EXECUTABLE_DESTINATION_PATH "${CMAKE_BINARY_DIR}/libs/${ANDROID_ABI}/lib${TARGET_NAME}.so") + + # add our dependencies to the deployment file + get_property(_DEPENDENCIES TARGET ${TARGET_NAME} PROPERTY INTERFACE_LINK_LIBRARIES) + set(_DEPS_LIST) + message(${_DEPENDENCIES}) + foreach(_DEP IN LISTS _DEPENDENCIES) + if(NOT _DEP MATCHES "Qt5::.*") + get_property(_DEP_LOCATION TARGET ${_DEP} PROPERTY "LOCATION_${CMAKE_BUILD_TYPE}") + list(APPEND _DEPS_LIST ${_DEP_LOCATION}) + endif() + endforeach() + string(REPLACE ";" "," _DEPS "${_DEPS_LIST}") + configure_file("${ANDROID_THIS_DIRECTORY}/deployment-file.json.in" "${TARGET_NAME}-deployment.json") + + # Uninstall previous version from the device/emulator (else we may get e.g. signature conflicts) + add_custom_command(TARGET ${TARGET_NAME} + COMMAND adb uninstall ${ANDROID_APK_PACKAGE} + ) +endmacro() \ No newline at end of file diff --git a/cmake/android/deployment-file.json.in b/cmake/android/deployment-file.json.in new file mode 100644 index 0000000000..aa4140e36a --- /dev/null +++ b/cmake/android/deployment-file.json.in @@ -0,0 +1,14 @@ +{ + "qt": "@QTDIR@", + "sdk": "@ANDROID_SDK_ROOT@", + "ndk": "@ANDROID_NDK@", + "toolchain-prefix": "@ANDROID_TOOLCHAIN@", + "tool-prefix": "@ANDROID_TOOLCHAIN@", + "toolchain-version": "@ANDROID_GCC_VERSION@", + "ndk-host": "@_HOST@", + "target-architecture": "@ANDROID_ABI@", + "application-binary": "@EXECUTABLE_DESTINATION_PATH@", + "android-extra-libs": "@_DEPS@", + "android-extra-plugins": "@CMAKE_PREFIX_PATH@/share,@CMAKE_PREFIX_PATH@/lib/qml", + "android-package-source-directory": "@ANDROID_APK_DIR@" +} diff --git a/cmake/android/strings.xml.in b/cmake/android/strings.xml.in index b72f92bb6d..b1efc9f558 100755 --- a/cmake/android/strings.xml.in +++ b/cmake/android/strings.xml.in @@ -3,5 +3,5 @@ - ${ANDROID_NAME} + ${ANDROID_APP_NAME} diff --git a/gvr-interface/CMakeLists.txt b/gvr-interface/CMakeLists.txt index c07f14e8e3..6ab9f914a6 100644 --- a/gvr-interface/CMakeLists.txt +++ b/gvr-interface/CMakeLists.txt @@ -1,14 +1,8 @@ set(TARGET_NAME gvr-interface) -set(${TARGET_NAME}_SRCS - ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c -) - set(${TARGET_NAME}_SHARED true) setup_hifi_library() -include_directories(${ANDROID_NDK}/sources/android/native_app_glue) - include_glm() set(REQUIRED_HIFI_LIBRARIES "shared" "networking") @@ -16,38 +10,9 @@ set(REQUIRED_HIFI_LIBRARIES "shared" "networking") link_hifi_libraries(${REQUIRED_HIFI_LIBRARIES}) link_shared_dependencies() -target_link_libraries(${TARGET_NAME} log android) -set_target_properties(${TARGET_NAME} PROPERTIES COMPILE_DEFINITIONS "ANDROID") - +set(ANDROID_APP_NAME Interface) set(ANDROID_API_LEVEL 19) -set(ARM_TARGET "armeabi-v7a") +set(ANDROID_APK_PACKAGE io.highfidelity.io) +set(ANDROID_APK_FULLSCREEN true) -foreach(TARGET_LINK_LIBRARY ${${TARGET_NAME}_LIBRARIES_TO_LINK}) - get_filename_component(LIB_EXTENSION ${TARGET_LINK_LIBRARY} NAME_WE) - - if (LIB_EXTENSION STREQUAL "so") - list(APPEND TARGET_SHARED_LIBRARIES ${TARGET_LINK_LIBRARY}) - else () - list(APPEND TARGET_STATIC_LIBRARIES ${TARGET_LINK_LIBRARY}) - endif () - -endforeach() - -# append each of the hifi shared libraries to our list of libs to link -foreach(HIFI_STATIC_LIBRARY ${REQUIRED_HIFI_LIBRARIES}) - list(APPEND TARGET_STATIC_LIBRARIES "${LIBRARY_OUTPUT_PATH}/lib${HIFI_STATIC_LIBRARY}.a") -endforeach() - -list(APPEND TARGET_SHARED_LIBRARIES "${LIBRARY_OUTPUT_PATH}/lib${TARGET_NAME}.so") - -set(TARGET_JAR_LIBRARIES "${QT_CMAKE_PREFIX_PATH}/../../jar/QtAndroid-bundled.jar") - -android_create_apk( - ${TARGET_NAME} - "${CMAKE_BINARY_DIR}/apk" - "${TARGET_SHARED_LIBRARIES}" - "${TARGET_STATIC_LIBRARIES}" - "${TARGET_JAR_LIBRARIES}" - "${CMAKE_CURRENT_SOURCE_DIR}/assets" - "Data" -) \ No newline at end of file +qt_create_apk() \ No newline at end of file