cargo-ohos
Cross-compile Rust for OpenHarmony. Sets up the environment for cargo, cc-rs, bindgen, cmake-rs and pkg-config from the OpenHarmony SDK.
Usage
The SDK can also be discovered from DEVECO_SDK_HOME or the standard DevEco Studio installation location
(currently only macOS)
Prebuilt LLVM toolchains
It's generally recommend to use the LLVM toolchain bundled with the OpenHarmony SDK. However, if a newer LLVM version is required, it's possible to use a prebuilt version mirrored from openharmony-rs/ohos-llvm-toolchains. Use --download-prebuilt and pass the expected major version. At the time of writing only version 19 is supported, but future upstream release might make more versions available.
The archive is verified against the SHA-256 digest published by GitHub.
When the gh CLI is installed and authenticated, its GitHub artifact attestation must also
identify the mirror repository's mirror.yml workflow on main as the signer.
This attests the mirroring and validation workflow, not how OpenHarmony originally built the toolchain.
The verified toolchain is by default located under
$XDG_CACHE_HOME/cargo-ohos/ohos-llvm (or ~/.cache/cargo-ohos/ohos-llvm) on Linux,
~/Library/Caches/cargo-ohos/ohos-llvm on macOS, and
%LOCALAPPDATA%\cargo-ohos\ohos-llvm on Windows.
An absolute XDG_CACHE_HOME takes precedence on every platform.
A regular OpenHarmony SDK is still required for the sysroot.
Set the option for all invocations with:
--download-prebuilt replaces --llvm/OHOS_LLVM. If GitHub's anonymous API rate limit is
insufficient, cargo-ohos and gh use GITHUB_TOKEN when it is set.
License
MIT OR Apache-2.0