mirror of
https://github.com/openai/codex.git
synced 2026-04-24 06:35:50 +00:00
Invoke cargo-ndk directly from Android Gradle
Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
@@ -21,8 +21,28 @@ val codexTargets = mapOf(
|
||||
tasks.register<Exec>("buildCodexCliNative") {
|
||||
group = "build"
|
||||
description = "Build the Android codex binary packaged into the Agent and Genie APKs."
|
||||
workingDir = repoRoot
|
||||
commandLine("just", "android-build")
|
||||
workingDir = repoRoot.resolve("codex-rs")
|
||||
environment("CARGO_TARGET_DIR", "target/android")
|
||||
val cargoArgs = mutableListOf(
|
||||
"cargo",
|
||||
"ndk",
|
||||
"--platform",
|
||||
"26",
|
||||
"-t",
|
||||
"arm64-v8a",
|
||||
"-t",
|
||||
"x86_64",
|
||||
"build",
|
||||
"-p",
|
||||
"codex-cli",
|
||||
)
|
||||
if (skipAndroidLto) {
|
||||
cargoArgs += listOf("--profile", "android-release-no-lto")
|
||||
} else {
|
||||
cargoArgs += "--release"
|
||||
}
|
||||
cargoArgs += listOf("--bin", "codex")
|
||||
commandLine(cargoArgs)
|
||||
if (skipAndroidLto) {
|
||||
environment("CODEX_ANDROID_SKIP_LTO", "1")
|
||||
}
|
||||
@@ -31,8 +51,6 @@ tasks.register<Exec>("buildCodexCliNative") {
|
||||
exclude("target/**")
|
||||
},
|
||||
).withPathSensitivity(PathSensitivity.RELATIVE)
|
||||
inputs.file(repoRoot.resolve("justfile"))
|
||||
.withPathSensitivity(PathSensitivity.RELATIVE)
|
||||
outputs.files(
|
||||
codexTargets.values.map { triple ->
|
||||
repoRoot.resolve("codex-rs/target/android/${triple}/${codexCargoProfileDir}/codex")
|
||||
|
||||
@@ -60,10 +60,10 @@ If you prefer the system Gradle install, use `gradle :app:assembleDebug` from
|
||||
The Agent/Genie prototype modules also require
|
||||
`ANDROID_AGENT_PLATFORM_STUB_SDK_ZIP` (or `-PagentPlatformStubSdkZip=...`) so
|
||||
Gradle can compile against the stub SDK jar. The Agent APK and Genie APK both
|
||||
package the Android `codex` binary as `libcodex.so`. Gradle now rebuilds that
|
||||
native binary automatically before `:app:assembleDebug` and
|
||||
`:genie:assembleDebug`, so plain APK builds no longer silently package a stale
|
||||
`libcodex.so`.
|
||||
package the Android `codex` binary as `libcodex.so`. Gradle now runs the
|
||||
equivalent of `cargo ndk ... build -p codex-cli --bin codex` automatically
|
||||
before `:app:assembleDebug` and `:genie:assembleDebug`, so plain APK builds no
|
||||
longer silently package a stale `libcodex.so`.
|
||||
|
||||
To install both APKs, assign the AGENT/GENIE roles, grant notifications, and
|
||||
optionally seed `auth.json` into the Agent sandbox:
|
||||
|
||||
Reference in New Issue
Block a user