Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/proc-macro-srv-cli/src/main.rs')
-rw-r--r--crates/proc-macro-srv-cli/src/main.rs38
1 files changed, 35 insertions, 3 deletions
diff --git a/crates/proc-macro-srv-cli/src/main.rs b/crates/proc-macro-srv-cli/src/main.rs
index ac9fa9f5a4..bece195187 100644
--- a/crates/proc-macro-srv-cli/src/main.rs
+++ b/crates/proc-macro-srv-cli/src/main.rs
@@ -1,6 +1,6 @@
//! A standalone binary for `proc-macro-srv`.
-
-use proc_macro_srv::cli;
+//! Driver for proc macro server
+use std::io;
fn main() -> std::io::Result<()> {
let v = std::env::var("RUST_ANALYZER_INTERNALS_DO_NOT_USE");
@@ -15,5 +15,37 @@ fn main() -> std::io::Result<()> {
}
}
- cli::run()
+ run()
+}
+
+#[cfg(not(feature = "sysroot-abi"))]
+fn run() -> io::Result<()> {
+ panic!("proc-macro-srv-cli requires the `sysroot-abi` feature to be enabled");
+}
+
+#[cfg(feature = "sysroot-abi")]
+fn run() -> io::Result<()> {
+ use proc_macro_api::msg::{self, Message};
+
+ let read_request = |buf: &mut String| msg::Request::read(&mut io::stdin().lock(), buf);
+
+ let write_response = |msg: msg::Response| msg.write(&mut io::stdout().lock());
+
+ let mut srv = proc_macro_srv::ProcMacroSrv::default();
+ let mut buf = String::new();
+
+ while let Some(req) = read_request(&mut buf)? {
+ let res = match req {
+ msg::Request::ListMacros { dylib_path } => {
+ msg::Response::ListMacros(srv.list_macros(&dylib_path))
+ }
+ msg::Request::ExpandMacro(task) => msg::Response::ExpandMacro(srv.expand(task)),
+ msg::Request::ApiVersionCheck {} => {
+ msg::Response::ApiVersionCheck(proc_macro_api::msg::CURRENT_API_VERSION)
+ }
+ };
+ write_response(res)?
+ }
+
+ Ok(())
}