diff options
author | Edwin Cheng <[email protected]> | 2020-03-26 20:26:34 +0000 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2020-03-31 15:20:18 +0100 |
commit | 503cbd3f4b54f3be224d7a4221fa023f0e35d228 (patch) | |
tree | 101dcec6de8da790766a6e76d8f983242d8fcbfd /crates/ra_project_model | |
parent | fa3c7742af9fbfe5146f4158a6119fa727dcc87a (diff) |
Implement ra_proc_macro client logic
Diffstat (limited to 'crates/ra_project_model')
-rw-r--r-- | crates/ra_project_model/src/cargo_workspace.rs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs index 738fd6f61..32592e660 100644 --- a/crates/ra_project_model/src/cargo_workspace.rs +++ b/crates/ra_project_model/src/cargo_workspace.rs | |||
@@ -1,6 +1,7 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | 2 | ||
3 | use std::{ | 3 | use std::{ |
4 | ffi::OsStr, | ||
4 | ops, | 5 | ops, |
5 | path::{Path, PathBuf}, | 6 | path::{Path, PathBuf}, |
6 | }; | 7 | }; |
@@ -299,7 +300,10 @@ pub fn load_extern_resources(cargo_toml: &Path, cargo_features: &CargoFeatures) | |||
299 | Message::CompilerArtifact(message) => { | 300 | Message::CompilerArtifact(message) => { |
300 | if message.target.kind.contains(&"proc-macro".to_string()) { | 301 | if message.target.kind.contains(&"proc-macro".to_string()) { |
301 | let package_id = message.package_id; | 302 | let package_id = message.package_id; |
302 | if let Some(filename) = message.filenames.get(0) { | 303 | // Skip rmeta file |
304 | if let Some(filename) = | ||
305 | message.filenames.iter().filter(|name| is_dylib(name)).next() | ||
306 | { | ||
303 | acc.proc_dylib_paths.insert(package_id, filename.clone()); | 307 | acc.proc_dylib_paths.insert(package_id, filename.clone()); |
304 | } | 308 | } |
305 | } | 309 | } |
@@ -316,3 +320,19 @@ pub fn load_extern_resources(cargo_toml: &Path, cargo_features: &CargoFeatures) | |||
316 | 320 | ||
317 | acc | 321 | acc |
318 | } | 322 | } |
323 | |||
324 | // FIXME: File a better way to know if it is a dylib | ||
325 | fn is_dylib(path: &Path) -> bool { | ||
326 | let ext = match path.extension().and_then(OsStr::to_str).map(|it| it.to_string().to_lowercase()) | ||
327 | { | ||
328 | None => return false, | ||
329 | Some(ext) => ext, | ||
330 | }; | ||
331 | |||
332 | match ext.as_str() { | ||
333 | "dll" => true, | ||
334 | "dylib" => true, | ||
335 | "so" => true, | ||
336 | _ => false, | ||
337 | } | ||
338 | } | ||