| --- | 
 | layout: documentation | 
 | title: Command-Line Reference | 
 | --- | 
 | <h1>Command-Line Reference</h1> | 
 |  | 
 | <pre> | 
 | bazel [<startup options>] <command> [<args>] | 
 | </pre> | 
 |  | 
 | or | 
 |  | 
 | <pre> | 
 | bazel [<startup options>] <command> [<args>] -- [<target patterns>] | 
 | </pre> | 
 |  | 
 | <h2>Option Syntax</h2> | 
 |  | 
 | <p> | 
 | Options can be passed to Bazel in different ways. Options that require a value | 
 | can be passed with either an equals sign or a space: | 
 | <pre> | 
 | --<option>=<value> | 
 | --<option> <value> | 
 | </pre> | 
 | Some options have a single character short form; in that case, the short form | 
 | has to be passed with a single dash and a space. | 
 | <pre> | 
 | -<short_form> <value> | 
 | </pre> | 
 | </p> | 
 |  | 
 | <p> | 
 | Boolean options can be enabled as follows: | 
 | <pre> | 
 | --<option> | 
 | --<option>=[true|yes|1] | 
 | </pre> | 
 |  | 
 | and disabled as follows: | 
 | <pre> | 
 | --no<option> | 
 | --<option>=[false|no|0] | 
 | </pre> | 
 | </p> | 
 |  | 
 | <p> | 
 | Tristate options are usually set to automatic by default, and can be | 
 | force-enabled as follows: | 
 | <pre> | 
 | --<option>=[true|yes|1] | 
 | </pre> | 
 | or force-disabled as follows: | 
 | <pre> | 
 | --no<option> | 
 | --<option>=[false|no|0] | 
 | </pre> | 
 | </p> | 
 |  | 
 | <h2>Target Pattern Syntax</h2> | 
 |  | 
 | <p> | 
 | A target pattern refers to a single or more targets, which are source files, | 
 | output files, or rules specified in BUILD files. In addition to plain labels, | 
 | Bazel also supports working-directory-relative labels, recursive patterns, and | 
 | target subtraction. | 
 | </p> | 
 |  | 
 | <p> | 
 | All target patterns starting with '//' are resolved relative to the current | 
 | workspace. | 
 | <table> | 
 | <tr> | 
 |   <td><code>//foo/bar:wiz</code></td> | 
 |   <td>Just the single target '//foo/bar:wiz'.</td> | 
 | </tr> | 
 | <tr> | 
 |   <td><code>//foo/bar</code></td> | 
 |   <td>Equivalent to '//foo/bar:bar'.</td> | 
 | </tr> | 
 | <tr> | 
 |   <td><code>//foo/bar:all</code></td> | 
 |   <td>All rules in the package 'foo/bar'.</td> | 
 | </tr> | 
 | <tr> | 
 |   <td><code>//foo/...</code></td> | 
 |   <td>All rules in all packages beneath the directory 'foo'.</td> | 
 | </tr> | 
 | <tr> | 
 |   <td><code>//foo/...:all</code></td> | 
 |   <td>All rules in all packages beneath the directory 'foo'.</td> | 
 | </tr> | 
 | <tr> | 
 |   <td><code>//foo/...:*</code></td> | 
 |   <td>All targets (rules and files) in all packages beneath the directory 'foo'.</td> | 
 | </tr> | 
 | <tr> | 
 |   <td><code>//foo/...:all-targets</code></td> | 
 |   <td>All targets (rules and files) in all packages beneath the directory 'foo'.</td> | 
 | </tr> | 
 | </table> | 
 | </p> | 
 |  | 
 | <p> | 
 | Targets with <code>tags=["manual"]</code> are not included in wildcard | 
 | target patterns (<code>...</code>, <code>:*</code>, <code>:all</code>, etc). | 
 | Specify such test targets with explicit labels on the command line if | 
 | you want Bazel to build/test them. | 
 | </p> | 
 |  | 
 | <p> | 
 | Target patterns which do not begin with '//' are resolved relative to the | 
 | current <em>working directory</em>. These examples assume a working directory of | 
 | 'foo': | 
 | <table> | 
 | <tr> | 
 |   <td><code>:foo</code></td> | 
 |   <td>Equivalent to  '//foo:foo'.</td> | 
 | </tr> | 
 | <tr> | 
 |   <td><code>bar:wiz</code></td> | 
 |   <td>Equivalent to  '//foo/bar:wiz'.</td> | 
 | </tr> | 
 | <tr> | 
 |   <td><code>bar/wiz</code></td> | 
 |   <td>Equivalent to: | 
 |                       '//foo/bar/wiz:wiz' if foo/bar/wiz is a package, | 
 |                       '//foo/bar:wiz' if foo/bar is a package, | 
 |                       '//foo:bar/wiz' otherwise. | 
 |   </td> | 
 | </tr> | 
 | <tr> | 
 |   <td><code>bar:all</code></td> | 
 |   <td>Equivalent to  '//foo/bar:all'.</td> | 
 | </tr> | 
 | <tr> | 
 |   <td><code>:all</code></td> | 
 |   <td>Equivalent to  '//foo:all'.</td> | 
 | </tr> | 
 | <tr> | 
 |   <td><code>...:all</code></td> | 
 |   <td>Equivalent to  '//foo/...:all'.</td> | 
 | </tr> | 
 | <tr> | 
 |   <td><code>...</code></td> | 
 |   <td>Equivalent to  '//foo/...:all'.</td> | 
 | </tr> | 
 | <tr> | 
 |   <td><code>bar/...:all</code></td> | 
 |   <td>Equivalent to  '//foo/bar/...:all'.</td> | 
 | </tr> | 
 | </table> | 
 | </p> | 
 |  | 
 | <p> | 
 | By default, directory symlinks are followed for recursive target patterns, | 
 | except those that point to under the output base, such as the convenience | 
 | symlinks that are created in the root directory of the workspace. | 
 | </p> | 
 |  | 
 | <p> | 
 | In addition, Bazel does not follow symlinks when evaluating recursive target | 
 | patterns in any directory that contains a file named as follows: | 
 | <pre> | 
 | DONT_FOLLOW_SYMLINKS_WHEN_TRAVERSING_THIS_DIRECTORY_VIA_A_RECURSIVE_TARGET_PATTERN | 
 | </pre> | 
 | </p> | 
 |  | 
 | <p> | 
 | Target patterns may be preceded by a single dash ('<code>-</code>'), in which | 
 | case Bazel subtracts them from the set of targets accumulated by preceding | 
 | patterns. Note that this means <em>order matters</em>. In order to pass negative | 
 | target patterns, you need to use '--' as an argument to prevent Bazel from | 
 | interpreting it as an option, e.g.: | 
 | <pre> | 
 | bazel build -- foo/... -foo/contrib/... | 
 | </pre> | 
 | Note that Bazel may still build targets matched by a negative target pattern due | 
 | to dependencies, and may also load the corresponding BUILD files, even if the | 
 | targets are never built. | 
 | </p> |