Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 5
ADFA-5189 | Package for arm64-v8a only#78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+191
−19
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84 ...rc/test/kotlin/com/itsaky/androidide/plugins/aiagentlocal/packaging/PrebuiltAarAbiTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| package com.itsaky.androidide.plugins.aiagentlocal.packaging | ||
| import java.io.File | ||
| import java.util.zip.ZipFile | ||
| import org.junit.Assert.assertEquals | ||
| import org.junit.Assert.assertTrue | ||
| import org.junit.Test | ||
| /** | ||
| * Guards the committed llama.cpp AAR against a bad regeneration. | ||
| * The plugin filters packaging to one ABI, so the AAR losing that ABI - or a | ||
| * partial native build - would only surface as an UnsatisfiedLinkError on device. | ||
| */ | ||
| class PrebuiltAarAbiTest { | ||
| // Gradle passes the AAR path; the relative fallback keeps an IDE test runner - which sets no | ||
| // system properties but does run from the module directory - reporting a real assertion. | ||
| private val aar: File = File(System.getProperty("prebuiltAarPath") ?: AAR_RELATIVE_PATH) | ||
| private val expectedAbi: String = System.getProperty("expectedAbi") ?: DEFAULT_ABI | ||
| // One pass over the archive; every test reads this map instead of reopening it. | ||
| private val jniLibs: Map<String, Long> by lazy { | ||
| ZipFile(aar).use { zip -> | ||
| zip.entries() | ||
| .asSequence() | ||
| .filter { !it.isDirectory && it.name.startsWith("jni/") && it.name.endsWith(".so") } | ||
| .associate { it.name to it.size } | ||
| } | ||
| } | ||
| private fun abisPresent(): Set<String> = | ||
| jniLibs.keys.map { it.removePrefix("jni/").substringBefore('/') }.toSet() | ||
| @Test | ||
| fun givenTheCommittedAar_whenLocated_thenItExists() { | ||
| assertTrue("Missing prebuilt AAR at ${aar.absolutePath}", aar.isFile) | ||
| } | ||
| @Test | ||
| fun givenTheCommittedAar_whenInspected_thenItShipsTheExpectedAbi() { | ||
| assertTrue( | ||
| "AAR carries $expectedAbi? Found ${abisPresent()}", | ||
| abisPresent().contains(expectedAbi), | ||
| ) | ||
| } | ||
| @Test | ||
| fun givenTheCommittedAar_whenInspected_thenTheExpectedAbiCarriesEveryNativeLibrary() { | ||
| // A partial native build drops one .so and fails at load time, not at build time. | ||
| val actual = jniLibs.keys | ||
| .filter { it.startsWith("jni/$expectedAbi/") } | ||
| .map { it.substringAfterLast('/') } | ||
| .toSet() | ||
| // Subset, not equality: an upstream llama.cpp bump may legitimately add a library. | ||
| assertEquals( | ||
| "Prebuilt AAR is missing native libraries (found $actual)", | ||
| emptySet<String>(), | ||
| REQUIRED_LIBS - actual, | ||
| ) | ||
| } | ||
| @Test | ||
| fun givenTheCommittedAar_whenInspected_thenTheJniWrapperIsNotEmpty() { | ||
| val size = jniLibs["jni/$expectedAbi/libllama-android.so"] ?: -1 | ||
| assertTrue("libllama-android.so is missing or empty (size=$size)", size > 0) | ||
| } | ||
| private companion object { | ||
| const val DEFAULT_ABI = "arm64-v8a" | ||
| const val AAR_RELATIVE_PATH = "libs/v8/llama-v8-release.aar" | ||
| /** The libraries llama.cpp has to produce for the wrapper to load at all. */ | ||
| val REQUIRED_LIBS = setOf( | ||
| "libggml-base.so", | ||
| "libggml-cpu.so", | ||
| "libggml.so", | ||
| "libllama-android.so", | ||
| "libllama.so", | ||
| "libomp.so", | ||
| ) | ||
| } | ||
| } |
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.