aboutsummaryrefslogtreecommitdiff
path: root/xtask/src/flags.rs
diff options
context:
space:
mode:
Diffstat (limited to 'xtask/src/flags.rs')
-rw-r--r--xtask/src/flags.rs51
1 files changed, 33 insertions, 18 deletions
diff --git a/xtask/src/flags.rs b/xtask/src/flags.rs
index 5710fbdb5..48d1ad45e 100644
--- a/xtask/src/flags.rs
+++ b/xtask/src/flags.rs
@@ -1,6 +1,10 @@
1#![allow(unreachable_pub)] 1#![allow(unreachable_pub)]
2 2
3xflags::args_parser! { 3use crate::install::{ClientOpt, Malloc, ServerOpt};
4
5xflags::xflags! {
6 src "./src/flags.rs"
7
4 /// Run custom build command. 8 /// Run custom build command.
5 cmd xtask { 9 cmd xtask {
6 default cmd help { 10 default cmd help {
@@ -23,10 +27,6 @@ xflags::args_parser! {
23 optional --jemalloc 27 optional --jemalloc
24 } 28 }
25 29
26 cmd codegen {
27 optional --features
28 }
29
30 cmd lint {} 30 cmd lint {}
31 cmd fuzz-tests {} 31 cmd fuzz-tests {}
32 cmd pre-cache {} 32 cmd pre-cache {}
@@ -53,7 +53,7 @@ xflags::args_parser! {
53 53
54// generated start 54// generated start
55// The following code is generated by `xflags` macro. 55// The following code is generated by `xflags` macro.
56// Run `env XFLAGS_DUMP= cargo build` to regenerate. 56// Run `env UPDATE_XFLAGS=1 cargo build` to regenerate.
57#[derive(Debug)] 57#[derive(Debug)]
58pub struct Xtask { 58pub struct Xtask {
59 pub subcommand: XtaskCmd, 59 pub subcommand: XtaskCmd,
@@ -63,7 +63,6 @@ pub struct Xtask {
63pub enum XtaskCmd { 63pub enum XtaskCmd {
64 Help(Help), 64 Help(Help),
65 Install(Install), 65 Install(Install),
66 Codegen(Codegen),
67 Lint(Lint), 66 Lint(Lint),
68 FuzzTests(FuzzTests), 67 FuzzTests(FuzzTests),
69 PreCache(PreCache), 68 PreCache(PreCache),
@@ -89,18 +88,13 @@ pub struct Install {
89} 88}
90 89
91#[derive(Debug)] 90#[derive(Debug)]
92pub struct Codegen { 91pub struct Lint;
93 pub features: bool,
94}
95
96#[derive(Debug)]
97pub struct Lint {}
98 92
99#[derive(Debug)] 93#[derive(Debug)]
100pub struct FuzzTests {} 94pub struct FuzzTests;
101 95
102#[derive(Debug)] 96#[derive(Debug)]
103pub struct PreCache {} 97pub struct PreCache;
104 98
105#[derive(Debug)] 99#[derive(Debug)]
106pub struct Release { 100pub struct Release {
@@ -129,11 +123,32 @@ pub struct Bb {
129} 123}
130 124
131impl Xtask { 125impl Xtask {
132 pub const HELP: &'static str = Self::_HELP; 126 pub const HELP: &'static str = Self::HELP_;
133 127
134 pub fn from_env() -> xflags::Result<Self> { 128 pub fn from_env() -> xflags::Result<Self> {
135 let mut p = xflags::rt::Parser::new_from_env(); 129 Self::from_env_()
136 Self::_parse(&mut p)
137 } 130 }
138} 131}
139// generated end 132// generated end
133
134impl Install {
135 pub(crate) fn server(&self) -> Option<ServerOpt> {
136 if self.client && !self.server {
137 return None;
138 }
139 let malloc = if self.mimalloc {
140 Malloc::Mimalloc
141 } else if self.jemalloc {
142 Malloc::Jemalloc
143 } else {
144 Malloc::System
145 };
146 Some(ServerOpt { malloc })
147 }
148 pub(crate) fn client(&self) -> Option<ClientOpt> {
149 if !self.client && self.server {
150 return None;
151 }
152 Some(ClientOpt { code_bin: self.code_bin.clone() })
153 }
154}