From 142f9a03fd4bad366439b18d8de7f2237bed65ab Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 5 Mar 2021 11:51:32 +0300 Subject: Cleanup install command --- xtask/src/flags.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'xtask/src/flags.rs') 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 @@ #![allow(unreachable_pub)] +use crate::install::{ClientOpt, Malloc, ServerOpt}; + xflags::args_parser! { /// Run custom build command. cmd xtask { @@ -137,3 +139,34 @@ impl Xtask { } } // generated end + +impl Install { + pub(crate) fn validate(&self) -> xflags::Result<()> { + if let Some(code_bin) = &self.code_bin { + if let Err(err) = code_bin.parse::() { + return Err(xflags::Error::new(format!("failed to parse `--code-bin`: {}", err))); + } + } + Ok(()) + } + pub(crate) fn server(&self) -> Option { + if self.client && !self.server { + return None; + } + let malloc = if self.mimalloc { + Malloc::Mimalloc + } else if self.jemalloc { + Malloc::Jemalloc + } else { + Malloc::System + }; + Some(ServerOpt { malloc }) + } + pub(crate) fn client(&self) -> Option { + if !self.client && self.server { + return None; + } + let client_opt = self.code_bin.as_ref().and_then(|it| it.parse().ok()).unwrap_or_default(); + Some(client_opt) + } +} -- cgit v1.2.3