Compile Git for host and Android target platforms

- Rename CrossCompileGitForAndroid.sh to CompileGitForAllTargetPlatforms.sh and support host, Android-only, and all-target modes.
- Compile a development-host Git binary at build/host-git/libgit.so for JVM tests.
- Route level and sandbox tests through GITHUG_TEST_GIT_BINARY so they exercise the compiled host Git rather than the system Git fallback.
- Cross-compile packaged Git binaries for arm64-v8a, armeabi-v7a, x86, and x86_64 Android targets.
- Remove the temporary device-bound Pull rebase instrumentation path from the previous debugging attempt.
This commit is contained in:
Joe Tretter
2026-05-07 15:26:38 -05:00
parent 565028f64a
commit 8873755490
10 changed files with 228 additions and 110 deletions

View File

@@ -152,7 +152,7 @@ class GitSandboxEngineTest {
@Test
fun nativeCompletionUsesCurrentDirectoryIncludingGitMetadata() {
val git = File("/usr/bin/git")
val git = testGitBinary()
assumeTrue(git.exists() && git.canExecute())
val root = Files.createTempDirectory("githug-completion").toFile()
try {
@@ -177,7 +177,7 @@ class GitSandboxEngineTest {
@Test
fun nativePushLevelHasDivergedStatusAndRebasesCleanly() {
val git = File("/usr/bin/git")
val git = testGitBinary()
assumeTrue(git.exists() && git.canExecute())
val root = Files.createTempDirectory("githug-push-level").toFile()
try {
@@ -221,4 +221,22 @@ class GitSandboxEngineTest {
assertTrue(output.isEmpty())
assertFalse(updatedRepo.files.any { it.name == "deleteme.txt" })
}
private fun testGitBinary(): File {
System.getenv("GITHUG_TEST_GIT_BINARY")
?.takeIf { it.isNotBlank() }
?.let { File(it) }
?.takeIf { it.exists() && it.canExecute() }
?.let { return it }
val repoHostGit = File(repoRoot(), "build/host-git/libgit.so")
if (repoHostGit.exists() && repoHostGit.canExecute()) return repoHostGit
return File("/usr/bin/git")
}
private fun repoRoot(): File {
val userDir = File(System.getProperty("user.dir") ?: ".")
return if (File(userDir, "app/build.gradle.kts").exists()) userDir else userDir.parentFile ?: userDir
}
}

View File

@@ -31,7 +31,7 @@ class LevelSolutionsTest {
@Test
fun knownSolutionsCompleteEveryLevel() {
val evidence = StringBuilder()
val gitBinary = systemGitBinary()
val gitBinary = testGitBinary()
val runtimeRoot = testSandboxRoot().apply {
deleteRecursively()
mkdirs()
@@ -120,7 +120,16 @@ class LevelSolutionsTest {
return File(appDir, "build/test-sandboxes/level-solutions")
}
fun systemGitBinary(): File {
fun testGitBinary(): File {
System.getenv("GITHUG_TEST_GIT_BINARY")
?.takeIf { it.isNotBlank() }
?.let { File(it) }
?.takeIf { it.exists() && it.canExecute() }
?.let { return it }
val repoHostGit = File(repoRoot(), "build/host-git/libgit.so")
if (repoHostGit.exists() && repoHostGit.canExecute()) return repoHostGit
val candidates = listOf(
File("/usr/bin/git"),
File("/usr/local/bin/git"),
@@ -136,6 +145,11 @@ class LevelSolutionsTest {
return File(output)
}
fun repoRoot(): File {
val userDir = File(System.getProperty("user.dir") ?: ".")
return if (File(userDir, "app/build.gradle.kts").exists()) userDir else userDir.parentFile ?: userDir
}
fun RepoState.describeForEvidence(): String = buildString {
appendLine("initialized=$initialized")
appendLine("headBranch=$headBranch")