Skip to content

jarod/ndk-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 

Repository files navigation

A helper library for build.rs to work with NDK to build native libraries targeting android.

Usage

Cargo.toml

[build-dependencies]
ndk-rs = { git = "https://github.com/jarod/ndk-rs.git" }

Autotools configure script:

extern crate ndk;

use ndk::Toolchain;

fn main() {
    let target = env::var("TARGET").unwrap();
    let mut configure = Command::new("sh");
    configure.args(&[
        "configure",
        "--host",
        &target,
    ]);
    // set CC and sysroot for android targets
    if target.contains("android") {
        let toolchain = Toolchain::new(14, &target).unwrap();
        configure
            .env("CC", toolchian.cc())
            .arg("--with-sysroot")
            .arg(&toolchian.sysroot());
    }
    configure.status().expect("configure");
}

Set ANDROID_NDK then build

export ANDROID_NDK=<path to ndk directory>
cargo build

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages