Browse Source

Assert that there's only one file in config when using expand

cmd
James Higgs 8 years ago
parent
commit
e872a0bdbc
  1. 15
      src/lib.rs

15
src/lib.rs

@ -609,6 +609,17 @@ impl Config {
/// Run the compiler, returning the macro-expanded version of the input files.
///
/// This is only relevant for C and C++ files.
///
/// # Panics
/// Panics if more than one file is present in the config, as macro
/// expansion only makes sense for a single file.
///
/// # Example
/// ```no_run
/// gcc::Config::new()
/// .file("src/foo.c")
/// .expand()
/// ```
pub fn expand(&self) -> Vec<u8> {
let compiler = self.get_compiler();
let mut cmd = compiler.to_command();
@ -616,6 +627,10 @@ impl Config {
cmd.env(a, b);
}
cmd.arg(compiler.family.expand_flag());
assert_eq!(self.files.len(), 1,
"Expand may only be called for a single file");
for file in self.files.iter() {
cmd.arg(file);
}

Loading…
Cancel
Save