File: cquery.html

package info (click to toggle)
bazel-bootstrap 4.2.3%2Bds-11
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 85,704 kB
  • sloc: java: 721,717; sh: 55,859; cpp: 35,360; python: 12,139; xml: 295; objc: 269; makefile: 113; ansic: 106; ruby: 3
file content (744 lines) | stat: -rwxr-xr-x 23,942 bytes parent folder | download | duplicates (2)
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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
---
layout: documentation
title: Cquery (configurable query)
---
<h1>Cquery (configurable query)</h1>

<h2 id='overview'>Overview</h2>

<p>
  <code>cquery</code> is a variant
  of <a href="query.html"><code>query</code></a> that correctly handles
  <a href="configurable-attributes.md"><code>select()</code></a> and build
  options' effects on the build graph.
</p>

<p>
  It achieves this by running over the results of Bazel's
  <a href="https://docs.bazel.build/versions/master/skylark/concepts.html#evaluation-model">analysis
    phase</a>, which integrates these effects. <code>query</code>, by constrast,
  runs over the results of Bazel's loading phase, before options are evaluated.
</p>

<p>
  For example:
</p>

<pre>
$ cat > tree/BUILD &lt;&lt;EOF
sh_library(
    name = "ash",
    deps = select({
        ":excelsior": [":manna-ash"],
        ":americana": [":white-ash"],
        "//conditions:default": [":common-ash"],
    }),
)
sh_library(name = "manna-ash")
sh_library(name = "white-ash")
sh_library(name = "common-ash")
config_setting(
    name = "excelsior",
    values = {"define": "species=excelsior"},
)
config_setting(
    name = "americana",
    values = {"define": "species=americana"},
)
EOF
</pre>

<pre>
# Traditional query: query doesn't know which select() branch will be chosen
# so it conservatively lists all of them.
$ bazel query "deps(//tree:ash)" --noimplicit_deps
//tree:ash
//tree:white-ash
//tree:manna-ash
//tree:common-ash

# cquery: cquery lets you set build options at the command line and chooses
# the exact dependencies that implies.
$ bazel cquery "deps(//tree:ash)" --define species=excelsior --noimplicit_deps
//tree:ash (9f87702)
//tree:manna-ash (9f87702)
</pre>

<p>
  Each result includes a <a href="#configurations">unique identifier</a> <code>(9f87702)</code> of
  the <a href="https://docs.bazel.build/glossary.html#configuration">configuration</a> the target is
  built with.
</p>

<p>
  Since <code>cquery</code> runs over the configured target graph. it doesn't
  have insight into artifacts like build actions nor access to
  <code><a href="be/general.html#test_suite">test_suite</a></code>
  rules as they are not configured targets. For the former,
  see <code><a href="aquery.html">aquery</a></code>.
</p>

<h2 id='basic-syntax'>Basic syntax</h2>

<p>A simple <code>cquery</code> call looks like:</p>

<p><code>bazel cquery "function(//target)"</code></p>

<p>The query expression <code>"function(//target)"</code> consists of the following:

<ul>
  <li>
    <b><code>function(...)</code></b> is the function to run on the target. <code>cquery</code>
    supports most
    of <code>query</code>'s <a href="query.html#functions">functions</a>, plus a
    few new ones.
  </li>
  <li><b><code>//target</code></b> is the expression fed to the function. In this example, the
    expression is a simple target. But the query language also allows nesting of functions.
    See the <a href="query-how-to.html">Query How-To</a> for examples.
   </li>
</ul>

<p>
  <code>cquery</code> requires a target to run through the
  <a href="https://docs.bazel.build/versions/master/skylark/concepts.html#evaluation-model">loading
  and analysis</a>
  phases. Unless otherwise specified, <code>cquery</code> parses the target(s)
  listed in the query
  expression. See <a href="#universe_scope-comma-separated-list"><code>--universe_scope</code></a>
  for querying dependencies of top-level build targets.
</p>

