Browse Source

Merge pull request #2 from tomaka/defs

Add possibility to pass -D flags
add-rc-path
Alex Crichton 10 years ago
parent
commit
55cb127d81
  1. 13
      src/lib.rs

13
src/lib.rs

@ -1,3 +1,5 @@
#![feature(if_let)]
use std::os;
use std::io::Command;
use std::io::process::InheritFd;
@ -7,12 +9,15 @@ use std::default::Default;
pub struct Config {
/// Directories where gcc will look for header files.
pub include_directories: Vec<Path>,
/// Additional definitions (`-DKEY` or `-DKEY=VALUE`).
pub definitions: Vec<(String, Option<String>)>,
}
impl Default for Config {
fn default() -> Config {
Config {
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);
}
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 dst = Path::new(os::getenv("OUT_DIR").unwrap());
let mut objects = Vec::new();

Loading…
Cancel
Save