mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-22 10:51:50 -05:00
android: Make hash and branch accessible from BuildConfig
This commit is contained in:
parent
f5055ca930
commit
63819af214
1 changed files with 25 additions and 0 deletions
|
@ -47,6 +47,9 @@ android {
|
||||||
versionCode autoVersion
|
versionCode autoVersion
|
||||||
versionName getVersion()
|
versionName getVersion()
|
||||||
ndk.abiFilters "arm64-v8a", "x86_64"
|
ndk.abiFilters "arm64-v8a", "x86_64"
|
||||||
|
|
||||||
|
buildConfigField "String", "GIT_HASH", "\"${getGitHash()}\""
|
||||||
|
buildConfigField "String", "BRANCH", "\"${getBranch()}\""
|
||||||
}
|
}
|
||||||
|
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
|
@ -163,3 +166,25 @@ def getVersion() {
|
||||||
|
|
||||||
return versionName
|
return versionName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def getGitHash() {
|
||||||
|
try {
|
||||||
|
def gitHash = 'git rev-parse HEAD'.execute([], project.rootDir).text.trim()
|
||||||
|
return gitHash
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e + ': Cannot find git, defaulting to dummy build hash')
|
||||||
|
}
|
||||||
|
|
||||||
|
return '0'
|
||||||
|
}
|
||||||
|
|
||||||
|
def getBranch() {
|
||||||
|
try {
|
||||||
|
def branch = 'git rev-parse --abbrev-ref HEAD'.execute([], project.rootDir).text.trim()
|
||||||
|
return branch
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e + ': Cannot find git, defaulting to dummy branch')
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'main'
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue