Auto-commit after successful build: update app gameplay/UI, improve build setup
Changed files:\nCrossCompileGitForAndroid.sh app/build.gradle.kts app/src/main/java/com/kawomi/githugandroid/GitRuntime.kt app/src/main/jniLibs/arm64-v8a/libgit.so
This commit is contained in:
@@ -2,6 +2,7 @@ package com.kawomi.githugandroid
|
||||
|
||||
import android.os.Build
|
||||
import android.content.Context
|
||||
import android.content.pm.ApplicationInfo
|
||||
import java.io.File
|
||||
|
||||
class GitRepositoryRuntime(private val context: Context) {
|
||||
@@ -9,7 +10,7 @@ class GitRepositoryRuntime(private val context: Context) {
|
||||
private val extractedGitDir = File(context.filesDir, "native-git/bin")
|
||||
|
||||
fun startupBanner(): String {
|
||||
return if (ensureNativeGitBinary() != null) {
|
||||
return if (nativeGitBinary() != null) {
|
||||
"Welcome to GitHug Android. Native Git prototype ready."
|
||||
} else {
|
||||
"Welcome to GitHug Android. Native Git binary not bundled for this ABI yet; using in-memory fallback."
|
||||
@@ -17,7 +18,7 @@ class GitRepositoryRuntime(private val context: Context) {
|
||||
}
|
||||
|
||||
fun prepareLevel(level: Level): RepoState {
|
||||
val nativeGit = ensureNativeGitBinary()
|
||||
val nativeGit = nativeGitBinary()
|
||||
if (nativeGit == null) {
|
||||
return level.setup()
|
||||
}
|
||||
@@ -52,7 +53,7 @@ class GitRepositoryRuntime(private val context: Context) {
|
||||
}
|
||||
|
||||
fun execute(level: Level, currentRepo: RepoState, command: String): Pair<RepoState, List<String>> {
|
||||
val nativeGit = ensureNativeGitBinary()
|
||||
val nativeGit = nativeGitBinary()
|
||||
if (nativeGit == null) {
|
||||
return GitSandboxEngine.execute(currentRepo, command)
|
||||
}
|
||||
@@ -78,7 +79,8 @@ class GitRepositoryRuntime(private val context: Context) {
|
||||
return buildList {
|
||||
addAll(GitSandboxEngine.commandReferenceLines())
|
||||
add("Native Git prototype:")
|
||||
add(" extracted binary path: files/native-git/bin/git")
|
||||
add(" preferred binary path: nativeLibraryDir/libgit.so")
|
||||
add(" fallback binary path: files/native-git/bin/git")
|
||||
add(" selected ABI: ${Build.SUPPORTED_ABIS.firstOrNull() ?: "unknown"}")
|
||||
add(" helper commands: ls, pwd, cat, touch, mkdir, rm, echo")
|
||||
}
|
||||
@@ -132,7 +134,7 @@ class GitRepositoryRuntime(private val context: Context) {
|
||||
|
||||
private fun inspectSandbox(level: Level): RepoState {
|
||||
val sandbox = sandboxDir(level)
|
||||
val nativeGit = ensureNativeGitBinary()
|
||||
val nativeGit = nativeGitBinary()
|
||||
val filesOnDisk = sandbox.listFiles()
|
||||
?.filter { it.isFile && it.name != ".git" }
|
||||
.orEmpty()
|
||||
@@ -180,7 +182,22 @@ class GitRepositoryRuntime(private val context: Context) {
|
||||
)
|
||||
}
|
||||
|
||||
private fun ensureNativeGitBinary(): File? {
|
||||
private fun nativeGitBinary(): File? {
|
||||
val packaged = packagedNativeGitBinary()
|
||||
if (packaged != null) {
|
||||
return packaged
|
||||
}
|
||||
|
||||
return ensureExtractedAssetGitBinary()
|
||||
}
|
||||
|
||||
private fun packagedNativeGitBinary(): File? {
|
||||
val nativeLibraryDir = context.applicationInfo.nativeLibraryDir ?: return null
|
||||
val candidate = File(nativeLibraryDir, "libgit.so")
|
||||
return candidate.takeIf { it.exists() && it.canExecute() }
|
||||
}
|
||||
|
||||
private fun ensureExtractedAssetGitBinary(): File? {
|
||||
val extracted = File(extractedGitDir, "git")
|
||||
if (extracted.exists() && extracted.canExecute()) {
|
||||
return extracted
|
||||
|
||||
BIN
app/src/main/jniLibs/arm64-v8a/libgit.so
Executable file
BIN
app/src/main/jniLibs/arm64-v8a/libgit.so
Executable file
Binary file not shown.
Reference in New Issue
Block a user