mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Add cargo xtask install proc-macro-server
This commit is contained in:
parent
e846c04fbe
commit
c0136070a7
3 changed files with 30 additions and 4 deletions
|
@ -240,7 +240,7 @@ fn hover_simple(
|
|||
.flatten()
|
||||
.unique_by(|&(def, _, _)| def)
|
||||
.map(|(def, macro_arm, node)| {
|
||||
dbg!(hover_for_definition(sema, file_id, def, &node, macro_arm, config))
|
||||
hover_for_definition(sema, file_id, def, &node, macro_arm, config)
|
||||
})
|
||||
.reduce(|mut acc: HoverResult, HoverResult { markup, actions }| {
|
||||
acc.actions.extend(actions);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use std::{fmt, str::FromStr};
|
||||
|
||||
use crate::install::{ClientOpt, ServerOpt};
|
||||
use crate::install::{ClientOpt, ProcMacroServerOpt, ServerOpt};
|
||||
|
||||
xflags::xflags! {
|
||||
src "./src/flags.rs"
|
||||
|
@ -23,6 +23,10 @@ xflags::xflags! {
|
|||
optional --mimalloc
|
||||
/// Use jemalloc allocator for server.
|
||||
optional --jemalloc
|
||||
|
||||
/// Install the proc-macro server.
|
||||
optional --proc-macro-server
|
||||
|
||||
/// build in release with debug info set to 2.
|
||||
optional --dev-rel
|
||||
}
|
||||
|
@ -109,6 +113,7 @@ pub struct Install {
|
|||
pub client: bool,
|
||||
pub code_bin: Option<String>,
|
||||
pub server: bool,
|
||||
pub proc_macro_server: bool,
|
||||
pub mimalloc: bool,
|
||||
pub jemalloc: bool,
|
||||
pub dev_rel: bool,
|
||||
|
@ -284,7 +289,7 @@ impl Malloc {
|
|||
|
||||
impl Install {
|
||||
pub(crate) fn server(&self) -> Option<ServerOpt> {
|
||||
if self.client && !self.server {
|
||||
if !self.server {
|
||||
return None;
|
||||
}
|
||||
let malloc = if self.mimalloc {
|
||||
|
@ -296,8 +301,14 @@ impl Install {
|
|||
};
|
||||
Some(ServerOpt { malloc, dev_rel: self.dev_rel })
|
||||
}
|
||||
pub(crate) fn proc_macro_server(&self) -> Option<ProcMacroServerOpt> {
|
||||
if !self.proc_macro_server {
|
||||
return None;
|
||||
}
|
||||
Some(ProcMacroServerOpt { dev_rel: self.dev_rel })
|
||||
}
|
||||
pub(crate) fn client(&self) -> Option<ClientOpt> {
|
||||
if !self.client && self.server {
|
||||
if !self.client {
|
||||
return None;
|
||||
}
|
||||
Some(ClientOpt { code_bin: self.code_bin.clone() })
|
||||
|
|
|
@ -15,6 +15,9 @@ impl flags::Install {
|
|||
if let Some(server) = self.server() {
|
||||
install_server(sh, server).context("install server")?;
|
||||
}
|
||||
if let Some(server) = self.proc_macro_server() {
|
||||
install_proc_macro_server(sh, server).context("install proc-macro server")?;
|
||||
}
|
||||
if let Some(client) = self.client() {
|
||||
install_client(sh, client).context("install client")?;
|
||||
}
|
||||
|
@ -34,6 +37,10 @@ pub(crate) struct ServerOpt {
|
|||
pub(crate) dev_rel: bool,
|
||||
}
|
||||
|
||||
pub(crate) struct ProcMacroServerOpt {
|
||||
pub(crate) dev_rel: bool,
|
||||
}
|
||||
|
||||
fn fix_path_for_mac(sh: &Shell) -> anyhow::Result<()> {
|
||||
let mut vscode_path: Vec<PathBuf> = {
|
||||
const COMMON_APP_PATH: &str =
|
||||
|
@ -132,3 +139,11 @@ fn install_server(sh: &Shell, opts: ServerOpt) -> anyhow::Result<()> {
|
|||
cmd.run()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn install_proc_macro_server(sh: &Shell, opts: ProcMacroServerOpt) -> anyhow::Result<()> {
|
||||
let profile = if opts.dev_rel { "dev-rel" } else { "release" };
|
||||
|
||||
let cmd = cmd!(sh, "cargo +nightly install --path crates/proc-macro-srv-cli --profile={profile} --locked --force --features sysroot-abi");
|
||||
cmd.run()?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue