Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/compiler/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ pub struct ParsedArguments {
pub preprocessor_args: Vec<String>,
/// Commandline arguments for the preprocessor or the compiler.
pub common_args: Vec<String>,
/// Whether or not the `-showIncludes` argument is passed on MSVC
pub msvc_show_includes: bool,
}

impl ParsedArguments {
Expand All @@ -77,7 +79,7 @@ struct CCompilation<I: CCompilerImpl> {
parsed_args: ParsedArguments,
executable: String,
/// The output from running the preprocessor.
preprocessor_output: Vec<u8>,
preprocessor_result: process::Output,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change ought to make it easier to fix #72 as well!

compiler: I,
}

Expand Down Expand Up @@ -114,7 +116,7 @@ pub trait CCompilerImpl: Clone + fmt::Debug + Send + 'static {
fn compile<T>(&self,
creator: &T,
executable: &str,
preprocessor_output: Vec<u8>,
preprocessor_result: process::Output,
parsed_args: &ParsedArguments,
cwd: &str,
env_vars: &[(OsString, OsString)],
Expand Down Expand Up @@ -217,7 +219,7 @@ impl<T, I> CompilerHasher<T> for CCompilerHasher<I>
compilation: Box::new(CCompilation {
parsed_args: parsed_args,
executable: executable,
preprocessor_output: preprocessor_result.stdout,
preprocessor_result: preprocessor_result,
compiler: compiler,
}),
})
Expand All @@ -244,8 +246,8 @@ impl<T: CommandCreatorSync, I: CCompilerImpl> Compilation<T> for CCompilation<I>
-> SFuture<(Cacheable, process::Output)>
{
let me = *self;
let CCompilation { parsed_args, executable, preprocessor_output, compiler } = me;
compiler.compile(creator, &executable, preprocessor_output, &parsed_args, cwd, env_vars,
let CCompilation { parsed_args, executable, preprocessor_result, compiler } = me;
compiler.compile(creator, &executable, preprocessor_result, &parsed_args, cwd, env_vars,
pool)
}

Expand Down
15 changes: 9 additions & 6 deletions src/compiler/clang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ impl CCompilerImpl for Clang {
fn compile<T>(&self,
creator: &T,
executable: &str,
preprocessor_output: Vec<u8>,
preprocessor_result: process::Output,
parsed_args: &ParsedArguments,
cwd: &str,
env_vars: &[(OsString, OsString)],
pool: &CpuPool)
-> SFuture<(Cacheable, process::Output)>
where T: CommandCreatorSync
{
compile(creator, executable, preprocessor_output, parsed_args, cwd, env_vars, pool)
compile(creator, executable, preprocessor_result, parsed_args, cwd, env_vars, pool)
}
}

Expand All @@ -95,7 +95,7 @@ pub fn argument_takes_value(arg: &str) -> bool {

fn compile<T>(creator: &T,
executable: &str,
preprocessor_output: Vec<u8>,
preprocessor_result: process::Output,
parsed_args: &ParsedArguments,
cwd: &str,
env_vars: &[(OsString, OsString)],
Expand All @@ -111,7 +111,7 @@ fn compile<T>(creator: &T,
Some(name) => name,
None => return future::err("missing input filename".into()).boxed(),
};
write_temp_file(pool, filename.as_ref(), preprocessor_output)
write_temp_file(pool, filename.as_ref(), preprocessor_result.stdout)
};
let input = parsed_args.input.clone();
let out_file = match parsed_args.outputs.get("obj") {
Expand Down Expand Up @@ -193,6 +193,7 @@ mod test {
}
}


#[test]
fn test_parse_arguments_simple() {
let a = parses!("-c", "foo.c", "-o", "foo.o");
Expand Down Expand Up @@ -236,13 +237,14 @@ mod test {
outputs: vec![("obj", "foo.o".to_owned())].into_iter().collect::<HashMap<&'static str, String>>(),
preprocessor_args: vec!(),
common_args: vec!(),
msvc_show_includes: false,
};
let compiler = f.bins[0].to_str().unwrap();
// Compiler invocation.
next_command(&creator, Ok(MockChild::new(exit_status(0), "", "")));
let (cacheable, _) = compile(&creator,
&compiler,
vec!(),
empty_output(),
&parsed_args,
f.tempdir.path().to_str().unwrap(),
&[],
Expand All @@ -264,6 +266,7 @@ mod test {
outputs: vec![("obj", "foo.o".to_owned())].into_iter().collect::<HashMap<&'static str, String>>(),
preprocessor_args: vec!(),
common_args: stringvec!("-c", "-o", "foo.o", "-Werror=blah", "foo.c"),
msvc_show_includes: false,
};
let compiler = f.bins[0].to_str().unwrap();
// First compiler invocation fails.
Expand All @@ -272,7 +275,7 @@ mod test {
next_command(&creator, Ok(MockChild::new(exit_status(0), "", "")));
let (cacheable, output) = compile(&creator,
&compiler,
vec!(),
empty_output(),
&parsed_args,
f.tempdir.path().to_str().unwrap(),
&[],
Expand Down
Loading