diff options
Diffstat (limited to 'xtask/src/flags.rs')
-rw-r--r-- | xtask/src/flags.rs | 139 |
1 files changed, 139 insertions, 0 deletions
diff --git a/xtask/src/flags.rs b/xtask/src/flags.rs new file mode 100644 index 000000000..ce72879a1 --- /dev/null +++ b/xtask/src/flags.rs | |||
@@ -0,0 +1,139 @@ | |||
1 | #![allow(unreachable_pub)] | ||
2 | |||
3 | xflags::args_parser! { | ||
4 | /// Run custom build command. | ||
5 | cmd xtask { | ||
6 | default cmd help { | ||
7 | /// Print help information. | ||
8 | optional -h, --help | ||
9 | } | ||
10 | |||
11 | /// Install rust-analyzer server or editor plugin. | ||
12 | cmd install { | ||
13 | /// Install only VS Code plugin. | ||
14 | optional --client | ||
15 | /// One of 'code', 'code-exploration', 'code-insiders', 'codium', or 'code-oss'. | ||
16 | optional --code-bin name: String | ||
17 | |||
18 | /// Install only the language server. | ||
19 | optional --server | ||
20 | /// Use mimalloc allocator for server | ||
21 | optional --mimalloc | ||
22 | /// Use jemalloc allocator for server | ||
23 | optional --jemalloc | ||
24 | } | ||
25 | |||
26 | cmd codegen { | ||
27 | optional --features | ||
28 | } | ||
29 | |||
30 | cmd lint {} | ||
31 | cmd fuzz-tests {} | ||
32 | cmd pre-cache {} | ||
33 | |||
34 | cmd release { | ||
35 | optional --dry-run | ||
36 | } | ||
37 | cmd promote { | ||
38 | optional --dry-run | ||
39 | } | ||
40 | cmd dist { | ||
41 | optional --nightly | ||
42 | optional --client version: String | ||
43 | } | ||
44 | cmd metrics { | ||
45 | optional --dry-run | ||
46 | } | ||
47 | /// Builds a benchmark version of rust-analyzer and puts it into `./target`. | ||
48 | cmd bb | ||
49 | required suffix : String | ||
50 | {} | ||
51 | } | ||
52 | } | ||
53 | |||
54 | // generated start | ||
55 | // The following code is generated by `xflags` macro. | ||
56 | // Run `env XFLAGS_DUMP= cargo build` to regenerate. | ||
57 | #[derive(Debug)] | ||
58 | pub struct Xtask { | ||
59 | pub subcommand: XtaskCmd, | ||
60 | } | ||
61 | |||
62 | #[derive(Debug)] | ||
63 | pub enum XtaskCmd { | ||
64 | Help(Help), | ||
65 | Install(Install), | ||
66 | Codegen(Codegen), | ||
67 | Lint(Lint), | ||
68 | FuzzTests(FuzzTests), | ||
69 | PreCache(PreCache), | ||
70 | Release(Release), | ||
71 | Promote(Promote), | ||
72 | Dist(Dist), | ||
73 | Metrics(Metrics), | ||
74 | Bb(Bb), | ||
75 | } | ||
76 | |||
77 | #[derive(Debug)] | ||
78 | pub struct Help { | ||
79 | pub help: bool, | ||
80 | } | ||
81 | |||
82 | #[derive(Debug)] | ||
83 | pub struct Install { | ||
84 | pub client: bool, | ||
85 | pub code_bin: Option<String>, | ||
86 | pub server: bool, | ||
87 | pub mimalloc: bool, | ||
88 | pub jemalloc: bool, | ||
89 | } | ||
90 | |||
91 | #[derive(Debug)] | ||
92 | pub struct Codegen { | ||
93 | pub features: bool, | ||
94 | } | ||
95 | |||
96 | #[derive(Debug)] | ||
97 | pub struct Lint {} | ||
98 | |||
99 | #[derive(Debug)] | ||
100 | pub struct FuzzTests {} | ||
101 | |||
102 | #[derive(Debug)] | ||
103 | pub struct PreCache {} | ||
104 | |||
105 | #[derive(Debug)] | ||
106 | pub struct Release { | ||
107 | pub dry_run: bool, | ||
108 | } | ||
109 | |||
110 | #[derive(Debug)] | ||
111 | pub struct Promote { | ||
112 | pub dry_run: bool, | ||
113 | } | ||
114 | |||
115 | #[derive(Debug)] | ||
116 | pub struct Dist { | ||
117 | pub nightly: bool, | ||
118 | pub client: Option<String>, | ||
119 | } | ||
120 | |||
121 | #[derive(Debug)] | ||
122 | pub struct Metrics { | ||
123 | pub dry_run: bool, | ||
124 | } | ||
125 | |||
126 | #[derive(Debug)] | ||
127 | pub struct Bb { | ||
128 | pub suffix: String, | ||
129 | } | ||
130 | |||
131 | impl Xtask { | ||
132 | pub const HELP: &'static str = Self::_HELP; | ||
133 | |||
134 | pub fn from_env() -> xflags::Result<Self> { | ||
135 | let mut p = xflags::rt::Parser::new_from_env(); | ||
136 | Self::_parse(&mut p) | ||
137 | } | ||
138 | } | ||
139 | // generated end | ||