aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_project_model
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_project_model')
-rw-r--r--crates/ra_project_model/src/cargo_workspace.rs10
-rw-r--r--crates/ra_project_model/src/lib.rs7
2 files changed, 15 insertions, 2 deletions
diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs
index 362ee30fe..afbd30164 100644
--- a/crates/ra_project_model/src/cargo_workspace.rs
+++ b/crates/ra_project_model/src/cargo_workspace.rs
@@ -83,6 +83,7 @@ pub struct PackageData {
83 pub dependencies: Vec<PackageDependency>, 83 pub dependencies: Vec<PackageDependency>,
84 pub edition: Edition, 84 pub edition: Edition,
85 pub features: Vec<String>, 85 pub features: Vec<String>,
86 pub cfgs: Vec<PathBuf>,
86 pub out_dir: Option<PathBuf>, 87 pub out_dir: Option<PathBuf>,
87 pub proc_macro_dylib_path: Option<PathBuf>, 88 pub proc_macro_dylib_path: Option<PathBuf>,
88} 89}
@@ -165,10 +166,12 @@ impl CargoWorkspace {
165 })?; 166 })?;
166 167
167 let mut out_dir_by_id = FxHashMap::default(); 168 let mut out_dir_by_id = FxHashMap::default();
169 let mut cfgs = FxHashMap::default();
168 let mut proc_macro_dylib_paths = FxHashMap::default(); 170 let mut proc_macro_dylib_paths = FxHashMap::default();
169 if cargo_features.load_out_dirs_from_check { 171 if cargo_features.load_out_dirs_from_check {
170 let resources = load_extern_resources(cargo_toml, cargo_features)?; 172 let resources = load_extern_resources(cargo_toml, cargo_features)?;
171 out_dir_by_id = resources.out_dirs; 173 out_dir_by_id = resources.out_dirs;
174 cfgs = resources.cfgs;
172 proc_macro_dylib_paths = resources.proc_dylib_paths; 175 proc_macro_dylib_paths = resources.proc_dylib_paths;
173 } 176 }
174 177
@@ -194,6 +197,7 @@ impl CargoWorkspace {
194 edition, 197 edition,
195 dependencies: Vec::new(), 198 dependencies: Vec::new(),
196 features: Vec::new(), 199 features: Vec::new(),
200 cfgs: cfgs.get(&id).cloned().unwrap_or_default(),
197 out_dir: out_dir_by_id.get(&id).cloned(), 201 out_dir: out_dir_by_id.get(&id).cloned(),
198 proc_macro_dylib_path: proc_macro_dylib_paths.get(&id).cloned(), 202 proc_macro_dylib_path: proc_macro_dylib_paths.get(&id).cloned(),
199 }); 203 });
@@ -275,6 +279,7 @@ impl CargoWorkspace {
275pub struct ExternResources { 279pub struct ExternResources {
276 out_dirs: FxHashMap<PackageId, PathBuf>, 280 out_dirs: FxHashMap<PackageId, PathBuf>,
277 proc_dylib_paths: FxHashMap<PackageId, PathBuf>, 281 proc_dylib_paths: FxHashMap<PackageId, PathBuf>,
282 cfgs: FxHashMap<PackageId, Vec<PathBuf>>,
278} 283}
279 284
280pub fn load_extern_resources( 285pub fn load_extern_resources(
@@ -300,8 +305,9 @@ pub fn load_extern_resources(
300 for message in cargo_metadata::parse_messages(output.stdout.as_slice()) { 305 for message in cargo_metadata::parse_messages(output.stdout.as_slice()) {
301 if let Ok(message) = message { 306 if let Ok(message) = message {
302 match message { 307 match message {
303 Message::BuildScriptExecuted(BuildScript { package_id, out_dir, .. }) => { 308 Message::BuildScriptExecuted(BuildScript { package_id, out_dir, cfgs, .. }) => {
304 res.out_dirs.insert(package_id, out_dir); 309 res.out_dirs.insert(package_id.clone(), out_dir);
310 res.cfgs.insert(package_id, cfgs);
305 } 311 }
306 312
307 Message::CompilerArtifact(message) => { 313 Message::CompilerArtifact(message) => {
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs
index 731cbd291..2d5d61b61 100644
--- a/crates/ra_project_model/src/lib.rs
+++ b/crates/ra_project_model/src/lib.rs
@@ -399,6 +399,13 @@ impl ProjectWorkspace {
399 let cfg_options = { 399 let cfg_options = {
400 let mut opts = default_cfg_options.clone(); 400 let mut opts = default_cfg_options.clone();
401 opts.insert_features(cargo[pkg].features.iter().map(Into::into)); 401 opts.insert_features(cargo[pkg].features.iter().map(Into::into));
402 opts.insert_cfgs(
403 cargo[pkg]
404 .cfgs
405 .iter()
406 .filter_map(|c| c.to_str())
407 .map(Into::into),
408 );
402 opts 409 opts
403 }; 410 };
404 let mut env = Env::default(); 411 let mut env = Env::default();