100 lines
2.8 KiB
Plaintext
100 lines
2.8 KiB
Plaintext
import com.android.build.api.dsl.ApplicationDefaultConfig
|
|
import com.android.build.api.dsl.CommonExtension
|
|
import com.android.build.gradle.api.AndroidBasePlugin
|
|
import java.io.ByteArrayOutputStream
|
|
|
|
plugins {
|
|
alias(libs.plugins.agp.app) apply false
|
|
alias(libs.plugins.agp.lib) apply false
|
|
alias(libs.plugins.kotlin) apply false
|
|
alias(libs.plugins.lsplugin.cmaker)
|
|
}
|
|
|
|
cmaker {
|
|
default {
|
|
arguments.addAll(
|
|
arrayOf(
|
|
"-DANDROID_STL=c++_static",
|
|
)
|
|
)
|
|
val flags = arrayOf(
|
|
"-Wno-gnu-string-literal-operator-template",
|
|
"-Wno-c++2b-extensions",
|
|
)
|
|
cFlags.addAll(flags)
|
|
cppFlags.addAll(flags)
|
|
abiFilters("arm64-v8a", "x86_64")
|
|
}
|
|
buildTypes {
|
|
if (it.name == "release") {
|
|
arguments += "-DDEBUG_SYMBOLS_PATH=${buildDir.absolutePath}/symbols"
|
|
}
|
|
}
|
|
}
|
|
|
|
val androidMinSdkVersion = 26
|
|
val androidTargetSdkVersion = 34
|
|
val androidCompileSdkVersion = 34
|
|
val androidBuildToolsVersion = "34.0.0"
|
|
val androidCompileNdkVersion = "26.3.11579264"
|
|
val androidSourceCompatibility = JavaVersion.VERSION_21
|
|
val androidTargetCompatibility = JavaVersion.VERSION_21
|
|
val managerVersionCode by extra(getVersionCode())
|
|
val managerVersionName by extra(getVersionName())
|
|
|
|
fun getGitCommitCount(): Int {
|
|
val out = ByteArrayOutputStream()
|
|
exec {
|
|
commandLine("git", "rev-list", "--count", "HEAD")
|
|
standardOutput = out
|
|
}
|
|
return out.toString().trim().toInt()
|
|
}
|
|
|
|
fun getGitDescribe(): String {
|
|
val out = ByteArrayOutputStream()
|
|
exec {
|
|
commandLine("git", "describe", "--tags", "--always")
|
|
standardOutput = out
|
|
}
|
|
return out.toString().trim()
|
|
}
|
|
|
|
fun getVersionCode(): Int {
|
|
val commitCount = getGitCommitCount()
|
|
val major = 1
|
|
return major * 10000 + commitCount + 200
|
|
}
|
|
|
|
fun getVersionName(): String {
|
|
return getGitDescribe()
|
|
}
|
|
|
|
subprojects {
|
|
plugins.withType(AndroidBasePlugin::class.java) {
|
|
extensions.configure(CommonExtension::class.java) {
|
|
compileSdk = androidCompileSdkVersion
|
|
ndkVersion = androidCompileNdkVersion
|
|
buildToolsVersion = androidBuildToolsVersion
|
|
|
|
defaultConfig {
|
|
minSdk = androidMinSdkVersion
|
|
if (this is ApplicationDefaultConfig) {
|
|
targetSdk = androidTargetSdkVersion
|
|
versionCode = managerVersionCode
|
|
versionName = managerVersionName
|
|
}
|
|
}
|
|
|
|
lint {
|
|
abortOnError = true
|
|
checkReleaseBuilds = false
|
|
}
|
|
|
|
compileOptions {
|
|
sourceCompatibility = androidSourceCompatibility
|
|
targetCompatibility = androidTargetCompatibility
|
|
}
|
|
}
|
|
}
|
|
} |