diff options
Diffstat (limited to 'xtask/src/install.rs')
-rw-r--r-- | xtask/src/install.rs | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/xtask/src/install.rs b/xtask/src/install.rs index 8c65b51e3..99e1eddb1 100644 --- a/xtask/src/install.rs +++ b/xtask/src/install.rs | |||
@@ -24,6 +24,7 @@ pub struct ServerOpt { | |||
24 | 24 | ||
25 | impl InstallCmd { | 25 | impl InstallCmd { |
26 | pub fn run(self) -> Result<()> { | 26 | pub fn run(self) -> Result<()> { |
27 | let both = self.server.is_some() && self.client.is_some(); | ||
27 | if cfg!(target_os = "macos") { | 28 | if cfg!(target_os = "macos") { |
28 | fix_path_for_mac().context("Fix path for mac")? | 29 | fix_path_for_mac().context("Fix path for mac")? |
29 | } | 30 | } |
@@ -33,6 +34,16 @@ impl InstallCmd { | |||
33 | if let Some(client) = self.client { | 34 | if let Some(client) = self.client { |
34 | install_client(client).context("install client")?; | 35 | install_client(client).context("install client")?; |
35 | } | 36 | } |
37 | if both { | ||
38 | eprintln!( | ||
39 | " | ||
40 | Installation complete. | ||
41 | |||
42 | Add `\"rust-analyzer.raLspServerPath\": \"ra_lsp_server\",` to VS Code settings, | ||
43 | otherwise it will use the latest release from GitHub. | ||
44 | " | ||
45 | ) | ||
46 | } | ||
36 | Ok(()) | 47 | Ok(()) |
37 | } | 48 | } |
38 | } | 49 | } |
@@ -116,15 +127,12 @@ fn install_client(ClientOpt::VsCode: ClientOpt) -> Result<()> { | |||
116 | } | 127 | } |
117 | .run()?; | 128 | .run()?; |
118 | 129 | ||
119 | let installed_extensions = { | 130 | let installed_extensions = Cmd { |
120 | let output = Cmd { | 131 | unix: &format!(r"{} --list-extensions", code_binary), |
121 | unix: &format!(r"{} --list-extensions", code_binary), | 132 | windows: &format!(r"cmd.exe /c {}.cmd --list-extensions", code_binary), |
122 | windows: &format!(r"cmd.exe /c {}.cmd --list-extensions", code_binary), | 133 | work_dir: ".", |
123 | work_dir: ".", | 134 | } |
124 | } | 135 | .run_with_output()?; |
125 | .run_with_output()?; | ||
126 | String::from_utf8(output.stdout)? | ||
127 | }; | ||
128 | 136 | ||
129 | if !installed_extensions.contains("rust-analyzer") { | 137 | if !installed_extensions.contains("rust-analyzer") { |
130 | anyhow::bail!( | 138 | anyhow::bail!( |
@@ -150,12 +158,10 @@ fn install_client(ClientOpt::VsCode: ClientOpt) -> Result<()> { | |||
150 | 158 | ||
151 | fn install_server(opts: ServerOpt) -> Result<()> { | 159 | fn install_server(opts: ServerOpt) -> Result<()> { |
152 | let mut old_rust = false; | 160 | let mut old_rust = false; |
153 | if let Ok(output) = run_with_output("cargo --version", ".") { | 161 | if let Ok(stdout) = run_with_output("cargo --version", ".") { |
154 | if let Ok(stdout) = String::from_utf8(output.stdout) { | 162 | println!("{}", stdout); |
155 | println!("{}", stdout); | 163 | if !check_version(&stdout, REQUIRED_RUST_VERSION) { |
156 | if !check_version(&stdout, REQUIRED_RUST_VERSION) { | 164 | old_rust = true; |
157 | old_rust = true; | ||
158 | } | ||
159 | } | 165 | } |
160 | } | 166 | } |
161 | 167 | ||