|
@ -1,3 +1,5 @@ |
|
|
|
|
|
#![feature(if_let)] |
|
|
|
|
|
|
|
|
use std::os; |
|
|
use std::os; |
|
|
use std::io::Command; |
|
|
use std::io::Command; |
|
|
use std::io::process::InheritFd; |
|
|
use std::io::process::InheritFd; |
|
@ -7,12 +9,15 @@ use std::default::Default; |
|
|
pub struct Config { |
|
|
pub struct Config { |
|
|
/// Directories where gcc will look for header files.
|
|
|
/// Directories where gcc will look for header files.
|
|
|
pub include_directories: Vec<Path>, |
|
|
pub include_directories: Vec<Path>, |
|
|
|
|
|
/// Additional definitions (`-DKEY` or `-DKEY=VALUE`).
|
|
|
|
|
|
pub definitions: Vec<(String, Option<String>)>, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
impl Default for Config { |
|
|
impl Default for Config { |
|
|
fn default() -> Config { |
|
|
fn default() -> Config { |
|
|
Config { |
|
|
Config { |
|
|
include_directories: Vec::new(), |
|
|
include_directories: Vec::new(), |
|
|
|
|
|
definitions: Vec::new(), |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -59,6 +64,14 @@ pub fn compile_library(output: &str, config: &Config, files: &[&str]) { |
|
|
cmd.arg("-I").arg(directory); |
|
|
cmd.arg("-I").arg(directory); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for &(ref key, ref value) in config.definitions.iter() { |
|
|
|
|
|
if let &Some(ref value) = value { |
|
|
|
|
|
cmd.arg(format!("-D{}={}", key, value)); |
|
|
|
|
|
} else { |
|
|
|
|
|
cmd.arg(format!("-D{}", key)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
let src = Path::new(os::getenv("CARGO_MANIFEST_DIR").unwrap()); |
|
|
let src = Path::new(os::getenv("CARGO_MANIFEST_DIR").unwrap()); |
|
|
let dst = Path::new(os::getenv("OUT_DIR").unwrap()); |
|
|
let dst = Path::new(os::getenv("OUT_DIR").unwrap()); |
|
|
let mut objects = Vec::new(); |
|
|
let mut objects = Vec::new(); |
|
|