diff options
Diffstat (limited to 'xtask/src/install.rs')
-rw-r--r-- | xtask/src/install.rs | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/xtask/src/install.rs b/xtask/src/install.rs index 4c5c2673c..3e8fbe0a6 100644 --- a/xtask/src/install.rs +++ b/xtask/src/install.rs | |||
@@ -5,16 +5,28 @@ use std::{env, path::PathBuf, str}; | |||
5 | use anyhow::{bail, format_err, Context, Result}; | 5 | use anyhow::{bail, format_err, Context, Result}; |
6 | use xshell::{cmd, pushd}; | 6 | use xshell::{cmd, pushd}; |
7 | 7 | ||
8 | use crate::flags; | ||
9 | |||
8 | // Latest stable, feel free to send a PR if this lags behind. | 10 | // Latest stable, feel free to send a PR if this lags behind. |
9 | const REQUIRED_RUST_VERSION: u32 = 50; | 11 | const REQUIRED_RUST_VERSION: u32 = 50; |
10 | 12 | ||
11 | pub struct InstallCmd { | 13 | impl flags::Install { |
12 | pub client: Option<ClientOpt>, | 14 | pub(crate) fn run(self) -> Result<()> { |
13 | pub server: Option<ServerOpt>, | 15 | if cfg!(target_os = "macos") { |
16 | fix_path_for_mac().context("Fix path for mac")? | ||
17 | } | ||
18 | if let Some(server) = self.server() { | ||
19 | install_server(server).context("install server")?; | ||
20 | } | ||
21 | if let Some(client) = self.client() { | ||
22 | install_client(client).context("install client")?; | ||
23 | } | ||
24 | Ok(()) | ||
25 | } | ||
14 | } | 26 | } |
15 | 27 | ||
16 | #[derive(Clone, Copy)] | 28 | #[derive(Clone, Copy)] |
17 | pub enum ClientOpt { | 29 | pub(crate) enum ClientOpt { |
18 | VsCode, | 30 | VsCode, |
19 | VsCodeExploration, | 31 | VsCodeExploration, |
20 | VsCodeInsiders, | 32 | VsCodeInsiders, |
@@ -24,7 +36,7 @@ pub enum ClientOpt { | |||
24 | } | 36 | } |
25 | 37 | ||
26 | impl ClientOpt { | 38 | impl ClientOpt { |
27 | pub const fn as_cmds(&self) -> &'static [&'static str] { | 39 | pub(crate) const fn as_cmds(&self) -> &'static [&'static str] { |
28 | match self { | 40 | match self { |
29 | ClientOpt::VsCode => &["code"], | 41 | ClientOpt::VsCode => &["code"], |
30 | ClientOpt::VsCodeExploration => &["code-exploration"], | 42 | ClientOpt::VsCodeExploration => &["code-exploration"], |
@@ -60,31 +72,16 @@ impl std::str::FromStr for ClientOpt { | |||
60 | } | 72 | } |
61 | } | 73 | } |
62 | 74 | ||
63 | pub struct ServerOpt { | 75 | pub(crate) struct ServerOpt { |
64 | pub malloc: Malloc, | 76 | pub(crate) malloc: Malloc, |
65 | } | 77 | } |
66 | 78 | ||
67 | pub enum Malloc { | 79 | pub(crate) enum Malloc { |
68 | System, | 80 | System, |
69 | Mimalloc, | 81 | Mimalloc, |
70 | Jemalloc, | 82 | Jemalloc, |
71 | } | 83 | } |
72 | 84 | ||
73 | impl InstallCmd { | ||
74 | pub fn run(self) -> Result<()> { | ||
75 | if cfg!(target_os = "macos") { | ||
76 | fix_path_for_mac().context("Fix path for mac")? | ||
77 | } | ||
78 | if let Some(server) = self.server { | ||
79 | install_server(server).context("install server")?; | ||
80 | } | ||
81 | if let Some(client) = self.client { | ||
82 | install_client(client).context("install client")?; | ||
83 | } | ||
84 | Ok(()) | ||
85 | } | ||
86 | } | ||
87 | |||
88 | fn fix_path_for_mac() -> Result<()> { | 85 | fn fix_path_for_mac() -> Result<()> { |
89 | let mut vscode_path: Vec<PathBuf> = { | 86 | let mut vscode_path: Vec<PathBuf> = { |
90 | const COMMON_APP_PATH: &str = | 87 | const COMMON_APP_PATH: &str = |