Home/docs/project/Building and dependencies
Building and dependencies
Building and Dependencies
liberika's Rust code builds directly with cargo. Native dependencies such as FFmpeg, dav1d, libass, and HarfBuzz are fetched as source, built inside third_party/, and managed by xtask deps. The build scripts keep CI output consistent with local builds.
Prerequisites前提#
| Target | Tools |
|---|---|
| macOS / iOS / tvOS | Xcode Command Line Tools; nasm, meson, ninja, and pkg-config (from Homebrew). |
| Windows | Inside MSYS2 (UCRT64): make, tar, pkgconf, perl, and zip. Also nasm; Python meson and ninja; and LLVM (set LIBCLANG_PATH to its bin/ directory). |
| Android | Android SDK and NDK (r29, API 26). |
| OpenHarmony | DevEco Studio with the matching SDK / NDK. |
Native dependenciesネイティブ依存#
Dependencies for release targets are fetched from upstream source at pinned versions, and the build scripts apply the patches in third_party/patches/.
| Component | Version | Description |
|---|---|---|
| FFmpeg | 8.1.2 | Wrapped in crates/erika_ffmpeg_sys. Android uses the patchset erika-android-mediacodec-v4. |
| dav1d | 1.5.1 | AV1 decoding. |
| libass | 0.17.5 | Subtitle rendering. |
| HarfBuzz | 14.2.1 | Text shaping. |
| FreeType | 2.14.3 | Font rasterization. |
| FriBidi | 1.0.16 | Bidirectional text. |
| zlib | 1.3.2 | FFmpeg dependency. |
Fetch and build results stay in the workspace's third_party/ directory; nothing is installed into system directories:
third_party/cache # Downloaded source archives third_party/src # Extracted source trees third_party/build # Build directories, split by target / profile third_party/dist # Output prefixes, split by target / profile
xtask deps依存管理#
Full build workflow
cargo run -p xtask -- deps plan # Print the dependency plan cargo run -p xtask -- deps fetch # Download and extract sources cargo run -p xtask -- deps build --all # Build the host target
| Option | Values | Default |
|---|---|---|
| --profile | lgpl / gpl-full | lgpl |
| --ffmpeg | FFmpeg format set (full, common, slim or slim,<group>) | full |
| --crt | Windows C runtime (dynamic / static) | dynamic |
| --target | See the target table below | host |
| --force | Force a rebuild of native dependencies | Off; completed outputs are reused by default |
| --all | Also builds the subtitle stack: libass + FreeType + HarfBuzz + FriBidi (fetch downloads the sources of all four as well) | Builds only the video stack |
| --jobs | Parallelism | Automatic |
The two profiles differ in FFmpeg's configure flags. lgpl disables GPL components, disables networking, and enables only the demuxers, parsers, and decoders the playback core needs. gpl-full also enables the GPL components. The default, lgpl, meets release requirements.
Build results store a build marker per target and profile, and FFmpeg and dav1d check the version, patches, and build options against it. After you change xtask/src/main.rs or third_party/patches/, run deps build --force to trigger a rebuild.
Windows / MSVC#
Since 0.3.8, host on Windows x64 and ARM64 resolves to the matching MSVC target, so the dependency directory matches a cargo build without --target. Name a target explicitly when you need another architecture. For x64:
PowerShell
cargo run -p xtask -- deps build --all --profile lgpl --target x86_64-pc-windows-msvc $env:ERIKA_NATIVE_TARGET = "x86_64-pc-windows-msvc" cargo build --locked -p erika_capi --target x86_64-pc-windows-msvc
For ARM64, use aarch64-pc-windows-msvc. The default is the DLL CRT (/MD); omit --crt static unless Rust uses -C target-feature=+crt-static. Static CRT dependencies are stored separately under lgpl-crt-static.
Targetsターゲット#
| Target | Platform |
|---|---|
| x86_64-unknown-linux-gnu / aarch64-unknown-linux-gnu | Linux (GNU, native build). |
| host | The current machine. |
| aarch64-apple-darwin / x86_64-apple-darwin | macOS. |
| aarch64-apple-ios | iOS device. |
| aarch64-apple-ios-sim / x86_64-apple-ios | iOS simulator. |
| aarch64-apple-tvos / aarch64-apple-tvos-sim / x86_64-apple-tvos | tvOS. |
| x86_64-pc-windows-msvc / aarch64-pc-windows-msvc | Windows. |
| aarch64-linux-android / armv7-linux-androideabi / x86_64-linux-android / i686-linux-android | Android. |
| aarch64-unknown-linux-ohos | OpenHarmony. |
macOS artifacts are built with MACOSX_DEPLOYMENT_TARGET=11.0; the script fills in the default if it is unset. At release time, the arm64 and x86_64 outputs for Apple platforms are merged into universal binaries; see Releases and artifacts.
Workspace buildワークスペース#
cargo build --workspace cargo test --workspace
The workspace contains four library crates: erika (the kernel), erika_capi (the C ABI), and erika_plugin (plugin ABI), erika_ffmpeg_sys (the FFmpeg bindings), plus xtask and more than 20 examples. Each example is a minimal program that exercises one specific path:
macOS desktop smoke test
cargo run -p macos_native_demo -- --smoke-seconds 3 /path/to/video.mp4
macos_native_demo is a complete end-to-end Presenter demo: open, play, Metal rendering, and system media controls. The other examples are divided up by name. capi_smoke covers the main C ABI call paths, and playback_tick / player_tick cover the scheduling loops of the two entry points, play and pull.
Linux release and source builds#
Since 0.3.7 there are four Linux ZIPs: x64 / ARM64 × bundled / system, all based on Ubuntu 22.04 / glibc 2.35. Release builds need a native GNU/Linux host of the matching CPU, Rust 1.92+, Meson 1.8.5 and the development tools listed in CI; the old distro Rust/Meson are insufficient. Run the modes separately:
shell
ERIKA_LINUX_DEPENDENCIES=bundled bash scripts/build_linux_release.sh ERIKA_LINUX_DEPENDENCIES=system bash scripts/build_linux_release.sh
The script prepares a pinned FFmpeg 8 SDK and build headers. Outputs are isolated in target/linux-<mode>/<triple>/release, with ZIPs in dist/. bundled embeds media dependencies; system requires matching FFmpeg 8 shared libraries on the host. Both need system audio and graphics drivers. The Ubuntu 26.04 system-library path remains available: run scripts/build_linux_libass.sh, then cargo build --locked --release -p erika_capi -p linux_native_demo.
Rust / C / Flutter · HAL patch · PIC
The codecs and license of the system FFmpeg depend on how your distribution built it; setting the lgpl profile does not change system libraries.