[Build] Use first-party premake-androidndk (#1878)

This commit is contained in:
Triang3l 2021-10-30 00:01:27 +03:00
parent 2962a266b5
commit 7e6cf349e2
11 changed files with 52 additions and 35 deletions

6
.gitmodules vendored
View File

@ -64,9 +64,6 @@
[submodule "third_party/premake-cmake"] [submodule "third_party/premake-cmake"]
path = third_party/premake-cmake path = third_party/premake-cmake
url = https://github.com/Enhex/premake-cmake.git 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"] [submodule "third_party/date"]
path = third_party/date path = third_party/date
url = https://github.com/HowardHinnant/date.git url = https://github.com/HowardHinnant/date.git
@ -76,3 +73,6 @@
[submodule "third_party/FFmpeg"] [submodule "third_party/FFmpeg"]
path = third_party/FFmpeg path = third_party/FFmpeg
url = https://github.com/xenia-project/FFmpeg.git 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

View File

@ -4,23 +4,29 @@ plugins {
android { android {
compileSdkVersion 30 compileSdkVersion 30
buildToolsVersion "30.0.2" buildToolsVersion '30.0.2'
ndkVersion '22.0.6917172 rc1' ndkVersion '23.0.7599858'
defaultConfig { defaultConfig {
applicationId "jp.xenia.emulator" applicationId 'jp.xenia.emulator'
// 24 (7.0) - Vulkan. // 24 (7.0) - Vulkan.
minSdkVersion 24 minSdkVersion 24
targetSdkVersion 30 targetSdkVersion 30
versionCode 1 versionCode 1
versionName "Prototype" versionName 'Prototype'
externalNativeBuild { externalNativeBuild {
ndkBuild { 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 { ndk {
abiFilters 'arm64-v8a' abiFilters 'arm64-v8a', 'x86_64'
jobs Runtime.runtime.availableProcessors()
stl 'c++_static'
} }
} }
@ -28,40 +34,40 @@ android {
release { release {
externalNativeBuild { externalNativeBuild {
ndkBuild { ndkBuild {
arguments "PM5_CONFIG:=release_android" arguments 'PREMAKE_ANDROIDNDK_CONFIGURATIONS:=Release'
} }
} }
minifyEnabled true minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
} }
debug { debug {
applicationIdSuffix ".debug" applicationIdSuffix '.debug'
debuggable true debuggable true
externalNativeBuild { externalNativeBuild {
ndkBuild { ndkBuild {
arguments "PM5_CONFIG:=debug_android" arguments 'PREMAKE_ANDROIDNDK_CONFIGURATIONS:=Debug'
} }
} }
} }
checked { checked {
applicationIdSuffix ".checked" applicationIdSuffix '.checked'
debuggable true debuggable true
externalNativeBuild { externalNativeBuild {
ndkBuild { ndkBuild {
arguments "PM5_CONFIG:=checked_android" arguments 'PREMAKE_ANDROIDNDK_CONFIGURATIONS:=Checked'
} }
} }
} }
} }
flavorDimensions "distribution" flavorDimensions 'distribution'
productFlavors { productFlavors {
github { github {
dimension "distribution" dimension 'distribution'
applicationIdSuffix ".github" applicationIdSuffix '.github'
} }
googlePlay { googlePlay {
dimension "distribution" dimension 'distribution'
// TODO(Triang3l): Provide a signing config for core contributors only. // TODO(Triang3l): Provide a signing config for core contributors only.
} }
} }
@ -73,7 +79,7 @@ android {
externalNativeBuild { externalNativeBuild {
ndkBuild { ndkBuild {
path file('../../../build/xenia_Android.mk') path file('../../../build/xenia.wks.Android.mk')
} }
} }
} }

View File

@ -2,10 +2,10 @@
buildscript { buildscript {
repositories { repositories {
google() google()
jcenter() mavenCentral()
} }
dependencies { 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 // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files
@ -15,7 +15,7 @@ buildscript {
allprojects { allprojects {
repositories { repositories {
google() google()
jcenter() mavenCentral()
} }
} }

View File

@ -1,9 +1,7 @@
include("tools/build") include("tools/build")
require("third_party/premake-export-compile-commands/export-compile-commands") require("third_party/premake-export-compile-commands/export-compile-commands")
require("third_party/premake-androidndk/androidndk")
require("third_party/premake-cmake/cmake") require("third_party/premake-cmake/cmake")
-- gmake required for androidmk.
require("gmake")
require("third_party/premake-androidmk/androidmk")
location(build_root) location(build_root)
targetdir(build_bin) targetdir(build_bin)
@ -138,11 +136,15 @@ filter({"platforms:Linux", "language:C++", "toolset:clang", "files:*.cc or *.cpp
"-stdlib=libstdc++", "-stdlib=libstdc++",
}) })
filter("platforms:Android") filter("platforms:Android-*")
system("android") system("android")
systemversion("24")
cppstl("c++")
staticruntime("On")
links({ links({
"android", "android",
"dl", "dl",
"log",
}) })
filter("platforms:Windows") filter("platforms:Windows")
@ -204,9 +206,12 @@ workspace("xenia")
uuid("931ef4b0-6170-4f7a-aaf2-0fece7632747") uuid("931ef4b0-6170-4f7a-aaf2-0fece7632747")
startproject("xenia-app") startproject("xenia-app")
if os.istarget("android") then if os.istarget("android") then
-- Not setting architecture as that's handled by ndk-build itself. platforms({"Android-ARM64", "Android-x86_64"})
platforms({"Android"}) filter("platforms:Android-ARM64")
ndkstl("c++_static") architecture("ARM64")
filter("platforms:Android-x86_64")
architecture("x86_64")
filter({})
else else
architecture("x86_64") architecture("x86_64")
if os.istarget("linux") then if os.istarget("linux") then

View File

@ -14,3 +14,7 @@ project("xenia-ui")
local_platform_files() local_platform_files()
removefiles({"*_demo.cc"}) removefiles({"*_demo.cc"})
removefiles({"windowed_app_main_*.cc"}) removefiles({"windowed_app_main_*.cc"})
filter("platforms:Android-*")
-- Exports JNI functions.
wholelib("On")

2
third_party/FFmpeg vendored

@ -1 +1 @@
Subproject commit e07c38c67578352e3f3e769cdac91650ea9575a9 Subproject commit 15ece0882e8d5875051ff5b73c5a8326f7cee9f5

@ -1 +0,0 @@
Subproject commit 01a84c7eee20980ea51961c956fb26caa6907298

1
third_party/premake-androidndk vendored Submodule

@ -0,0 +1 @@
Subproject commit e6132d3f7877f9ad361c634db35b708c41075e3a

View File

@ -7,7 +7,9 @@ build_tools = "tools/build"
build_scripts = build_tools .. "/scripts" build_scripts = build_tools .. "/scripts"
build_tools_src = build_tools .. "/src" 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" platform_suffix = "win"
else else
platform_suffix = "posix" platform_suffix = "posix"

View File

@ -25,7 +25,7 @@ local function match_platform_files(base_path, base_match)
base_path.."/"..base_match.."_win.h", base_path.."/"..base_match.."_win.h",
base_path.."/"..base_match.."_win.cc", base_path.."/"..base_match.."_win.cc",
}) })
filter("platforms:Linux or Android") filter("platforms:Linux or Android-*")
files({ files({
base_path.."/"..base_match.."_posix.h", base_path.."/"..base_match.."_posix.h",
base_path.."/"..base_match.."_posix.cc", 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.h",
base_path.."/"..base_match.."_gtk.cc", base_path.."/"..base_match.."_gtk.cc",
}) })
filter("platforms:Android") filter("platforms:Android-*")
files({ files({
base_path.."/"..base_match.."_android.h", base_path.."/"..base_match.."_android.h",
base_path.."/"..base_match.."_android.cc", base_path.."/"..base_match.."_android.cc",

View File

@ -514,7 +514,7 @@ def run_platform_premake(target_os_override=None, cc='clang', devenv=None):
vs_version = os.environ['VSVERSION'] vs_version = os.environ['VSVERSION']
devenv = 'vs' + vs_version devenv = 'vs' + vs_version
elif target_os == 'android': elif target_os == 'android':
devenv = 'androidmk' devenv = 'androidndk'
else: else:
devenv = 'gmake2' devenv = 'gmake2'
if target_os != 'linux': if target_os != 'linux':