diff options
Diffstat (limited to 'xtask/src/flags.rs')
-rw-r--r-- | xtask/src/flags.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/xtask/src/flags.rs b/xtask/src/flags.rs index 5710fbdb5..2ca05d3df 100644 --- a/xtask/src/flags.rs +++ b/xtask/src/flags.rs | |||
@@ -1,5 +1,7 @@ | |||
1 | #![allow(unreachable_pub)] | 1 | #![allow(unreachable_pub)] |
2 | 2 | ||
3 | use crate::install::{ClientOpt, Malloc, ServerOpt}; | ||
4 | |||
3 | xflags::args_parser! { | 5 | xflags::args_parser! { |
4 | /// Run custom build command. | 6 | /// Run custom build command. |
5 | cmd xtask { | 7 | cmd xtask { |
@@ -137,3 +139,34 @@ impl Xtask { | |||
137 | } | 139 | } |
138 | } | 140 | } |
139 | // generated end | 141 | // generated end |
142 | |||
143 | impl Install { | ||
144 | pub(crate) fn validate(&self) -> xflags::Result<()> { | ||
145 | if let Some(code_bin) = &self.code_bin { | ||
146 | if let Err(err) = code_bin.parse::<ClientOpt>() { | ||
147 | return Err(xflags::Error::new(format!("failed to parse `--code-bin`: {}", err))); | ||
148 | } | ||
149 | } | ||
150 | Ok(()) | ||
151 | } | ||
152 | pub(crate) fn server(&self) -> Option<ServerOpt> { | ||
153 | if self.client && !self.server { | ||
154 | return None; | ||
155 | } | ||
156 | let malloc = if self.mimalloc { | ||
157 | Malloc::Mimalloc | ||
158 | } else if self.jemalloc { | ||
159 | Malloc::Jemalloc | ||
160 | } else { | ||
161 | Malloc::System | ||
162 | }; | ||
163 | Some(ServerOpt { malloc }) | ||
164 | } | ||
165 | pub(crate) fn client(&self) -> Option<ClientOpt> { | ||
166 | if !self.client && self.server { | ||
167 | return None; | ||
168 | } | ||
169 | let client_opt = self.code_bin.as_ref().and_then(|it| it.parse().ok()).unwrap_or_default(); | ||
170 | Some(client_opt) | ||
171 | } | ||
172 | } | ||