From 6609ff83a7a2b8cfb12d85a386460c9b9ce07838 Mon Sep 17 00:00:00 2001 From: BreadFish64 Date: Sun, 18 Nov 2018 18:23:41 -0600 Subject: [PATCH] android: set up cmake --- CMakeLists.txt | 1 + CMakeModules/AndroidNdkModules.cmake | 6 +-- bitrise.yml | 51 ++++++++++++++++++++------ src/CMakeLists.txt | 3 ++ src/android/app/CMakeLists.txt | 8 +++- src/android/app/build.gradle | 7 ++-- src/android/app/src/main/cpp/dummy.cpp | 3 ++ src/common/CMakeLists.txt | 3 ++ 8 files changed, 61 insertions(+), 21 deletions(-) create mode 100644 src/android/app/src/main/cpp/dummy.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 094904cb69..1ba175a1d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -187,6 +187,7 @@ if (NOT Boost_FOUND) message(STATUS "Boost 1.66.0 or newer not found, falling back to externals") set(BOOST_ROOT "${PROJECT_SOURCE_DIR}/externals/boost") + set(Boost_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/externals/boost") set(Boost_NO_SYSTEM_PATHS OFF) find_package(Boost QUIET REQUIRED) endif() diff --git a/CMakeModules/AndroidNdkModules.cmake b/CMakeModules/AndroidNdkModules.cmake index 64f37fdee2..0ef51b3554 100644 --- a/CMakeModules/AndroidNdkModules.cmake +++ b/CMakeModules/AndroidNdkModules.cmake @@ -47,12 +47,12 @@ macro(android_ndk_import_module_ndk_helper) if(ANDROID) android_ndk_import_module_cpufeatures() android_ndk_import_module_native_app_glue() - + include_directories(${ANDROID_NDK}/sources/android/ndk_helper) file(GLOB _NDK_HELPER_SRCS ${ANDROID_NDK}/sources/android/ndk_helper/*.cpp ${ANDROID_NDK}/sources/android/ndk_helper/gl3stub.c) add_library(ndk_helper ${_NDK_HELPER_SRCS}) target_link_libraries(ndk_helper log android EGL GLESv2 cpufeatures native_app_glue) - + unset(_NDK_HELPER_SRCS) endif() -endmacro() \ No newline at end of file +endmacro() diff --git a/bitrise.yml b/bitrise.yml index 4da48bdb16..e6ab3d22df 100644 --- a/bitrise.yml +++ b/bitrise.yml @@ -42,19 +42,31 @@ workflows: The next change in your repository that matches any of your trigger map event will start **deploy** workflow. steps: - - activate-ssh-key@4.0.3: - run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}' - - git-clone@4.0.11: {} - cache-pull@2.0.1: {} - script@1.1.5: - title: Do anything with Script step - - install-missing-android-tools@2.2.0: + title: Install newer cmake + inputs: + - content: |- + #!/bin/bash + set -ex + sudo apt remove cmake -y + sudo apt purge --auto-remove cmake -y + sudo apt install ninja-build -y + version=3.8 + build=2 + mkdir ~/temp + cd ~/temp + wget https://cmake.org/files/v$version/cmake-$version.$build-Linux-x86_64.sh + sudo mkdir /opt/cmake + sudo sh cmake-$version.$build-Linux-x86_64.sh --prefix=/opt/cmake --skip-license --exclude-subdir + envman add --key PATH --value "/opt/cmake/bin:$PATH" + - install-missing-android-tools@2.3.3: inputs: - gradlew_path: "$PROJECT_LOCATION/gradlew" - change-android-versioncode-and-versionname@1.1.1: inputs: - build_gradle_path: "$PROJECT_LOCATION/$MODULE/build.gradle" - - android-lint@0.9.4: + - android-lint@0.9.5: inputs: - project_location: "$PROJECT_LOCATION" - module: "$MODULE" @@ -71,17 +83,32 @@ workflows: - variant: "$BUILD_VARIANT" - sign-apk@1.2.3: run_if: '{{getenv "BITRISEIO_ANDROID_KEYSTORE_URL" | ne ""}}' - - deploy-to-bitrise-io@1.3.15: {} + - deploy-to-bitrise-io@1.3.18: {} - cache-push@2.0.5: {} primary: steps: - cache-pull@2.0.1: {} - script@1.1.5: - title: Do anything with Script step - - install-missing-android-tools@2.2.0: + title: Install newer cmake inputs: - - gradlew_path: "$PROJECT_LOCATION/gradlew" - - android-lint@0.9.4: + - content: |- + #!/bin/bash + set -ex + sudo apt remove cmake -y + sudo apt purge --auto-remove cmake -y + sudo apt install ninja-build -y + version=3.8 + build=2 + mkdir ~/temp + cd ~/temp + wget https://cmake.org/files/v$version/cmake-$version.$build-Linux-x86_64.sh + sudo mkdir /opt/cmake + sudo sh cmake-$version.$build-Linux-x86_64.sh --prefix=/opt/cmake --skip-license --exclude-subdir + envman add --key PATH --value "/opt/cmake/bin:$PATH" + - install-missing-android-tools@2.3.3: + inputs: + - gradlew_path: "$PROJECT_LOCATION/gradlew" + - android-lint@0.9.5: inputs: - project_location: "$PROJECT_LOCATION" - module: "$MODULE" @@ -90,7 +117,7 @@ workflows: inputs: - variant: Debug - project_location: "$PROJECT_LOCATION" - - deploy-to-bitrise-io@1.3.15: {} + - deploy-to-bitrise-io@1.3.18: {} - cache-push@2.0.5: {} app: envs: diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 38e2e8b6af..a0c433c77e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -14,6 +14,9 @@ endif() if (ENABLE_QT) add_subdirectory(citra_qt) endif() +if (ANDROID) + add_subdirectory(android/app) +endif() if (ENABLE_WEB_SERVICE) add_subdirectory(web_service) endif() diff --git a/src/android/app/CMakeLists.txt b/src/android/app/CMakeLists.txt index af3c3f62be..6626c6f761 100644 --- a/src/android/app/CMakeLists.txt +++ b/src/android/app/CMakeLists.txt @@ -1,6 +1,10 @@ -cmake_minimum_required(VERSION 3.6.0) +cmake_minimum_required(VERSION 3.8) -# TODO: actually add files to compile +add_library(citra-android STATIC + src/main/cpp/dummy.cpp + ) # find Android's log library find_library(log-lib log) + +target_link_libraries(citra-android ${log-lib} core common inih) diff --git a/src/android/app/build.gradle b/src/android/app/build.gradle index 921f26a883..8f84571a5c 100644 --- a/src/android/app/build.gradle +++ b/src/android/app/build.gradle @@ -56,21 +56,20 @@ android { externalNativeBuild { cmake { version getCmakeVersion() - path "CMakeLists.txt" + path "../../../CMakeLists.txt" } } defaultConfig { externalNativeBuild { cmake { - cppFlags "-std=c++17" arguments "-DENABLE_QT=0", // Don't use QT "-DENABLE_SDL2=0", // Don't use SDL "-DANDROID_ARM_NEON=true", // cryptopp requires Neon to work - "-DENABLE_CUBEB=0" + "-DENABLE_CUBEB=0", "-DANDROID_STL=c++_shared" - abiFilters "arm64-v8a", "x86_64" + abiFilters "arm64-v8a" } } } diff --git a/src/android/app/src/main/cpp/dummy.cpp b/src/android/app/src/main/cpp/dummy.cpp new file mode 100644 index 0000000000..d0ef94a09d --- /dev/null +++ b/src/android/app/src/main/cpp/dummy.cpp @@ -0,0 +1,3 @@ +int dummy(int a, int b) { + return a + b; +} diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index fc196601ad..db7a346521 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -9,6 +9,9 @@ if ($ENV{CI}) elseif($ENV{APPVEYOR}) set(BUILD_REPOSITORY $ENV{APPVEYOR_REPO_NAME}) set(BUILD_TAG $ENV{APPVEYOR_REPO_TAG_NAME}) + elseif($ENV{BITRISE_IO}) + set(BUILD_REPOSITORY "$ENV{BITRISEIO_GIT_REPOSITORY_OWNER}/$ENV{BITRISEIO_GIT_REPOSITORY_SLUG}") + set(BUILD_TAG $ENV{BITRISE_GIT_TAG}) endif() # regex capture the string nightly or canary into CMAKE_MATCH_1 string(REGEX MATCH "citra-emu/citra-?(.*)" OUTVAR ${BUILD_REPOSITORY})