Clean cutover — Kotlin off NewPipeExtractor, onto uniffi.strawcore
Brings the Phase U Android-side integration onto a feature branch
where the rust wrapper now bridges to strawcore-core (the new NPE
port) instead of rustypipe.
* strawApp/build.gradle.kts — JNA dep + cargoBuild + cargoBuildHost
+ uniffiBindgen + the merge/compile task wiring. libs.newpipe
.extractor dropped.
* StrawApp.kt — uniffi.strawcore.initLogging(); NewPipe.init() gone
* 5 ViewModels (Search/VideoDetail/Player/Channel/Subscriptions)
swapped to call uniffi.strawcore.{search,streamInfo,channelInfo}
* PlayerScreen + PlaybackService adjusted for the new StreamInfo
shape (dash_mpd_url / hls_url instead of NPE's manifests)
* IosSafeHttpDataSource carried forward — strawcore-core gives us
Android-primary URLs so the iOS cap path is mostly dead code,
but kept as belt-and-suspenders for the rare HLS-fallback
* NewPipeDownloader.kt + util/Thumbnails.kt deleted
Files taken wholesale from sulkta branch — the wrapper's UniFFI
surface is identical between sulkta (rustypipe-backed) and the
current Phase-7-bridged-to-strawcore-core code, so Kotlin doesn't
care which extractor is under the hood.
This commit is contained in:
parent
25a1904330
commit
680e170773
16 changed files with 516 additions and 367 deletions
|
|
@ -95,7 +95,9 @@ dependencies {
|
|||
implementation(libs.coil.network.okhttp)
|
||||
|
||||
// NewPipeExtractor (JVM/Android-only) + its OkHttp dep
|
||||
implementation(libs.newpipe.extractor)
|
||||
// libs.newpipe.extractor — REMOVED in Path C-6. Extractor is now strawcore
|
||||
// (Rust + rustypipe via UniFFI). See rust/strawcore/ + the cargoBuild +
|
||||
// uniffiBindgen Gradle tasks below.
|
||||
implementation(libs.squareup.okhttp)
|
||||
|
||||
// JSON for SponsorBlock + Return YouTube Dislike clients
|
||||
|
|
@ -110,4 +112,95 @@ dependencies {
|
|||
implementation("androidx.media3:media3-session:1.4.1")
|
||||
// Guava ListenableFuture support for awaiting MediaController connect.
|
||||
implementation("androidx.concurrent:concurrent-futures-ktx:1.2.0")
|
||||
|
||||
// strawcore — Rust YouTube extractor via UniFFI/JNA. Built by the
|
||||
// cargoBuild + uniffiBindgen tasks below; phase U-2+ exposes search /
|
||||
// streamInfo / channelInfo to replace NewPipeExtractor.
|
||||
implementation("net.java.dev.jna:jna:5.14.0@aar")
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// Phase U-1 / Path-C-2 — Rust core build glue.
|
||||
//
|
||||
// Two tasks chain into the Android build:
|
||||
// cargoBuild — cross-compiles rust/strawcore for the four Android ABIs
|
||||
// via cargo-ndk and drops the .so files in strawApp/src/main/jniLibs/.
|
||||
// uniffiBindgen — generates the Kotlin bindings from the freshly-built lib
|
||||
// into strawApp/src/main/java/uniffi/strawcore/.
|
||||
//
|
||||
// Both depend on:
|
||||
// - cargo + rustup with the four Android targets installed
|
||||
// - cargo-ndk on PATH
|
||||
// - ANDROID_NDK_HOME pointing at an NDK with the right toolchains
|
||||
// All of that lives in the build-host container.
|
||||
// =============================================================================
|
||||
|
||||
val rustRoot = file("../rust").absolutePath
|
||||
val jniLibsDir = file("src/main/jniLibs").absolutePath
|
||||
val bindingsDir = file("src/main/java").absolutePath
|
||||
|
||||
val cargoHome: String = System.getenv("CARGO_HOME") ?: "/caches/cargo"
|
||||
val cargoBin: String = "$cargoHome/bin/cargo"
|
||||
val ndkHome: String = System.getenv("ANDROID_NDK_HOME")
|
||||
?: System.getenv("ANDROID_NDK_ROOT")
|
||||
?: "/caches/android-sdk/ndk/27.2.12479018"
|
||||
// Honor CARGO_TARGET_DIR if set (we redirect it to /caches on build-host
|
||||
// because the container's writable rootfs hits 100% before the cross-compile
|
||||
// for 4 ABIs finishes). Falls back to the default `<workspace>/target`.
|
||||
val cargoTargetDir: String = System.getenv("CARGO_TARGET_DIR")
|
||||
?: "$rustRoot/target"
|
||||
|
||||
val cargoBuild by tasks.registering(Exec::class) {
|
||||
group = "rust"
|
||||
description = "Cross-compile strawcore for all Android ABIs via cargo-ndk."
|
||||
workingDir = file(rustRoot)
|
||||
environment("ANDROID_NDK_HOME", ndkHome)
|
||||
environment("PATH", "$cargoHome/bin:${System.getenv("PATH") ?: ""}")
|
||||
commandLine = listOf(
|
||||
cargoBin, "ndk",
|
||||
"-t", "arm64-v8a",
|
||||
"-t", "armeabi-v7a",
|
||||
"-t", "x86",
|
||||
"-t", "x86_64",
|
||||
"-o", jniLibsDir,
|
||||
"build", "--release", "-p", "strawcore",
|
||||
)
|
||||
standardOutput = System.out
|
||||
errorOutput = System.err
|
||||
}
|
||||
|
||||
val cargoBuildHost by tasks.registering(Exec::class) {
|
||||
group = "rust"
|
||||
description = "Build host-arch debug strawcore so bindgen can read its UniFFI metadata."
|
||||
workingDir = file(rustRoot)
|
||||
environment("PATH", "$cargoHome/bin:${System.getenv("PATH") ?: ""}")
|
||||
commandLine = listOf(cargoBin, "build", "-p", "strawcore")
|
||||
standardOutput = System.out
|
||||
errorOutput = System.err
|
||||
}
|
||||
|
||||
val uniffiBindgen by tasks.registering(Exec::class) {
|
||||
group = "rust"
|
||||
description = "Generate Kotlin bindings for strawcore via uniffi-bindgen."
|
||||
dependsOn(cargoBuildHost)
|
||||
workingDir = file(rustRoot)
|
||||
environment("PATH", "$cargoHome/bin:${System.getenv("PATH") ?: ""}")
|
||||
commandLine = listOf(
|
||||
cargoBin, "run", "--quiet", "--bin", "uniffi-bindgen", "--",
|
||||
"generate",
|
||||
"--library", "$cargoTargetDir/debug/libstrawcore.so",
|
||||
"--crate", "strawcore",
|
||||
"--language", "kotlin",
|
||||
"--no-format",
|
||||
"--out-dir", bindingsDir,
|
||||
)
|
||||
standardOutput = System.out
|
||||
errorOutput = System.err
|
||||
}
|
||||
|
||||
// Make sure Android's JNI-libs merge picks up the freshly built .so files,
|
||||
// and Kotlin compilation can resolve the generated bindings.
|
||||
tasks.matching { it.name.startsWith("merge") && it.name.endsWith("JniLibFolders") }
|
||||
.configureEach { dependsOn(cargoBuild) }
|
||||
tasks.matching { it.name.startsWith("compile") && it.name.endsWith("Kotlin") }
|
||||
.configureEach { dependsOn(uniffiBindgen) }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue