Skip to content

Change --crate-type metadata to --emit=metadata #38571

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

Merged
merged 4 commits into from
Dec 29, 2016
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Restore --crate-type=metadata as an alias for --crate-type=rlib,--emi…
…t=metadata + a warning
  • Loading branch information
nrc committed Dec 29, 2016
commit 9c8916661105322df7774378a264eb25b873401b
19 changes: 15 additions & 4 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1296,7 +1296,7 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
};

let unparsed_crate_types = matches.opt_strs("crate-type");
let crate_types = parse_crate_types_from_list(unparsed_crate_types)
let (crate_types, emit_metadata) = parse_crate_types_from_list(unparsed_crate_types)
.unwrap_or_else(|e| early_error(error_format, &e[..]));

let mut lint_opts = vec![];
Expand Down Expand Up @@ -1343,7 +1343,9 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
}
}
};
if output_types.is_empty() {
if emit_metadata {
output_types.insert(OutputType::Metadata, None);
} else if output_types.is_empty() {
output_types.insert(OutputType::Exe, None);
}

Expand Down Expand Up @@ -1545,8 +1547,10 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
cfg)
}

pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateType>, String> {
pub fn parse_crate_types_from_list(list_list: Vec<String>)
-> Result<(Vec<CrateType>, bool), String> {
let mut crate_types: Vec<CrateType> = Vec::new();
let mut emit_metadata = false;
for unparsed_crate_type in &list_list {
for part in unparsed_crate_type.split(',') {
let new_part = match part {
Expand All @@ -1557,6 +1561,13 @@ pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateTy
"cdylib" => CrateTypeCdylib,
"bin" => CrateTypeExecutable,
"proc-macro" => CrateTypeProcMacro,
// FIXME(#38640) remove this when Cargo is fixed.
"metadata" => {
early_warn(ErrorOutputType::default(), "--crate-type=metadata is deprecated, \
prefer --emit=metadata");
emit_metadata = true;
CrateTypeRlib
}
_ => {
return Err(format!("unknown crate type: `{}`",
part));
Expand All @@ -1568,7 +1579,7 @@ pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateTy
}
}

return Ok(crate_types);
return Ok((crate_types, emit_metadata));
}

pub mod nightly_options {
Expand Down