~nerosnm/oslog

ref: f0e0a1169d79e24e4e38008387fbb6bb3dfd7374 oslog/oslog-sys/build.rs -rw-r--r-- 1.1 KiB
f0e0a116 — Søren Mortensen Rename to oslog and cleaner structure 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//
//  build.rs
//  os_log
//
//  Created by Søren Mortensen on 28/07/2018.
//  Copyright © 2018 Søren Mortensen. All rights reserved.
//

extern crate bindgen;

use std::env;
use std::path::PathBuf;
use std::process::Command;

fn main() {
    let liboslog_dir = concat!(env!("CARGO_MANIFEST_DIR"), "/../liboslog");

    Command::new("make")
        .current_dir(PathBuf::from(liboslog_dir))
        .status()
        .unwrap();

    println!("cargo:rustc-link-search=native={}/out/", liboslog_dir);
    println!("cargo:rustc-link-lib=static=oslog");

    let bindings = bindgen::Builder::default()
        // The input header we would like to generate
        // bindings for.
        .header("include/oslog-sys.h")
        // Finish the builder and generate the bindings.
        .generate()
        // Unwrap the Result and panic on failure.
        .expect("Unable to generate bindings");

    // Write the bindings to the $OUT_DIR/bindings.rs file.
    let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
    bindings
        .write_to_file(out_path.join("os_log.rs"))
        .expect("Couldn't write bindings!");
}