ohos_ndk_env 0.1.4

set ohos build env for cc
Documentation
  • Coverage
  • 0%
    0 out of 2 items documented0 out of 1 items with examples
  • Size
  • Source code size: 4.05 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 236.75 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 8s Average build duration of successful builds.
  • all releases: 8s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • lubinglun

Add denpendencies

//Cargo.toml

[build-dependencies]
...
ohos_ndk_env = { version = "*" }

Use crate

// build.rs
extern ohos_ndk_env
fn main() {
    ohos_ndk_env::setup_ohos_ndk_env();
    let mut build = cc::Build::new();
    build.file("src/hello.c");
    build.compile("hello");
    println!("cargo:rerun-if-changed=src/hello.c");
    ...
}

Build

OHOS_NDK_HOME="/path/to/ohos-sdk/linux" cargo +nightly build