From 8cccd75e81c7150b5bb6cf43313eab9f5ac25f63 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Fri, 26 May 2023 15:21:23 +0200 Subject: [PATCH] Android build via CMake (#13528) * the thing * the thing 2 --- CMakeLists.txt | 14 +- android/app/src/main/AndroidManifest.xml | 2 +- .../net/minetest/minetest/GameActivity.java | 2 +- android/build.gradle | 3 +- android/native/build.gradle | 22 +- android/native/jni/Android.mk | 301 ------------------ android/native/jni/Application.mk | 32 -- cmake/Modules/MinetestAndroidLibs.cmake | 31 ++ doc/compiling/README.md | 2 - src/CMakeLists.txt | 33 +- src/config.h | 22 +- src/version.cpp | 3 + util/bump_version.sh | 9 - 13 files changed, 82 insertions(+), 394 deletions(-) delete mode 100644 android/native/jni/Android.mk delete mode 100644 android/native/jni/Application.mk create mode 100644 cmake/Modules/MinetestAndroidLibs.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 798173079..448e97d06 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,9 +67,17 @@ set(ENABLE_UPDATE_CHECKER (NOT ${DEVELOPMENT_BUILD}) CACHE BOOL # Included stuff set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") +# Load default options for Android +if(ANDROID) + cmake_minimum_required(VERSION 3.20) + include(MinetestAndroidLibs) +endif() + set(IRRLICHTMT_BUILD_DIR "" CACHE PATH "Path to IrrlichtMt build directory.") -if(NOT "${IRRLICHTMT_BUILD_DIR}" STREQUAL "") +if(ANDROID) + # currently manually provided +elseif(NOT "${IRRLICHTMT_BUILD_DIR}" STREQUAL "") find_package(IrrlichtMt QUIET PATHS "${IRRLICHTMT_BUILD_DIR}" NO_DEFAULT_PATH @@ -120,7 +128,9 @@ else() endif() endif() -if(BUILD_CLIENT AND TARGET IrrlichtMt::IrrlichtMt) +if(ANDROID) + # skipped for now +elseif(BUILD_CLIENT AND TARGET IrrlichtMt::IrrlichtMt) # retrieve version somehow if(NOT IrrlichtMt_VERSION) get_target_property(IrrlichtMt_VERSION IrrlichtMt VERSION) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 32f5ae45d..a3e3d0602 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -54,7 +54,7 @@ + android:value="minetest" /> prepareAssets + # for now! +elseif (USE_GETTEXT) set(MO_FILES) foreach(LOCALE ${GETTEXT_USED_LOCALES}) diff --git a/src/config.h b/src/config.h index a4c6c9f10..30e290acf 100644 --- a/src/config.h +++ b/src/config.h @@ -1,27 +1,7 @@ -/* - If CMake is used, includes the cmake-generated cmake_config.h. - Otherwise use default values -*/ - #pragma once -#define STRINGIFY(x) #x -#define STR(x) STRINGIFY(x) - - #if defined USE_CMAKE_CONFIG_H #include "cmake_config.h" #else - #if defined (__ANDROID__) - #define PROJECT_NAME "minetest" - #define PROJECT_NAME_C "Minetest" - #define STATIC_SHAREDIR "" - #define ENABLE_UPDATE_CHECKER 0 - #define VERSION_STRING STR(VERSION_MAJOR) "." STR(VERSION_MINOR) "." STR(VERSION_PATCH) STR(VERSION_EXTRA) - #endif - #ifdef NDEBUG - #define BUILD_TYPE "Release" - #else - #define BUILD_TYPE "Debug" - #endif + #warning Missing configuration #endif diff --git a/src/version.cpp b/src/version.cpp index f2aac37df..46c9d1520 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -28,6 +28,9 @@ with this program; if not, write to the Free Software Foundation, Inc., #define VERSION_GITHASH VERSION_STRING #endif +#define STRINGIFY(x) #x +#define STR(x) STRINGIFY(x) + const char *g_version_string = VERSION_STRING; const char *g_version_hash = VERSION_GITHASH; const char *g_build_info = diff --git a/util/bump_version.sh b/util/bump_version.sh index c31cbf673..82895f768 100755 --- a/util/bump_version.sh +++ b/util/bump_version.sh @@ -105,15 +105,6 @@ set_dev_build() { sed -i -re 's/^set\(DEVELOPMENT_BUILD [A-Z]+\)$/set(DEVELOPMENT_BUILD FALSE)/' CMakeLists.txt fi - # Update Android versions - if [ "$is_dev" -eq 1 ]; then - sed -i 's/set("versionExtra", "")/set("versionExtra", "-dev")/' android/build.gradle - sed -i 's/project.ext.set("developmentBuild", 0)/project.ext.set("developmentBuild", 1)/' android/build.gradle - else - sed -i 's/set("versionExtra", "-dev")/set("versionExtra", "")/' android/build.gradle - sed -i 's/project.ext.set("developmentBuild", 1)/project.ext.set("developmentBuild", 0)/' android/build.gradle - fi - git add -f CMakeLists.txt android/build.gradle }