vl53l1x 1.2.0

Library for the VL53L1X Time-of-Flight sensor.
Documentation
use std::env;
use std::process::Command;

fn main() {
    let mut make = Command::new("make");
    make.arg("libvl53l1x_api.a");
    // Support explicit CC and AR for cross compilation.
    if let Ok(cc) = env::var("VL53L1X_CC") {
        make.env("CC", cc);
    }
    if let Ok(ar) = env::var("VL53L1X_AR") {
        make.env("AR", ar);
    }
    // Optionally enable 2.8 Volt mode.
    if cfg!(feature = "i2c-2v8-mode") {
        make.env("CFLAGS", "-DUSE_I2C_2V8");
    }
    // Makefile uses OUT_DIR as target.
    run(&mut make);
    let out_dir = env::var("OUT_DIR").expect("Need OUT_DIR specified by cargo.");
    println!("{}", format!("cargo:rustc-link-search={}", out_dir));
    println!("cargo:rustc-link-lib=static=vl53l1x_api");
}

fn run(command: &mut Command) {
    match command.status() {
        Ok(status) => {
            if !status.success() {
                panic!("Failed: `{:?}` ({})", command, status);
            }
        }
        Err(error) => {
            panic!("Failed: `{:?}` ({})", command, error);
        }
    }
}