Files
kichikuou_system3-sdl2/android/app/build.gradle
T

133 lines
4.1 KiB
Groovy

def buildAsLibrary = project.hasProperty('BUILD_AS_LIBRARY')
def buildAsApplication = !buildAsLibrary
if (buildAsApplication) {
apply plugin: 'com.android.application'
}
else {
apply plugin: 'com.android.library'
}
apply plugin: 'kotlin-android'
// SDL3 is consumed as a prebuilt Android Archive (.aar), exposed to the native
// build via prefab. Download the official .aar file into app/aars/ if not already
// present, and extract its LICENSE.txt into ../licenses for in-app display.
def sdlAars = [
[url: 'https://github.com/libsdl-org/SDL/releases/download/release-3.4.10/SDL3-devel-3.4.10-android.zip',
aar: 'SDL3-3.4.10.aar', license: 'SDL.txt'],
]
def aarsDir = file('aars')
def licensesDir = file('../licenses')
aarsDir.mkdirs()
licensesDir.mkdirs()
sdlAars.each { entry ->
def aarFile = new File(aarsDir, entry.aar)
def licenseFile = new File(licensesDir, entry.license)
if (!aarFile.exists() || !licenseFile.exists()) {
logger.lifecycle("Downloading ${entry.aar} ...")
def tmpZip = File.createTempFile('sdl-aar', '.zip')
new URL(entry.url).withInputStream { input ->
tmpZip.withOutputStream { it << input }
}
copy {
from zipTree(tmpZip)
include entry.aar
into aarsDir
}
copy {
from zipTree(tmpZip)
include 'LICENSE.txt'
into licensesDir
rename 'LICENSE.txt', entry.license
}
tmpZip.delete()
}
}
android {
if (buildAsApplication) {
namespace "io.github.kichikuou.system3"
}
buildFeatures {
prefab true
}
compileSdkVersion 34
defaultConfig {
minSdkVersion 21
targetSdkVersion 34
versionCode 17
versionName "1.7.2" + gitRevision()
externalNativeBuild {
cmake {
arguments "-DANDROID_STL=c++_static"
// abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
abiFilters 'armeabi-v7a', 'arm64-v8a'
}
}
}
signingConfigs {
release {
storeFile rootProject.file('keystore.jks')
storePassword System.getenv('KEYSTORE_PASSWORD')
keyAlias System.getenv('KEY_ALIAS')
keyPassword System.getenv('KEY_PASSWORD')
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
if (rootProject.file('keystore.jks').exists()) {
signingConfig signingConfigs.release
}
}
}
applicationVariants.all { variant ->
tasks["merge${variant.name.capitalize()}Assets"]
.dependsOn("externalNativeBuild${variant.name.capitalize()}")
}
if (!project.hasProperty('EXCLUDE_NATIVE_LIBS')) {
sourceSets.main {
jniLibs.srcDir 'libs'
assets.srcDir '../../resources'
}
aaptOptions {
// Disable asset compression for fonts.
// Without this, text rendering will be very slow.
noCompress 'ttf', 'otf'
}
externalNativeBuild {
cmake {
version '3.22.1'
path 'jni/CMakeLists.txt'
}
}
}
lint {
abortOnError false
}
if (buildAsLibrary) {
libraryVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith(".aar")) {
def fileName = "org.libsdl.app.aar"
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation files('aars/SDL3-3.4.10.aar')
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
}
static String gitRevision() {
' (git ' + "git rev-parse --short HEAD".execute().text.trim() + ')'
}