summaryrefslogtreecommitdiff
path: root/nix-test/build.rs
blob: 6717b48c93e79e95d37e9c44c63c533eba6a2384 (plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
extern crate gcc;

use std::env;

pub fn main() {
    let target = env::var("TARGET").unwrap();

    let os = if target.contains("linux") {
        "LINUX"
    } else if target.contains("darwin") {
        "DARWIN"
    } else {
        "UNKNOWN"
    };

    let mut config = gcc::Config::new();

    for file in &["src/const.c", "src/sizes.c"] {
        config.file(file);
    }

    config.define(os, None);

    config.compile("libnixtest.a");
}

/*
use std::env;
use std::process::Command;

pub fn main() {
    let root   = env::var("CARGO_MANIFEST_DIR").unwrap();
    let make   = root.clone() + "/Makefile";
    let src    = root.clone() + "/src";
    let out    = env::var("OUT_DIR").unwrap();
    let target = env::var("TARGET").unwrap();

    let os = if target.contains("linux") {
        "LINUX"
    } else if target.contains("darwin") {
        "DARWIN"
    } else {
        "UNKNOWN"
    };

    let res = Command::new("make")
        .arg("-f").arg(&make)
        .current_dir(&out)
        .env("VPATH", &src)
        .env("OS", os)
        .spawn().unwrap()
        .wait().unwrap();

    assert!(res.success());

    println!("cargo:rustc-flags=-L {}/", out);
}
*/