mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Started rust-analyzer.cargo.defaultTarget implementation
This commit is contained in:
parent
5671bacfa6
commit
b7edffe244
3 changed files with 21 additions and 0 deletions
|
@ -42,6 +42,11 @@ impl ops::Index<Target> for CargoWorkspace {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct RustcConfig {
|
||||
pub default_target: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct CargoConfig {
|
||||
/// Do not activate the `default` feature.
|
||||
|
@ -56,6 +61,9 @@ pub struct CargoConfig {
|
|||
|
||||
/// Runs cargo check on launch to figure out the correct values of OUT_DIR
|
||||
pub load_out_dirs_from_check: bool,
|
||||
|
||||
/// rustc config
|
||||
pub rustc: RustcConfig,
|
||||
}
|
||||
|
||||
impl Default for CargoConfig {
|
||||
|
@ -65,6 +73,7 @@ impl Default for CargoConfig {
|
|||
all_features: true,
|
||||
features: Vec::new(),
|
||||
load_out_dirs_from_check: false,
|
||||
rustc: RustcConfig { default_target: None },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -160,6 +169,9 @@ impl CargoWorkspace {
|
|||
if let Some(parent) = cargo_toml.parent() {
|
||||
meta.current_dir(parent);
|
||||
}
|
||||
if let Some(target) = cargo_features.rustc.default_target.as_ref() {
|
||||
meta.other_options(&[String::from("--filter-platform"), target.clone()]);
|
||||
}
|
||||
let meta = meta.exec().with_context(|| {
|
||||
format!("Failed to run `cargo metadata --manifest-path {}`", cargo_toml.display())
|
||||
})?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue