Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature more msvc flags parsed #1729

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
62 changes: 62 additions & 0 deletions src/compiler/msvc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ msvc_args!(static ARGS: [ArgInfo<ArgData>; _] = [
msvc_take_arg!("Wv:", OsString, Concatenated, PassThroughWithSuffix),
msvc_flag!("X", PassThrough),
msvc_take_arg!("Xclang", OsString, Separated, XClang),
msvc_take_arg!("Yc", PathBuf, Concatenated, TooHardPath), // Compile PCH - not yet supported.
msvc_flag!("Yd", PassThrough),
msvc_flag!("Z7", PassThrough), // Add debug info to .obj files.
msvc_take_arg!("ZH:", OsString, Concatenated, PassThroughWithSuffix),
Expand All @@ -459,6 +460,7 @@ msvc_args!(static ARGS: [ArgInfo<ArgData>; _] = [
msvc_take_arg!("Zc:", OsString, Concatenated, PassThroughWithSuffix),
msvc_flag!("Ze", PassThrough),
msvc_flag!("Zi", DebugInfo),
msvc_take_arg!("Zm", OsString, Concatenated, PassThroughWithSuffix),
msvc_flag!("Zo", PassThrough),
msvc_flag!("Zo-", PassThrough),
msvc_flag!("Zp1", PassThrough),
Expand Down Expand Up @@ -518,6 +520,7 @@ msvc_args!(static ARGS: [ArgInfo<ArgData>; _] = [
msvc_flag!("sdl-", PassThrough),
msvc_flag!("showIncludes", ShowIncludes),
msvc_take_arg!("source-charset:", OsString, Concatenated, PassThroughWithSuffix),
msvc_take_arg!("sourceDependencies", PathBuf, CanBeSeparated, DepFile),
msvc_take_arg!("std:", OsString, Concatenated, PassThroughWithSuffix),
msvc_flag!("u", PassThrough),
msvc_flag!("utf-8", PassThrough),
Expand Down Expand Up @@ -1322,6 +1325,8 @@ impl<'a> Iterator for SplitMsvcResponseFileArgs<'a> {

#[cfg(test)]
mod test {
use std::str::FromStr;

use super::*;
use crate::compiler::*;
use crate::mock_command::*;
Expand Down Expand Up @@ -1486,6 +1491,53 @@ mod test {
assert!(!msvc_show_includes);
}

#[test]
fn parse_deps_arguments() {
let arg_sets = vec![
ovec!["-c", "foo.c", "/Fofoo.obj", "/depsfoo.obj.pp"],
ovec!["-c", "foo.c", "/Fofoo.obj", "/sourceDependenciesfoo.obj.pp"],
ovec![
"-c",
"foo.c",
"/Fofoo.obj",
"/sourceDependencies",
"foo.obj.pp"
],
];

for args in arg_sets {
let ParsedArguments {
input,
language,
outputs,
preprocessor_args,
msvc_show_includes,
common_args,
depfile,
..
} = match parse_arguments(args) {
CompilerArguments::Ok(args) => args,
o => panic!("Got unexpected parse result: {:?}", o),
};
assert_eq!(Some("foo.c"), input.to_str());
assert_eq!(Language::C, language);
assert_eq!(Some(PathBuf::from_str("foo.obj.pp").unwrap()), depfile);
assert_map_contains!(
outputs,
(
"obj",
ArtifactDescriptor {
path: PathBuf::from("foo.obj"),
optional: false
}
)
);
assert!(preprocessor_args.is_empty());
assert!(common_args.is_empty());
assert!(!msvc_show_includes);
}
}

#[test]
fn test_parse_arguments_clang_passthrough() {
let args = ovec![
Expand Down Expand Up @@ -1837,6 +1889,16 @@ mod test {
CompilerArguments::CannotCache("-FR", None),
parse_arguments(ovec!["-c", "foo.c", "-FR", "-Fofoo.obj"])
);

assert_eq!(
CompilerArguments::CannotCache("-Fp", None),
parse_arguments(ovec!["-c", "-Fpfoo.h", "foo.c"])
);

assert_eq!(
CompilerArguments::CannotCache("-Yc", None),
parse_arguments(ovec!["-c", "-Ycfoo.h", "foo.c"])
);
}

#[test]
Expand Down