diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-03-31 15:30:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-31 15:30:24 +0100 |
commit | 7a546490ecb93b9da1cd888086f00a69ebd8d0aa (patch) | |
tree | 18c25777f7f0fad8f60f58bf7187db45fe3307fd /crates/ra_project_model/src | |
parent | fa3c7742af9fbfe5146f4158a6119fa727dcc87a (diff) | |
parent | 207903a1c33961c2014010f5678b1c6807e7f6d6 (diff) |
Merge #3738
3738: Implement ra_proc_macro client logic r=matklad a=edwin0cheng
This PR add the actual client logic for `ra_proc_macro` crate:
1. Define all necessary rpc serialization data structure, which include `ra_tt` related data and some task messages. Although adding `Serialize` and `Deserialize` trait to ra_tt directly seem to be much easier, we deliberately duplicate the `ra_tt` struct with `#[serde(with = "XXDef")]` for separation of code responsibility.
2. Define a simplified version of lsp base protocol for rpc, which basically copy from lsp-server code base.
3. Implement the actual `IO` for the client side progress spawning and message passing.
Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
Diffstat (limited to 'crates/ra_project_model/src')
-rw-r--r-- | crates/ra_project_model/src/cargo_workspace.rs | 14 |
1 files changed, 13 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..0aea01d83 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,11 @@ 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 | match path.extension().and_then(OsStr::to_str).map(|it| it.to_string().to_lowercase()) { | ||
327 | None => false, | ||
328 | Some(ext) => matches!(ext.as_str(), "dll" | "dylib" | "so"), | ||
329 | } | ||
330 | } | ||