wiringpi 0.2.1

An API wrapper for WiringPi, implementing the most important functions and provides a bit of type system convenience. See README.md for Raspberry Pi build instructions.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::process::Command;
use std::env;

#[cfg(not(feature = "orangepi"))]
const TARGET: &'static str = "wiringpi";
#[cfg(feature = "orangepi")]
const TARGET: &'static str = "wiringop";

fn main() {
    let out_dir = env::var("OUT_DIR").unwrap();
    match Command::new("make").arg("-e").arg(TARGET).status() {
        Ok(status) if !status.success() => panic!("failed to build wiringPi C library (exit code {:?})", status.code()),
        Err(e) => panic!("failed to build wiringPi C library: {}", e),
        _ => {}
    }
    println!("cargo:rustc-flags=-L native={} -l static=wiringpi", out_dir);
}