From 7e6cf349e21c2483ee9b12b8cb4543fa545c9c01 Mon Sep 17 00:00:00 2001 From: Triang3l Date: Sat, 30 Oct 2021 00:01:27 +0300 Subject: [PATCH] [Build] Use first-party premake-androidndk (#1878) --- .gitmodules | 6 +-- .../android_studio_project/app/build.gradle | 38 +++++++++++-------- android/android_studio_project/build.gradle | 6 +-- premake5.lua | 19 ++++++---- src/xenia/ui/premake5.lua | 4 ++ third_party/FFmpeg | 2 +- third_party/premake-androidmk | 1 - third_party/premake-androidndk | 1 + tools/build/scripts/build_paths.lua | 4 +- tools/build/scripts/platform_files.lua | 4 +- xenia-build | 2 +- 11 files changed, 52 insertions(+), 35 deletions(-) delete mode 160000 third_party/premake-androidmk create mode 160000 third_party/premake-androidndk diff --git a/.gitmodules b/.gitmodules index 630625cc5..5809e562b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -64,9 +64,6 @@ [submodule "third_party/premake-cmake"] path = third_party/premake-cmake url = https://github.com/Enhex/premake-cmake.git -[submodule "third_party/premake-androidmk"] - path = third_party/premake-androidmk - url = https://github.com/Triang3l/premake-androidmk.git [submodule "third_party/date"] path = third_party/date url = https://github.com/HowardHinnant/date.git @@ -76,3 +73,6 @@ [submodule "third_party/FFmpeg"] path = third_party/FFmpeg url = https://github.com/xenia-project/FFmpeg.git +[submodule "third_party/premake-androidndk"] + path = third_party/premake-androidndk + url = https://github.com/Triang3l/premake-androidndk.git diff --git a/android/android_studio_project/app/build.gradle b/android/android_studio_project/app/build.gradle index d199beaa1..ff6acf7e2 100644 --- a/android/android_studio_project/app/build.gradle +++ b/android/android_studio_project/app/build.gradle @@ -4,23 +4,29 @@ plugins { android { compileSdkVersion 30 - buildToolsVersion "30.0.2" - ndkVersion '22.0.6917172 rc1' + buildToolsVersion '30.0.2' + ndkVersion '23.0.7599858' defaultConfig { - applicationId "jp.xenia.emulator" + applicationId 'jp.xenia.emulator' // 24 (7.0) - Vulkan. minSdkVersion 24 targetSdkVersion 30 versionCode 1 - versionName "Prototype" + versionName 'Prototype' externalNativeBuild { ndkBuild { - arguments "NDK_APPLICATION_MK:=../../../build/xenia_Application.mk" + arguments 'NDK_APPLICATION_MK:=../../../build/xenia.Application.mk', + 'PREMAKE_ANDROIDNDK_PLATFORMS:=Android-ARM64', + 'PREMAKE_ANDROIDNDK_PLATFORMS+=Android-x86_64', + // Work around "Bad file descriptor" on Windows on NDK r22+. + '--output-sync=none' } } ndk { - abiFilters 'arm64-v8a' + abiFilters 'arm64-v8a', 'x86_64' + jobs Runtime.runtime.availableProcessors() + stl 'c++_static' } } @@ -28,40 +34,40 @@ android { release { externalNativeBuild { ndkBuild { - arguments "PM5_CONFIG:=release_android" + arguments 'PREMAKE_ANDROIDNDK_CONFIGURATIONS:=Release' } } minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } debug { - applicationIdSuffix ".debug" + applicationIdSuffix '.debug' debuggable true externalNativeBuild { ndkBuild { - arguments "PM5_CONFIG:=debug_android" + arguments 'PREMAKE_ANDROIDNDK_CONFIGURATIONS:=Debug' } } } checked { - applicationIdSuffix ".checked" + applicationIdSuffix '.checked' debuggable true externalNativeBuild { ndkBuild { - arguments "PM5_CONFIG:=checked_android" + arguments 'PREMAKE_ANDROIDNDK_CONFIGURATIONS:=Checked' } } } } - flavorDimensions "distribution" + flavorDimensions 'distribution' productFlavors { github { - dimension "distribution" - applicationIdSuffix ".github" + dimension 'distribution' + applicationIdSuffix '.github' } googlePlay { - dimension "distribution" + dimension 'distribution' // TODO(Triang3l): Provide a signing config for core contributors only. } } @@ -73,7 +79,7 @@ android { externalNativeBuild { ndkBuild { - path file('../../../build/xenia_Android.mk') + path file('../../../build/xenia.wks.Android.mk') } } } \ No newline at end of file diff --git a/android/android_studio_project/build.gradle b/android/android_studio_project/build.gradle index 4d24be2c6..d51d77442 100644 --- a/android/android_studio_project/build.gradle +++ b/android/android_studio_project/build.gradle @@ -2,10 +2,10 @@ buildscript { repositories { google() - jcenter() + mavenCentral() } dependencies { - classpath "com.android.tools.build:gradle:4.1.1" + classpath 'com.android.tools.build:gradle:7.0.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files @@ -15,7 +15,7 @@ buildscript { allprojects { repositories { google() - jcenter() + mavenCentral() } } diff --git a/premake5.lua b/premake5.lua index d55843c3e..f603b59af 100644 --- a/premake5.lua +++ b/premake5.lua @@ -1,9 +1,7 @@ include("tools/build") require("third_party/premake-export-compile-commands/export-compile-commands") +require("third_party/premake-androidndk/androidndk") require("third_party/premake-cmake/cmake") --- gmake required for androidmk. -require("gmake") -require("third_party/premake-androidmk/androidmk") location(build_root) targetdir(build_bin) @@ -138,11 +136,15 @@ filter({"platforms:Linux", "language:C++", "toolset:clang", "files:*.cc or *.cpp "-stdlib=libstdc++", }) -filter("platforms:Android") +filter("platforms:Android-*") system("android") + systemversion("24") + cppstl("c++") + staticruntime("On") links({ "android", "dl", + "log", }) filter("platforms:Windows") @@ -204,9 +206,12 @@ workspace("xenia") uuid("931ef4b0-6170-4f7a-aaf2-0fece7632747") startproject("xenia-app") if os.istarget("android") then - -- Not setting architecture as that's handled by ndk-build itself. - platforms({"Android"}) - ndkstl("c++_static") + platforms({"Android-ARM64", "Android-x86_64"}) + filter("platforms:Android-ARM64") + architecture("ARM64") + filter("platforms:Android-x86_64") + architecture("x86_64") + filter({}) else architecture("x86_64") if os.istarget("linux") then diff --git a/src/xenia/ui/premake5.lua b/src/xenia/ui/premake5.lua index 93c012600..540c27154 100644 --- a/src/xenia/ui/premake5.lua +++ b/src/xenia/ui/premake5.lua @@ -14,3 +14,7 @@ project("xenia-ui") local_platform_files() removefiles({"*_demo.cc"}) removefiles({"windowed_app_main_*.cc"}) + + filter("platforms:Android-*") + -- Exports JNI functions. + wholelib("On") diff --git a/third_party/FFmpeg b/third_party/FFmpeg index e07c38c67..15ece0882 160000 --- a/third_party/FFmpeg +++ b/third_party/FFmpeg @@ -1 +1 @@ -Subproject commit e07c38c67578352e3f3e769cdac91650ea9575a9 +Subproject commit 15ece0882e8d5875051ff5b73c5a8326f7cee9f5 diff --git a/third_party/premake-androidmk b/third_party/premake-androidmk deleted file mode 160000 index 01a84c7ee..000000000 --- a/third_party/premake-androidmk +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 01a84c7eee20980ea51961c956fb26caa6907298 diff --git a/third_party/premake-androidndk b/third_party/premake-androidndk new file mode 160000 index 000000000..e6132d3f7 --- /dev/null +++ b/third_party/premake-androidndk @@ -0,0 +1 @@ +Subproject commit e6132d3f7877f9ad361c634db35b708c41075e3a diff --git a/tools/build/scripts/build_paths.lua b/tools/build/scripts/build_paths.lua index e97bac0f4..5daa73a3f 100644 --- a/tools/build/scripts/build_paths.lua +++ b/tools/build/scripts/build_paths.lua @@ -7,7 +7,9 @@ build_tools = "tools/build" build_scripts = build_tools .. "/scripts" build_tools_src = build_tools .. "/src" -if os.istarget("windows") then +if os.istarget("android") then + platform_suffix = "android" +elseif os.istarget("windows") then platform_suffix = "win" else platform_suffix = "posix" diff --git a/tools/build/scripts/platform_files.lua b/tools/build/scripts/platform_files.lua index 5fffc8318..ec1579cf0 100644 --- a/tools/build/scripts/platform_files.lua +++ b/tools/build/scripts/platform_files.lua @@ -25,7 +25,7 @@ local function match_platform_files(base_path, base_match) base_path.."/"..base_match.."_win.h", base_path.."/"..base_match.."_win.cc", }) - filter("platforms:Linux or Android") + filter("platforms:Linux or Android-*") files({ base_path.."/"..base_match.."_posix.h", base_path.."/"..base_match.."_posix.cc", @@ -41,7 +41,7 @@ local function match_platform_files(base_path, base_match) base_path.."/"..base_match.."_gtk.h", base_path.."/"..base_match.."_gtk.cc", }) - filter("platforms:Android") + filter("platforms:Android-*") files({ base_path.."/"..base_match.."_android.h", base_path.."/"..base_match.."_android.cc", diff --git a/xenia-build b/xenia-build index ebcba477e..0104eac7d 100755 --- a/xenia-build +++ b/xenia-build @@ -514,7 +514,7 @@ def run_platform_premake(target_os_override=None, cc='clang', devenv=None): vs_version = os.environ['VSVERSION'] devenv = 'vs' + vs_version elif target_os == 'android': - devenv = 'androidmk' + devenv = 'androidndk' else: devenv = 'gmake2' if target_os != 'linux':