[android] Fix build id (#3066)
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3066 Reviewed-by: crueter <crueter@eden-emu.dev> Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Co-authored-by: Caio Oliveira <caiooliveirafarias0@gmail.com> Co-committed-by: Caio Oliveira <caiooliveirafarias0@gmail.com>
This commit is contained in:
parent
f7f6a4cde4
commit
61f3ce643c
|
|
@ -61,7 +61,6 @@ android {
|
||||||
minSdk = 24
|
minSdk = 24
|
||||||
targetSdk = 36
|
targetSdk = 36
|
||||||
versionName = getGitVersion()
|
versionName = getGitVersion()
|
||||||
|
|
||||||
versionCode = autoVersion
|
versionCode = autoVersion
|
||||||
|
|
||||||
ndk {
|
ndk {
|
||||||
|
|
@ -69,9 +68,6 @@ android {
|
||||||
abiFilters += listOf("arm64-v8a")
|
abiFilters += listOf("arm64-v8a")
|
||||||
}
|
}
|
||||||
|
|
||||||
buildConfigField("String", "GIT_HASH", "\"${getGitHash()}\"")
|
|
||||||
buildConfigField("String", "BRANCH", "\"${getBranch()}\"")
|
|
||||||
|
|
||||||
externalNativeBuild {
|
externalNativeBuild {
|
||||||
cmake {
|
cmake {
|
||||||
val extraCMakeArgs =
|
val extraCMakeArgs =
|
||||||
|
|
@ -92,14 +88,14 @@ android {
|
||||||
"-DYUZU_TESTS=OFF",
|
"-DYUZU_TESTS=OFF",
|
||||||
"-DDYNARMIC_TESTS=OFF",
|
"-DDYNARMIC_TESTS=OFF",
|
||||||
*extraCMakeArgs.toTypedArray()
|
*extraCMakeArgs.toTypedArray()
|
||||||
))
|
)
|
||||||
|
)
|
||||||
|
|
||||||
abiFilters("arm64-v8a")
|
abiFilters("arm64-v8a")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
val keystoreFile = System.getenv("ANDROID_KEYSTORE_FILE")
|
val keystoreFile = System.getenv("ANDROID_KEYSTORE_FILE")
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
if (keystoreFile != null) {
|
if (keystoreFile != null) {
|
||||||
|
|
@ -162,7 +158,39 @@ android {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is really annoying but idk any other ways to fix this behavior
|
flavorDimensions.add("version")
|
||||||
|
productFlavors {
|
||||||
|
create("mainline") {
|
||||||
|
dimension = "version"
|
||||||
|
resValue("string", "app_name_suffixed", "Eden")
|
||||||
|
}
|
||||||
|
|
||||||
|
create("genshinSpoof") {
|
||||||
|
dimension = "version"
|
||||||
|
resValue("string", "app_name_suffixed", "Eden Optimized")
|
||||||
|
applicationId = "com.miHoYo.Yuanshen"
|
||||||
|
}
|
||||||
|
|
||||||
|
create("legacy") {
|
||||||
|
dimension = "version"
|
||||||
|
resValue("string", "app_name_suffixed", "Eden Legacy")
|
||||||
|
applicationId = "dev.legacy.eden_emulator"
|
||||||
|
|
||||||
|
externalNativeBuild {
|
||||||
|
cmake {
|
||||||
|
arguments.add("-DYUZU_LEGACY=ON")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
getByName("legacy") {
|
||||||
|
res.srcDirs("src/main/legacy")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// this is really annoying but idk any other ways to fix this behavior
|
||||||
applicationVariants.all {
|
applicationVariants.all {
|
||||||
val variant = this
|
val variant = this
|
||||||
when {
|
when {
|
||||||
|
|
@ -187,40 +215,6 @@ android {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
android {
|
|
||||||
flavorDimensions.add("version")
|
|
||||||
productFlavors {
|
|
||||||
create("mainline") {
|
|
||||||
dimension = "version"
|
|
||||||
resValue("string", "app_name_suffixed", "Eden")
|
|
||||||
}
|
|
||||||
|
|
||||||
create("genshinSpoof") {
|
|
||||||
dimension = "version"
|
|
||||||
resValue("string", "app_name_suffixed", "Eden Optimized")
|
|
||||||
applicationId = "com.miHoYo.Yuanshen"
|
|
||||||
}
|
|
||||||
|
|
||||||
create("legacy") {
|
|
||||||
dimension = "version"
|
|
||||||
resValue("string", "app_name_suffixed", "Eden Legacy")
|
|
||||||
applicationId = "dev.legacy.eden_emulator"
|
|
||||||
|
|
||||||
externalNativeBuild {
|
|
||||||
cmake {
|
|
||||||
arguments.add("-DYUZU_LEGACY=ON")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets {
|
|
||||||
getByName("legacy") {
|
|
||||||
res.srcDirs("src/main/legacy")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
externalNativeBuild {
|
externalNativeBuild {
|
||||||
cmake {
|
cmake {
|
||||||
version = "3.22.1"
|
version = "3.22.1"
|
||||||
|
|
@ -284,7 +278,6 @@ dependencies {
|
||||||
implementation("androidx.core:core-splashscreen:1.0.1")
|
implementation("androidx.core:core-splashscreen:1.0.1")
|
||||||
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.17.2")
|
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.17.2")
|
||||||
implementation("androidx.window:window:1.3.0")
|
implementation("androidx.window:window:1.3.0")
|
||||||
implementation("androidx.constraintlayout:constraintlayout:2.2.1")
|
|
||||||
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
|
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
|
||||||
implementation("org.commonmark:commonmark:0.22.0")
|
implementation("org.commonmark:commonmark:0.22.0")
|
||||||
implementation("androidx.navigation:navigation-fragment-ktx:2.8.9")
|
implementation("androidx.navigation:navigation-fragment-ktx:2.8.9")
|
||||||
|
|
@ -302,7 +295,9 @@ fun runGitCommand(command: List<String>): String {
|
||||||
.directory(project.rootDir)
|
.directory(project.rootDir)
|
||||||
.redirectOutput(ProcessBuilder.Redirect.PIPE)
|
.redirectOutput(ProcessBuilder.Redirect.PIPE)
|
||||||
.redirectError(ProcessBuilder.Redirect.PIPE)
|
.redirectError(ProcessBuilder.Redirect.PIPE)
|
||||||
.start().inputStream.bufferedReader().use { it.readText() }
|
.start()
|
||||||
|
.inputStream.bufferedReader()
|
||||||
|
.use { it.readText() }
|
||||||
.trim()
|
.trim()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
logger.error("Cannot find git")
|
logger.error("Cannot find git")
|
||||||
|
|
@ -326,9 +321,3 @@ fun getGitVersion(): String {
|
||||||
}
|
}
|
||||||
return versionName.ifEmpty { "0.0" }
|
return versionName.ifEmpty { "0.0" }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getGitHash(): String =
|
|
||||||
runGitCommand(listOf("git", "rev-parse", "--short", "HEAD")).ifEmpty { "dummy-hash" }
|
|
||||||
|
|
||||||
fun getBranch(): String =
|
|
||||||
runGitCommand(listOf("git", "rev-parse", "--abbrev-ref", "HEAD")).ifEmpty { "dummy-hash" }
|
|
||||||
|
|
|
||||||
|
|
@ -227,6 +227,11 @@ object NativeLibrary {
|
||||||
*/
|
*/
|
||||||
external fun isUpdateCheckerEnabled(): Boolean
|
external fun isUpdateCheckerEnabled(): Boolean
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the build version generated by CMake (BUILD_VERSION).
|
||||||
|
*/
|
||||||
|
external fun getBuildVersion(): String
|
||||||
|
|
||||||
enum class CoreError {
|
enum class CoreError {
|
||||||
ErrorSystemFiles,
|
ErrorSystemFiles,
|
||||||
ErrorSavestate,
|
ErrorSavestate,
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ import org.yuzu.yuzu_emu.R
|
||||||
import org.yuzu.yuzu_emu.databinding.FragmentAboutBinding
|
import org.yuzu.yuzu_emu.databinding.FragmentAboutBinding
|
||||||
import org.yuzu.yuzu_emu.model.HomeViewModel
|
import org.yuzu.yuzu_emu.model.HomeViewModel
|
||||||
import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins
|
import org.yuzu.yuzu_emu.utils.ViewUtils.updateMargins
|
||||||
|
import org.yuzu.yuzu_emu.NativeLibrary
|
||||||
|
|
||||||
class AboutFragment : Fragment() {
|
class AboutFragment : Fragment() {
|
||||||
private var _binding: FragmentAboutBinding? = null
|
private var _binding: FragmentAboutBinding? = null
|
||||||
|
|
@ -78,11 +79,15 @@ class AboutFragment : Fragment() {
|
||||||
binding.root.findNavController().navigate(R.id.action_aboutFragment_to_licensesFragment)
|
binding.root.findNavController().navigate(R.id.action_aboutFragment_to_licensesFragment)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.textVersionName.text = BuildConfig.VERSION_NAME
|
val buildName = getString(R.string.app_name_suffixed)
|
||||||
|
val buildVersion = NativeLibrary.getBuildVersion()
|
||||||
|
val fullVersionText = "$buildName ($buildVersion)"
|
||||||
|
|
||||||
|
binding.textVersionName.text = fullVersionText
|
||||||
binding.buttonVersionName.setOnClickListener {
|
binding.buttonVersionName.setOnClickListener {
|
||||||
val clipBoard =
|
val clipBoard =
|
||||||
requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||||
val clip = ClipData.newPlainText(getString(R.string.build), BuildConfig.GIT_HASH)
|
val clip = ClipData.newPlainText(getString(R.string.build), fullVersionText)
|
||||||
clipBoard.setPrimaryClip(clip)
|
clipBoard.setPrimaryClip(clip)
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
|
|
||||||
|
|
@ -1615,4 +1615,10 @@ JNIEXPORT jstring JNICALL Java_org_yuzu_yuzu_1emu_NativeLibrary_getUpdateUrl(
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
JNIEXPORT jstring JNICALL Java_org_yuzu_yuzu_1emu_NativeLibrary_getBuildVersion(
|
||||||
|
JNIEnv* env,
|
||||||
|
[[maybe_unused]] jobject obj) {
|
||||||
|
return env->NewStringUTF(Common::g_build_version);
|
||||||
|
}
|
||||||
|
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue