Browse Source

Support for additional flags for gcc

- Via the `flags` vector in Config
- Bump version too.
add-rc-path
Pierre Baillet 10 years ago
parent
commit
de33ff0855
  1. 2
      Cargo.toml
  2. 7
      src/lib.rs

2
Cargo.toml

@ -1,7 +1,7 @@
[package] [package]
name = "gcc" name = "gcc"
version = "0.1.1" version = "0.1.2"
authors = ["Alex Crichton <alex@alexcrichton.com>"] authors = ["Alex Crichton <alex@alexcrichton.com>"]
license = "MIT/Apache-2.0" license = "MIT/Apache-2.0"
repository = "https://github.com/alexcrichton/gcc-rs" repository = "https://github.com/alexcrichton/gcc-rs"

7
src/lib.rs

@ -10,6 +10,8 @@ pub struct Config {
pub definitions: Vec<(String, Option<String>)>, pub definitions: Vec<(String, Option<String>)>,
/// Additional object files to link into the final archive /// Additional object files to link into the final archive
pub objects: Vec<Path>, pub objects: Vec<Path>,
/// Additional flags and parameter to pass to the compiler
pub flags: Vec<String>,
} }
impl Default for Config { impl Default for Config {
@ -18,6 +20,7 @@ impl Default for Config {
include_directories: Vec::new(), include_directories: Vec::new(),
definitions: Vec::new(), definitions: Vec::new(),
objects: Vec::new(), objects: Vec::new(),
flags: Vec::new(),
} }
} }
} }
@ -75,6 +78,10 @@ pub fn compile_library(output: &str, config: &Config, files: &[&str]) {
cmd.arg("-I").arg(directory); cmd.arg("-I").arg(directory);
} }
for flag in config.flags.iter() {
cmd.arg(flag);
}
for &(ref key, ref value) in config.definitions.iter() { for &(ref key, ref value) in config.definitions.iter() {
if let &Some(ref value) = value { if let &Some(ref value) = value {
cmd.arg(format!("-D{}={}", key, value)); cmd.arg(format!("-D{}={}", key, value));

Loading…
Cancel
Save