diff options
Diffstat (limited to 'app/build.gradle.kts')
| -rw-r--r-- | app/build.gradle.kts | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/app/build.gradle.kts b/app/build.gradle.kts index a81df9b..558e1dc 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,3 +1,23 @@ +import java.io.ByteArrayOutputStream +import java.time.Instant +import java.time.ZoneOffset +import java.time.format.DateTimeFormatter + +/** + * The commit this APK was built from. + * + * Exists so "which build am I running?" is answerable from the phone rather than by trusting + * that a publish worked -- a cached download looks identical to a failed publish. + */ +fun gitDescribe(): String = try { + val out = ByteArrayOutputStream() + providers.exec { + commandLine("git", "describe", "--always", "--dirty", "--abbrev=8") + }.standardOutput.asText.get().trim().ifEmpty { "unknown" } +} catch (e: Exception) { + "unknown" +} + plugins { id("com.android.application") id("org.jetbrains.kotlin.android") @@ -29,6 +49,14 @@ android { versionName = "1.0" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + buildConfigField("String", "GIT_COMMIT", "\"${gitDescribe()}\"") + buildConfigField( + "String", + "BUILD_TIME", + "\"${DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm") + .withZone(ZoneOffset.UTC).format(Instant.now())}\"", + ) + ndk { // CPython ships as native code, so every ABI included multiplies the APK size. // arm64 is the phone; x86_64 is the emulator. @@ -74,6 +102,7 @@ android { buildFeatures { compose = true + buildConfig = true } compileOptions { |
