]> git.lizzy.rs Git - rust.git/blob - xtask/src/flags.rs
Revert "Rewrite `#[derive]` removal to be based on AST"
[rust.git] / xtask / src / flags.rs
1 #![allow(unreachable_pub)]
2
3 use crate::install::{ClientOpt, Malloc, ServerOpt};
4
5 xflags::xflags! {
6     src "./src/flags.rs"
7
8     /// Run custom build command.
9     cmd xtask {
10         default cmd help {
11             /// Print help information.
12             optional -h, --help
13         }
14
15         /// Install rust-analyzer server or editor plugin.
16         cmd install {
17             /// Install only VS Code plugin.
18             optional --client
19             /// One of 'code', 'code-exploration', 'code-insiders', 'codium', or 'code-oss'.
20             optional --code-bin name: String
21
22             /// Install only the language server.
23             optional --server
24             /// Use mimalloc allocator for server
25             optional --mimalloc
26             /// Use jemalloc allocator for server
27             optional --jemalloc
28         }
29
30         cmd fuzz-tests {}
31         cmd pre-cache {}
32
33         cmd release {
34             optional --dry-run
35         }
36         cmd promote {
37             optional --dry-run
38         }
39         cmd dist {
40             optional --nightly
41             optional --client version: String
42         }
43         cmd metrics {
44             optional --dry-run
45         }
46         /// Builds a benchmark version of rust-analyzer and puts it into `./target`.
47         cmd bb
48             required suffix: String
49         {}
50     }
51 }
52
53 // generated start
54 // The following code is generated by `xflags` macro.
55 // Run `env UPDATE_XFLAGS=1 cargo build` to regenerate.
56 #[derive(Debug)]
57 pub struct Xtask {
58     pub subcommand: XtaskCmd,
59 }
60
61 #[derive(Debug)]
62 pub enum XtaskCmd {
63     Help(Help),
64     Install(Install),
65     FuzzTests(FuzzTests),
66     PreCache(PreCache),
67     Release(Release),
68     Promote(Promote),
69     Dist(Dist),
70     Metrics(Metrics),
71     Bb(Bb),
72 }
73
74 #[derive(Debug)]
75 pub struct Help {
76     pub help: bool,
77 }
78
79 #[derive(Debug)]
80 pub struct Install {
81     pub client: bool,
82     pub code_bin: Option<String>,
83     pub server: bool,
84     pub mimalloc: bool,
85     pub jemalloc: bool,
86 }
87
88 #[derive(Debug)]
89 pub struct Lint;
90
91 #[derive(Debug)]
92 pub struct FuzzTests;
93
94 #[derive(Debug)]
95 pub struct PreCache;
96
97 #[derive(Debug)]
98 pub struct Release {
99     pub dry_run: bool,
100 }
101
102 #[derive(Debug)]
103 pub struct Promote {
104     pub dry_run: bool,
105 }
106
107 #[derive(Debug)]
108 pub struct Dist {
109     pub nightly: bool,
110     pub client: Option<String>,
111 }
112
113 #[derive(Debug)]
114 pub struct Metrics {
115     pub dry_run: bool,
116 }
117
118 #[derive(Debug)]
119 pub struct Bb {
120     pub suffix: String,
121 }
122
123 impl Xtask {
124     pub const HELP: &'static str = Self::HELP_;
125
126     pub fn from_env() -> xflags::Result<Self> {
127         Self::from_env_()
128     }
129 }
130 // generated end
131
132 impl Install {
133     pub(crate) fn server(&self) -> Option<ServerOpt> {
134         if self.client && !self.server {
135             return None;
136         }
137         let malloc = if self.mimalloc {
138             Malloc::Mimalloc
139         } else if self.jemalloc {
140             Malloc::Jemalloc
141         } else {
142             Malloc::System
143         };
144         Some(ServerOpt { malloc })
145     }
146     pub(crate) fn client(&self) -> Option<ClientOpt> {
147         if !self.client && self.server {
148             return None;
149         }
150         Some(ClientOpt { code_bin: self.code_bin.clone() })
151     }
152 }