diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-03-05 08:52:07 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-03-05 08:52:07 +0000 |
commit | 9707acb59b3f1f74bcc2f806ea5eab59279fad5e (patch) | |
tree | d57e4695c79e7485a1295adac9a2aafa20e9a3df /xtask/src/flags.rs | |
parent | 16a76aa158d0898d6a46d7bba7310150555a69b9 (diff) | |
parent | 142f9a03fd4bad366439b18d8de7f2237bed65ab (diff) |
Merge #7876
7876: Cleanup install command r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
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 | } | ||