<h2 id='configurations'>Configurations</h2>

<p>
  The line:
</p>

<pre>
//tree:ash (9f87702)
</pre>

<p>
  means <code>//tree:ash</code> was built in a configuration with ID <code>9f87702</code>. For most
  targets, this is an opaque hash of the the build option values defining the configuration.
</p>

<p>
  To see the configuration's complete contents, run:
</p>

<pre>
$ bazel config 9f87702
</pre>

<p>
  The host configuration uses the special ID <code>(HOST)</code>. Non-generated source files, like
  those commonly found in <code>srcs</code>, use the special ID <code>(null)</code> (because they
  don't need to be configured).
</p>

<p>
  <code>9f87702</code> is a prefix of the complete ID. This is because complete IDs are
  SHA-256 hashes, which are long and hard to follow. <code>cquery</code> understands any valid
   prefix of a complete ID, similar to
  <a href="https://git-scm.com/book/en/v2/Git-Tools-Revision-Selection#_revision_selection">Git short hashes</a>.
  To see complete IDs, run <code>$ bazel config</code>.
</p>

<h2 id='target-pattern-evaluation'>Target pattern evaluation</h2>

<p>
  <code>//foo</code> has a different meaning for <code>cquery</code> than
  for <code>query</code>. This is because <code>cquery</code>
  evaluates <i>configured</i> targets and the build graph may have multiple
  configured versions of <code>//foo</code>.
</p>

<p>
  For <code>cquery</code>, a target pattern in the query expression evaluates
  to every configured target with a label that matches that pattern. Output is
  deterministic, but <code>cquery</code> makes no ordering guarantee beyond the
  <a href="query.html#graph-order">core query ordering contract</a>.
</p>

<p>
  This produces subtler results for query expressions than with <code>query</code>.
  For example, the following can produce multiple results:

  <pre>
# Analyzes //foo in the target configuration, but also analyzes
# //genrule_with_foo_as_tool which depends on a host-configured
# //foo. So there are two configured target instances of //foo in
# the build graph.
$ bazel cquery //foo --universe_scope=//foo,//genrule_with_foo_as_tool
//foo (9f87702)
//foo (HOST)
  </pre>

</p>

<p>
  If you want to precisely declare which instance to query over, use
  the <a href="#config"><code>config</code></a> function.
</p>


<p>
  See <code>query</code>'s <a href="query.html#target-patterns">target pattern
  documentation</a> for more information on target patterns.
</p>

<h2 id='functions'>Functions</h2>

<p>
  Of the <a href="query.html#functions" title="list of query functions">set of functions</a>
  supported by <code>query</code>, <code>cquery</code> supports
  all
  but <a href="query.html#visible"><code>visible</code></a>,
  <a href="query.html#siblings"><code>siblings</code></a>,
  <a href="query.html#buildfiles"><code>buildfiles</code></a>,
  and <a href="query.html#tests"><code>tests</code></a>.
</p>

<p>
  <code>cquery</code> also introduces the following new functions:
</p>

<h3 id="config">config</h3>

<p><code>expr ::= config(expr, word)</code></p>

<p>
  The <code>config</code> operator attempts to find the configured target for
  the label denoted by the first argument and configuration specified by the
  second argument.
</p>

<p>
  Valid values for the second argument
  are <code>target</code>, <code>host</code>, <code>null</code>, or a
  <a href="#configurations">custom configuration hash</a>. Hashes can be retrieved from <code>$
  bazel config</code> or a prevous <code>cquery</code>'s output.
</p>

<p>
  Examples:
</p>

<pre>
$ bazel cquery "config(//bar, host)" --universe_scope=//foo
</pre>

<pre>
$ bazel cquery "deps(//foo)"
//bar (HOST)
//baz (3732cc8)

$ bazel cquery "config(//baz, 3732cc8)"
</pre>

<p>
  If not all results of the first argument can be found in the specified
  configuration, only those that can be found are returned. If no results
  can be found in the specified configuration, the query fails.
</p>

<h2 id='options'>Options</h2>

<h3>Build options</h3>

<p>
  <code>cquery</code> runs over a regular Bazel build and thus inherits the
  set of

  <a href="command-line-reference.html#build-options">options</a>
  available during a build.
</p>

<h3>Cquery options</h3>

<h4 id="universe_scope-comma-separated-list"><code>--universe_scope</code> (comma-separated list)</h4>

<p>
  Often, the dependencies of configured targets go through
  <a href="https://docs.bazel.build/versions/master/skylark/rules.html#configurations">transitions</a>,
  which causes their configuration to differ from their dependent. This flag allows you to query
  a target as if it were built as a dependency or a transitive dependency of another target. For
  example:
</p>

<pre>
# x/BUILD
genrule(
     name = "my_gen",
     srcs = ["x.in"],
     outs = ["x.cc"],
     cmd = "$(locations :tool) $&lt; >$@",
     tools = [":tool"],
)
cc_library(
    name = "tool",
)
</pre>

<p>
  Genrules configure their tools in the
  <a href="https://docs.bazel.build/versions/master/skylark/rules.html#configurations">host configuration</a>
  so the following queries would produce the following outputs:
</p>

<table class="table table-condensed table-bordered table-params">
  <thead>
    <tr>
      <th>Query</th>
      <th>Target Built</th>
      <th>Output</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>bazel cquery "//x:tool"</td>
      <td>//x:tool</td>
      <td>//x:tool(targetconfig)</td>
    </tr>
    <tr>
      <td>bazel cquery "//x:tool" --universe_scope="//x:my_gen"</td>
      <td>//x:my_gen</td>
      <td>//x:tool(hostconfig)</td>
    </tr>
  </tbody>
</table>

<p>
  If this flag is set, its contents are built. <em>If it's not set, all targets
  mentioned in the query expression are built</em> instead. The transitive closure of the
  built targets are used as the universe of the query. Either way, the targets to
  be built must be buildable at the top level (that is, compatible with top-level
  options). <code>cquery</code> returns results in the transitive closure of these
  top-level targets.
</p>

<p>
  Even if it's possible to build all targets in a query expression at the top
  level, it may be beneficial to not do so. For example, explicitly setting
  <code>--universe_scope</code> could prevent building targets multiple times in
  configurations you don't care about. It could also help specify which configuration version of a
  target you're looking for (since it's not currently possible
  to fully specify this any other way). We recommend that you set this
  flag if your query expression is more complex than <code>deps(//foo)</code>.
</p>

<h4><code>--implicit_deps</code> (boolean, default=True)</h4>

<p>
  Setting this flag to false filters out all results that aren't explicitly set in
  the BUILD file and instead set elsewhere by Bazel.
</p>

<h4><code>--tool_deps</code> (boolean, default=True)</h4>

<p>
  Setting this flag to false filters out all configured targets for which the
  path from the queried target to them crosses a transition between the target
  configuration and the
  <a href="https://docs.bazel.build/versions/master/skylark/rules.html#configurations">non-target configurations</a>.
  If the queried target is in the target configuration, setting <code>--notool_deps</code> will
  only return targets that also are in the target configuration. If the queried
  target is in a non-target configuration, setting <code>--notool_deps</code> will only return
  targets also in non-target configurations.
</p>

<h4><code>--include_aspects</code> (boolean, default=False)</h4>

<p>
  <a href="https://docs.bazel.build/versions/master/skylark/aspects.html">Aspects</a> can add
  additional dependencies to a build. By default, <code>cquery</code> doesn't follow aspects because
  they make the queryable graph bigger, which uses more memory. But following them produces more
  accurate results.
</p>

<p>
  If you're not worried about the memory impact of large queries, enable this flag by default in
  your bazelrc.
</p>

<p>
  If you query with aspects disabled, you can experience a problem where target X fails while
  building target Y but <code>cquery somepath(Y, X)</code> and <code>cquery deps(Y) | grep 'X'
  </code> return no results because the dependency occurs through an aspect.
</p>

<h2 id='output-formats'>Output formats</h2>

<p> By default, cquery outputs results in a dependency-ordered list of label and configuration pairs.
There are other options for exposing the results as well. </p>

<h3> Transitions </h3>

<pre>
--transitions=lite
--transitions=full
</pre>

<p>
  Configuration <a href="https://docs.bazel.build/versions/master/skylark/rules.html#configurations">transitions</a>
  are used to build targets underneath the top level targets in different configurations than the top
  level targets.
</p>

<p>
  For example, a target might impose a transition to the host configuration on all
  dependencies in its <code>tools</code> attribute. These are known as attribute
  transitions. Rules can also impose transitions on their own configurations,
  known as rule class transitions. This output format outputs information about
  these transitions such as what type they are and the effect they have on build
  options.
</p>

<p>This output format is triggered by the <code>--transitions</code> flag which by default is set to
  <code>NONE</code>. It can be set to <code>FULL</code> or <code>LITE</code> mode. <code>FULL</code>
  mode outputs information about rule class transitions and attribute transitions including a detailed
  diff of the options before and after the transition. <code>LITE</code> mode outputs the same information
  without the options diff.
</p>

<h3>Protocol message output</h3>

<pre>
--output=proto
</pre>

<p>
  This option causes the resulting targets to be printed in a binary protocol
  buffer form. The definition of the protocol buffer can be found at

  <a href="https://github.com/bazelbuild/bazel/blob/master/src/main/protobuf/analysis.proto">src/main/protobuf/analysis.proto</a>.
<h4>--[no]proto:include_configurations</h4>

<p>
  By default, cquery results return configuration information as part of each
  configured target. If you'd like to omit this information and get proto output
  that is formatted exactly like query's proto output, set this flag to false

 .


<p>
  See <a href="query.html#output-proto">query's proto output documentation</a>
  for more proto output-related options.
</p>

<p>
  <b>Note</b>: while selects are resolved both at the top level of returned
  targets and within attributes, all possible inputs for selects are still
  included as <code>rule_input</code> fields.
</p>

<h3>Graph output</h3>

<pre>
--output=graph
</pre>

<p>
  This option generates output as a Graphviz-compatible .dot file. See <code>query</code>'s
  <a href="query.html#output-graph">graph output documentation</a> for details. <code>cquery</code>
  also supports

  <a href="query.html#graph-node_limit-n"><code>--graph:node_limit</code></a> and
  <a href="query.html#no-graph-factored"><code>--graph:factored</code></a>.

</p>

<h3>Defining the output format using Starlark</h3>

<pre>
--output=starlark
</pre>

<p>
  This output format calls a
  <a href="https://docs.bazel.build/versions/master/skylark/language.html">Starlark</a>
  function for each configured target in the query result, and prints the value returned by the
  call. The <code>--starlark:file</code> flag specifies the location of a Starlark file that
  defines a function named <code>format</code> with a single parameter, <code>target</code>. This
  function is called for each
  <a href="https://docs.bazel.build/versions/master/skylark/lib/Target.html">Target</a> in the
  query result. Alternatively, for convenience, you may specify just the body of a function
  declared as <code>def format(target): return expr</code> by using the
  <code>--starlark:expr</code> flag.

<h4>'cquery' Starlark dialect</h4>
<p>
  The cquery Starlark environment differs from a BUILD or .bzl file. It includes all core Starlark
  <a href="https://github.com/bazelbuild/starlark/blob/master/spec.md#built-in-constants-and-functions">
  built-in constants and functions</a>, plus a few cquery-specific ones described below,
  but not (for example) <code>glob</code>, <code>native</code>, or <code>rule</code>, and it does
  not support load statements.
</p>
<h5 id='build_options'>build_options(target)</h5>
<p>
  <code>build_options(target)</code> returns a map whose keys are build option identifiers (see
  <a href="https://docs.bazel.build/versions/master/skylark/config.html">Configurations</a>)
  and whose values are their Starlark values. Build options whose values are not legal Starlark
  values are omitted from this map.
</p><p>
  If the target is an input file, <code>build_options(target)</code> returns None, as input file
  targets have a null configuration.
</p>
<h5 id='providers'>providers(target)</h5>
<p>
  <code>providers(target)</code> returns a map whose keys are names of
  <a href="https://docs.bazel.build/versions/master/skylark/rules.html#providers">providers</a>
  (for example, <code>"DefaultInfo"</code>) and whose values are their Starlark values. Providers
  whose values are not legal Starlark values are omitted from this map.
</p>

<h4>Examples</h4>

<p>
Print a space-separated list of the base names of all files produced by <code>//foo</code>:
</p>
<pre>
  bazel cquery //foo --output=starlark \
    --starlark:expr="' '.join([f.basename for f in target.files.to_list()])"
</pre>
<p>
Print a space-separated list of the paths of all files produced by <b>rule</b> targets in
<code>//bar</code> and its subpackages:
</p>
<pre>
  bazel cquery 'kind(rule, //bar/...)' --output=starlark \
    --starlark:expr="' '.join([f.path for f in target.files.to_list()])"
</pre>
<p>
Print a list of the mnemonics of all actions registered by <code>//foo</code>.
</p>
<pre>
  bazel cquery //foo --output=starlark \
    --starlark:expr="[a.mnemonic for a in target.actions]"
</pre>
<p>
Print a list of compilation outputs registered by a <code>cc_library</code> <code>//baz</code>.
</p>
<pre>
  bazel cquery //baz --output=starlark \
    --starlark:expr="[f.path for f in target.output_groups.compilation_outputs.to_list()]"
</pre>
<p>
Print the value of the command line option <code>--javacopt</code> when building <code>//foo</code>.
</p>
<pre>
  bazel cquery //foo --output=starlark \
    --starlark:expr="build_options(target)['//command_line_option:javacopt']"
</pre>
<p>
  Print the label of each target with exactly one output. This example uses Starlark functions
  defined in a file.
</p>
<pre>
  $ cat example.cquery

  def has_one_output(target):
    return len(target.files.to_list()) == 1

  def format(target):
    if has_one_output(target):
      return target.label
    else:
      return ""


  $ bazel cquery //baz --output=starlark --starlark:file=example.cquery
</pre>
<p>
  Print the label of each target which is strictly Python 3. This example uses Starlark functions
  defined in a file.
</p>
<pre>
  $ cat example.cquery

  def format(target):
    p = providers(target)
    py_info = p.get("PyInfo")
    if py_info and py_info.has_py3_only_sources:
      return target.label
    else:
      return ""


  $ bazel cquery //baz --output=starlark --starlark:file=example.cquery
</pre>

<p>
  Extract a value from a user defined Provider.
</p>
<pre>
  $ cat some_package/my_rule.bzl

  MyRuleInfo = provider(fields={"color": "the name of a color"})

  def _my_rule_impl(ctx):
      ...
      return [MyRuleInfo(color="red")]

  my_rule = rule(
      implementation = _my_rule_impl,
      attrs = {...},
  )

  $ cat example.cquery

  def format(target):
    p = providers(target)
    my_rule_info = p.get("//some_package:my_rule.bzl%MyRuleInfo'")
    if my_rule_info:
      return my_rule_info.color
    return ""


  $ bazel cquery //baz --output=starlark --starlark:file=example.cquery
</pre>


<h2 id='compare'>cquery vs. query</h2>

<p>
  <code>cquery</code> and <code>query</code> complement each other and excel in
  different niches. Consider the following to decide which is right for you:

  <ul>
    <li>
      <code>cquery</code> follows specific <code>select()</code> branches to
      model the exact graph you build. <code>query</code> doesn't know which
      branch the build chooses, so overapproximates by including all branches.
    </li>
   <li>
      <code>cquery</code>'s precision requires building more of the graph than
      <code>query</code> does. Specifically, <code>cquery</code>
      evaluates <i>configured targets</i> while <code>query</code> only
      evaluates <i>targets</i>. This takes more time and uses more memory.
   </li>
   <li>
      <code>cquery</code>'s intepretation of
      the <a href="query.html#concepts">query language</a> introduces ambiguity
      that <code>query</code> avoids. For example,
      if <code>"//foo"</code> exists in two configurations, which one
      should <code>cquery "deps(//foo)"</code> use?
      The <code><a href="#config">config</a></code></code> function can help with
      this.
   </li>
   <li>
      As a newer tool, <code>cquery</code> lacks support for certain use
      cases. See <a href="#known-issues">Known issues</a> for details.
   </li>
  </ul>
</p>

<h2 id='known-issues'>Known issues</h2>

<ul>
  <li>
    <strong>All targets that <code>cquery</code> "builds" must have the same
    configuration.</strong>

    <p>
      Before evaluating queries, <code>cquery</code> triggers a build up to just
      before the point where build actions would execute. The targets it
      "builds" are by default selected from all labels that appear in the query
      expression (this can be overridden
      with <a href="#universe_scope-comma-separated-list"><code>--universe_scope</code></a>). These
      must have the same configuration.
    </p>

    <p>
      While these generally share the top-level "target" configuration,
      rules can change their own configuration with

      <a href="skylark/config.html#incoming-edge-transitions">incoming edge transitions</a>.
      This is where </code>cquery</code> falls short.
    </p>

    <p>
      Workaround: If possible, set <code>--universe_scope</code> to a stricter
      scope. For example:
    </p>

    <pre>
# This command attempts to build the transitive closures of both //foo and
# //bar. //bar uses an incoming edge transition to change its --cpu flag.
$ bazel cquery 'somepath(//foo, //bar)'
ERROR: Error doing post analysis query: Top-level targets //foo and //bar
have different configurations (top-level targets with different
configurations is not supported)

# This command only builds the transitive closure of //foo, under which
# //bar should exist in the correct configuration.
$ bazel cquery 'somepath(//foo, //bar)' --universe_scope=//foo
   </pre>
  </li>

  <li>
    <strong>No support
    for <a href="query.html#output-xml"><code>--output=xml</code></a>.</strong>
  </li>

  <li>
    <strong>Non-deterministic output.</strong>

    <p>
      <code>cquery</code> does not automatically wipe the build graph from
      previous commands and is therefore prone to picking up results from past
      queries. For example, <code>genquery</code> exerts a host transition on
      its <code>tools</code> attribute - that is, it configures its tools in the
      <a href="https://docs.bazel.build/versions/master/skylark/rules.html#configurations">host
      configuration</a>.
    </p>

    <p>
      We can see the lingering effects of that transition below.
    </p>

<pre>
$ cat > foo/BUILD &lt;&lt;&lt;EOF
genrule(
    name = "my_gen",
    srcs = ["x.in"],
    outs = ["x.cc"],
    cmd = "$(locations :tool) $&lt; >$@",
    tools = [":tool"],
)
cc_library(
    name = "tool",
)
EOF

$ bazel cquery "//foo:tool"
tool(target_config)

$ bazel cquery "deps(//foo:my_gen)"
my_gen (target_config)
tool (host_config)
...

$ bazel cquery "//foo:tool"
tool(host_config)
</pre>

<p>
  Workaround: change any startup option to force re-analysis of configured targets. For example,
  add <code>--test_arg=&lt;whatever&gt;</code> to your build command.
</p>

  </li>
</ul>

<h2 id='updates'>Updates</h2>

<p>
  The Bazel configurability team is continuously improving <code>cquery</code>. If you want to
  ask questions, stay updated, or get involved, contact

  the Bazel team at one of <a href="/support.html">these channels</a>.
</p>