-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathbazel.ts
340 lines (336 loc) · 10.1 KB
/
bazel.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
const bazelBuildFiles: Fig.Generator = {
script: [
"bash",
"-c",
`FILES=( $(find ./ -name BUILD) ); for f in $FILES; do echo "----$f"; \\cat "$f"; done`,
],
// returns filepaths and contents in the form below, note the "----" to indicate the filepath
// ----.//lib/BUILD
// load("@rules_cc//cc:defs.bzl", "cc_library")
// cc_library(
// name = "hello-time",
// srcs = ["hello-time.cc"],
// hdrs = ["hello-time.h"],
// visibility = ["//main:__pkg__"],
// )
postProcess: function (out) {
const lines = out.split("\n");
// return lines
const targets = [];
let currPath = "";
for (let i = 0; i < lines.length; i++) {
const isFilepath = lines[i].match("----.(.*)/BUILD");
const isBazelTarget = lines[i].match('name = "(.*)"');
if (isFilepath) {
currPath = isFilepath[1] + ":";
} else if (isBazelTarget) {
targets.push({
name: currPath + isBazelTarget[1],
description: "Bazel target",
icon: "🎯",
priority: 80,
});
}
}
return targets;
},
};
const completionSpec: Fig.Spec = {
name: "bazel",
description: "Bazel the build system!",
subcommands: [
{
name: "run",
description: "Runs the specified target",
args: {
name: "BUILD file",
generators: bazelBuildFiles,
},
},
{
name: "test",
description: "Builds and runs the specified test targets",
args: {
name: "BUILD file",
generators: bazelBuildFiles,
},
},
{
name: "build",
description: "Builds the specified targets",
args: {
name: "BUILD file",
generators: bazelBuildFiles,
},
},
],
options: [
{
name: "--autodetect_server_javabase",
exclusiveOn: ["--noautodetect_server_javabase"],
description:
"Back to the local JDK for running the bazel server and instead exits",
},
{
name: "--noautodetect_server_javabase",
exclusiveOn: ["autodetect_server_javabase"],
description:
"Does not fall back to the local JDK for running the bazel server and instead exits",
},
{
name: "--batch",
exclusiveOn: ["--nobatch"],
description: "Run as just a client process without a server",
},
{
name: "--nobatch",
exclusiveOn: ["--batch"],
description: "Run with a server",
},
{
name: "--batch_cpu_scheduling",
exclusiveOn: ["--nobatch_cpu_scheduling"],
description: "Only on Linux; use 'batch' CPU scheduling for Bazel",
},
{
name: "--nobatch_cpu_scheduling",
exclusiveOn: ["--batch_cpu_scheduling"],
description: "Only on Linux; Bazel does not perform a system call",
},
{
name: "--bazelrc",
description:
"The location of the user .bazelrc file containing default values of Bazel options",
args: {
name: "bazelrc path",
template: "filepaths",
},
},
{
name: "--block_for_lock",
exclusiveOn: ["--noblock_for_lock"],
description: "Wait for a running command to complete",
},
{
name: "--noblock_for_lock",
exclusiveOn: ["--block_for_lock"],
description:
"Bazel does not wait for a running command to complete, but instead exits immediately",
},
{
name: "--client_debug",
exclusiveOn: ["--noclient_debug"],
description:
"Log debug information from the client to stderr. Changing this option will not cause the server to restart",
},
{
name: "--noclient_debug",
exclusiveOn: ["--client_debug"],
description: "Don't log debug information from the client to stderr",
},
{
name: "--connect_timeout_secs",
description:
"The amount of time the client waits for each attempt to connect to the server",
args: {
name: "time",
},
},
{
name: "--expand_configs_in_place",
exclusiveOn: ["--noexpand_configs_in_place"],
description:
"Changed the expansion of --config flags to be done in-place",
},
{
name: "--noexpand_configs_in_place",
exclusiveOn: ["--expand_configs_in_place"],
description:
"--config flags in a fixed point expansion between normal rc options and command-line specified options",
},
{
name: "--failure_detail_out",
description:
"Specifies a location to write a failure_detail protobuf message if the server experiences a failure and cannot report it via gRPC, as normal. Otherwise, the location will be ${OUTPUT_BASE}/failure_detail.rawproto",
args: {
name: "path",
template: "filepaths",
},
},
{
name: "--home_rc",
exclusiveOn: ["--nohome_rc"],
description: "Look for the home bazelrc file at $HOME/.bazelrc",
},
{
name: "--nohome_rc",
exclusiveOn: ["--home_rc"],
description: "Don't look for the home bazelrc file at $HOME/.bazelrc",
},
{
name: "--idle_server_tasks",
exclusiveOn: ["--noidle_server_tasks"],
description: "Run System.gc() when the server is idle",
},
{
name: "--noidle_server_tasks",
exclusiveOn: ["--idle_server_tasks"],
description: "Don't run System.gc() when the server is idle",
},
{
name: "--ignore_all_rc_files",
exclusiveOn: ["--noignore_all_rc_files"],
description:
"Disables all rc files, regardless of the values of other rc-modifying flags, even if these flags come later in the list of startup options",
},
{
name: "--noignore_all_rc_files",
exclusiveOn: ["--ignore_all_rc_files"],
description: "Enables all rc files",
},
{
name: "--io_nice_level",
description:
"Only on Linux; set a level from 0-7 for best-effort IO scheduling using the sys_ioprio_set system call. 0 is highest priority, 7 is lowest",
args: {
name: "io-level",
suggestions: ["0", "1", "2", "3", "4", "5", "6", "7"],
},
},
{
name: "--local_startup_timeout_secs",
description:
"The maximum amount of time the client waits to connect to the server",
args: {
name: "seconds",
default: "120",
},
},
{
name: "--macos_qos_class",
description:
"Sets the QoS service class of the bazel server when running on macOS",
args: {
name: "QoS service class",
default: "default",
},
},
{
name: "--max_idle_secs",
description:
"The number of seconds the build server will wait idling before shutting down",
args: {
name: "seconds",
default: "10800",
},
},
{
name: "--output_base",
description:
"Specifies the output location to which all build output will be written",
args: {
name: "Path",
default: "${OUTPUT_ROOT}/_bazel_${USER}/${MD5_OF_WORKSPACE_ROOT}",
template: "filepaths",
},
},
{
name: "--output_base_root",
description:
"The user-specific directory beneath which all build outputs are written",
args: {
name: "Path",
default: "$USER",
template: "filepaths",
},
},
{
name: "--preemptible",
exclusiveOn: ["--nopreemptible"],
description:
"If true, the command can be preempted if another command is started",
},
{
name: "--nopreemptible",
exclusiveOn: ["--preemptible"],
description:
"If true, the command can be preempted if another command is started",
},
{
name: "--server_jvm_out",
description: "The location to write the server's JVM's output",
args: {
name: "Path",
template: "filepaths",
},
},
{
name: "--shutdown_on_low_sys_mem",
exclusiveOn: ["--noshutdown_on_low_sys_mem"],
description:
"Linux only. If max_idle_secs is set and the build server has been idle for a while, shut down the server when the system is low on free RAM",
},
{
name: "--noshutdown_on_low_sys_mem",
exclusiveOn: ["--shutdown_on_low_sys_mem"],
description:
"Linux only. Don't shut down the server when the system is low on free RAM",
},
{
name: "--system_rc",
exclusiveOn: ["--nosystem_rc"],
description: "Look for the system-wide bazelrc",
},
{
name: "--nosystem_rc",
exclusiveOn: ["--system_rc"],
description: "Don't look for the system-wide bazelrc",
},
{
name: "--unlimit_coredumps",
exclusiveOn: ["--nounlimit_coredumps"],
description:
"Raises the soft coredump limit to the hard limit to make coredumps of the server (including the JVM) and the client possible under common conditions",
},
{
name: "--nounlimit_coredumps",
exclusiveOn: ["--unlimit_coredumps"],
description:
"Don't raise the soft coredump limit to the hard limit to make coredumps of the server (including the JVM) and the client possible under common conditions",
},
{
name: "--watchfs",
exclusiveOn: ["--nowatchfs"],
description:
"Use the operating system's file watch service for local changes instead of scanning every file for a change",
},
{
name: "--nowatchfs",
exclusiveOn: ["--watchfs"],
description: "Scan every file for a change",
},
{
name: "--windows_enable_symlinks",
exclusiveOn: ["--nowindows_enable_symlinks"],
description:
"Real symbolic links will be created on Windows instead of file copying",
},
{
name: "--nowindows_enable_symlinks",
exclusiveOn: ["--windows_enable_symlinks"],
description: "Real symbolic links will be created via file copying",
},
{
name: "--workspace_rc",
exclusiveOn: ["--noworkspace_rc"],
description: "Look for the workspace bazelrc file at $workspace/.bazelrc",
},
{
name: "--noworkspace_rc",
exclusiveOn: ["--workspace_rc"],
description:
"Don't look for the workspace bazelrc file at $workspace/.bazelrc",
},
],
};
export default completionSpec;