Documentation

Command-Line Reference

bazel [<startup options>] <command> [<args>]
or
bazel [<startup options>] <command> [<args>] -- [<target patterns>]

Option Syntax

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:

--<option>=<value>
--<option> <value>
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.
-<short_form> <value>

Boolean options can be enabled as follows:

--<option>
--<option>=[true|yes|1]
and disabled as follows:
--no<option>
--no_<option>
--<option>=[false|no|0]

Tristate options are usually set to automatic by default, and can be force-enabled as follows:

--<option>=[true|yes|1]
or force-disabled as follows:
--no<option>
--no_<option>
--<option>=[false|no|0]

Target Pattern Syntax

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.

All target patterns starting with '//' are resolved relative to the current workspace.

//foo/bar:wiz Just the single target '//foo/bar:wiz'.
//foo/bar Equivalent to '//foo/bar:bar'.
//foo/bar:all All rules in the package 'foo/bar'.
//foo/... All rules in all packages beneath the directory 'foo'.
//foo/...:all All rules in all packages beneath the directory 'foo'.
//foo/...:* All targets (rules and files) in all packages beneath the directory 'foo'.
//foo/...:all-targets All targets (rules and files) in all packages beneath the directory 'foo'.

Targets with tags=["manual"] are not included in wildcard target patterns (..., :*, :all, etc). Specify such test targets with explicit labels on the command line if you want Bazel to build/test them.

Target patterns which do not begin with '//' are resolved relative to the current working directory. These examples assume a working directory of 'foo':

:foo Equivalent to '//foo:foo'.
bar:wiz Equivalent to '//foo/bar:wiz'.
bar/wiz 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.
bar:all Equivalent to '//foo/bar:all'.
:all Equivalent to '//foo:all'.
...:all Equivalent to '//foo/...:all'.
... Equivalent to '//foo/...:all'.
bar/...:all Equivalent to '//foo/bar/...:all'.

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.

In addition, Bazel does not follow symlinks when evaluating recursive target patterns in any directory that contains a file named as follows:

DONT_FOLLOW_SYMLINKS_WHEN_TRAVERSING_THIS_DIRECTORY_VIA_A_RECURSIVE_TARGET_PATTERN

Target patterns may be preceded by a single dash ('-'), in which case Bazel subtracts them from the set of targets accumulated by preceding patterns. Note that this means order matters. 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.:

bazel build -- foo/... -foo/contrib/...
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.

Commands

analyze-profile Analyzes build profile data.
build Builds the specified targets.
canonicalize-flags Canonicalizes a list of bazel options.
clean Removes output files and optionally stops the server.
coverage Generates code coverage report for specified test targets.
dump Dumps the internal state of the bazel server process.
fetch Fetches external repositories that are prerequisites to the targets.
help Prints help for commands, or the index.
info Displays runtime info about the bazel server.
mobile-install Installs targets to mobile devices.
query Executes a dependency graph query.
run Runs the specified target.
shutdown Stops the bazel server.
test Builds and runs the specified test targets.
version Prints version information for bazel.

Startup Options

Options that affect the startup of the bazel server's JVM:
--host_javabase=<jvm path> default: ""
Path to the JVM used to execute Bazel itself.
--host_jvm_args=<jvm_arg> multiple uses are accumulated
Flags to pass to the JVM executing Bazel.
--host_jvm_debug
Convenience option to add some additional JVM startup flags, which cause the JVM to wait during startup until you connect from a JDWP-compliant debugger (like Eclipse) to port 5005.
Expands to:
  --host_jvm_args=-Xdebug
  --host_jvm_args=-Xrunjdwp:transport=dt_socket,server=y,address=5005
--host_jvm_profile=<profiler_name> default: ""
Convenience option to add some profiler/debugger-specific JVM startup flags. Bazel has a list of known values that it maps to hard-coded JVM startup flags, possibly searching some hardcoded paths for certain files.
Miscellaneous options:
--bazelrc=<path> default: see description
The location of the .bazelrc file containing default values of Bazel command options. By default, Bazel first checks the current directory, then the user's home directory, and then looks for a file named .$(basename $0)rc (i. e. .bazelrc). Use /dev/null to disable the search for a bazelrc file, e.g. in release builds.
--[no]master_bazelrc default: "true"
If this option is false, the master bazelrc next to the binary is not read.
Startup options, which affect the startup of the bazel server:
--[no]batch default: "false"
If set, Bazel will be run in batch mode, instead of the standard client/server mode. Running in batch mode prevents Bazel from caching data in memory, which makes it a lot slower. We recommend against using this flag.
--[no]batch_cpu_scheduling default: "false"
Only on Linux; use 'batch' CPU scheduling for Bazel. This policy is useful for workloads that are non-interactive, but do not want to lower their nice value. See 'man 2 sched_setscheduler'. If false, then Bazel does not perform a system call.
--[no]block_for_lock default: "true"
When --noblock_for_lock is passed, Bazel does not wait for a running command to complete, but instead exits immediately.
--[no]client_debug default: "false"
If true, log debug information from the client to stderr
--connect_timeout_secs=<an integer> default: "10"
The amount of time the client waits for each attempt to connect to the server
--[no]deep_execroot default: "true"
If set, the execution root will be under $OUTPUT_BASE/execroot instead of $OUTPUT_BASE.
--[no]exobazel default: "false"
If true, Bazel runs as Exobazel
--io_nice_level={-1,0,1,2,3,4,5,6,7} default: "-1"
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. The anticipatory scheduler may only honor up to priority 4. If set to a negative value, then Bazel does not perform a system call.
--max_idle_secs=<integer> default: "10800"
The number of seconds the build server will wait idling before shutting down. Zero means that the server will never shutdown.
--[no]experimental_oom_more_eagerly default: "false"
If set, attempt to detect Java heap OOM conditions and exit before thrashing. Only honored when --batch is also passed. In some cases, builds that previously succeeded may OOM if they were close to OOMing before.
--experimental_oom_more_eagerly_threshold=<an integer> default: "100"
If this flag is set, Bazel will OOM if, after two full GC's, more than this percentage of the (old gen) heap is still occupied.
--output_base=<path> default: see description
If set, specifies the output location to which all build output will be written. Otherwise, the location will be ${OUTPUT_ROOT}/_bazel_${USER} /${MD5_OF_WORKSPACE_ROOT}. Note: If you specify a different option from one to the next Bazel invocation for this value, you'll likely start up a new, additional Bazel server. Bazel starts exactly one server per specified output base. Typically there is one output base per workspace - however, with this option you may have multiple output bases per workspace and thereby run multiple builds for the same client on the same machine concurrently. See ' bazel help shutdown' on how to shutdown a Bazel server.
--output_user_root=<path> default: see description
The user-specific directory beneath which all build outputs are written; by default, this is a function of $USER, but by specifying a constant, build outputs can be shared between collaborating users.
--[no]watchfs default: "false"
If true, bazel tries to use the operating system's file watch service for local changes instead of scanning every file for a change.

Options Common to all Commands

Miscellaneous options:
--config=<a string> multiple uses are accumulated
Selects additional config sections from the rc files; for every < command>, it also pulls in the options from <command>:<config> if such a section exists; if the section does not exist, this flag is ignored. Note that it is currently only possible to provide these options on the command line, not in the rc files. The config sections and flag combinations they are equivalent to are located in the tools/*.bazelrc config files.
--[no]experimental_multi_threaded_digest default: "false"
Whether to always compute MD5 digests of files with multiple threads. Might improve performance when using an SSD.
--profile=<a path> default: see description
If set, profile Bazel and write data to the specified file. Use bazel analyze- profile to analyze the profile.
--tool_tag=<a string> default: ""
A tool name to attribute this Bazel invocation to.
Startup options, which affect the startup of the bazel server:
--[no]watchfs default: "false"
If true, bazel tries to use the operating system's file watch service for local changes instead of scanning every file for a change.
Verbosity options, which control what bazel prints:
--[no]announce_rc default: "false"
Whether to announce rc options.
--[no]experimental_ui default: "false"
Switches to an alternative progress bar that more explicitly shows progress, such as loaded packages and executed actions.
--experimental_ui_actions_shown=<an integer> default: "3"
Number of concurrent actions shown in the alternative progress bar; each action is shown on a separate line. The alternative progress bar always shows at least one one, all numbers less than 1 are mapped to 1. This option has no effect unless --experimental_ui is set.
--[no]experimental_external_repositories default: "false"
Use external repositories for improved stability and speed when available.
--[no]force_experimental_external_repositories default: "false"
Forces --experimental_external_repositories.
--[no]progress_in_terminal_title default: "false"
Show the command progress in the terminal title. Useful to see what bazel is doing when having multiple terminal tabs.
--[no]show_progress default: "true"
Display progress messages during a build.
--show_progress_rate_limit=<a double> default: "0.03"
Minimum number of seconds between progress messages in the output.
--[no]show_task_finish default: "false"
Display progress messages when tasks complete, not just when they start.
--[no]show_timestamps default: "false"
Include timestamps in messages
--color=<yes, no or auto> default: "auto"
Use terminal controls to colorize output.
--curses=<yes, no or auto> default: "auto"
Use terminal cursor controls to minimize scrolling output
--logging=<0 <= an integer <= 6> default: "3"
The logging level.

Analyze-profile Options

Miscellaneous options:
--[no]chart default: "true"
If --nochart is present, do not include the task chart with --html_details. The default is --chart.
--combine=<a string> default: see description
If present, the statistics of all given profile files will be combined and output in text/--html format to the file named in the argument. Does not output HTML task charts.
--dump=<text, raw, text-unsorted or raw-unsorted> [-d] default: see description
output full profile data dump either in human-readable 'text' format or script-friendly 'raw' format, either sorted or unsorted.
--[no]html default: "false"
If present, an HTML file visualizing the tasks of the profiled build is created. The name of the html file is the name of the profile file plus '. html'.
--[no]html_details default: "false"
If --html_details is present, the task diagram contains all tasks of the profile and performance statistics on user-defined and built-in Skylark functions. If --nohtml_details is present, an aggregated diagram is generated. The default is to generate an aggregated diagram.
--[no]html_histograms default: "false"
If --html_histograms and --html_details is present, the HTML output will display histograms for Skylark functions clicked in the statistics table. This will increase file size massively.
--html_pixels_per_second=<an integer> default: "50"
Defines the scale of the time axis of the task diagram. The unit is pixels per second. Default is 50 pixels per second.
--task_tree=<a valid Java regular expression> default: see description
Print the tree of profiler tasks from all tasks matching the given regular expression.
--task_tree_threshold=<a long integer> default: "50"
When printing a task tree, will skip tasks with a duration that is less than the given threshold in milliseconds.
--[no]vfs_stats default: "false"
If present, include VFS path statistics.
--vfs_stats_limit=<an integer> default: "-1"
Maximum number of VFS path statistics to print.

Build Options

Options category 'build_worker':
--hazelcast_standalone_listen_port=<an integer> default: "0"
Runs an embedded hazelcast server that listens to this port. The server does not join any cluster. This is useful for testing.
Options category 'config':
--sandbox_add_mount_pair=<a single path or a 'source:target' pair> multiple uses are accumulated
Add additional path pair to mount in sandbox.
--sandbox_block_path=<a string> multiple uses are accumulated
For sandboxed actions, disallow access to this path.
--sandbox_tmpfs_path=<a string> multiple uses are accumulated
For sandboxed actions, mount an empty, writable directory at this path (if supported by the sandboxing implementation, ignored otherwise).
Experimental options, which control experimental (and potentially risky) features:
--experimental_extra_action_filter=<a comma-separated list of regex expressions with prefix '-' specifying excluded paths> default: ""
Filters set of targets to schedule extra_actions for.
--[no]experimental_extra_action_top_level_only default: "false"
Only schedules extra_actions for top level targets.
--[no]experimental_extra_action_top_level_only_with_aspects default: "true"
If true and --experimental_extra_action_top_level_only=true, will include actions from aspects injected by top-level rules. This is an escape hatch in case commit df9e5e16c370391098c4432779ad4d1c9dd693ca breaks something.
--[no]experimental_interleave_loading_and_analysis default: "true"
No-op.
Flags options, for passing options to other tools:
--output_filter=<a valid Java regular expression> default: see description
Only shows warnings for rules with a name matching the provided regular expression.
Miscellaneous options:
--embed_label=<string> default: ""
Embed source control revision or release label in binary
--dash_secret=<a string> default: ""
The path to a file containing a secret shared with the dashboard server for writing build results.
--symlink_prefix=<a string> default: see description
The prefix that is prepended to any of the convenience symlinks that are created after a build. If '/' is passed, then no symlinks are created and no warning is emitted. If omitted, the default value is the name of the build tool.
--dash_url=<a string> default: ""
The URL of the dashboard server.
--[no]use_dash default: "false"
If build/test results should be sent to a remote dashboard.
--workspace_status_command=<path> default: ""
A command invoked at the beginning of the build to provide status information about the workspace in the form of key/value pairs. See the User's Manual for the full specification.
Options that specify how to locate packages:
--deleted_packages=<comma-separated list of package names> default: ""
A comma-separated list of names of packages which the build system will consider non-existent, even if they are visible somewhere on the package path. Use this option when deleting a subpackage 'x/y' of an existing package 'x'. For example, after deleting x/y/BUILD in your client, the build system may complain if it encounters a label '//x:y/z' if that is still provided by another package_path entry. Specifying --deleted_packages x/y avoids this problem.
--package_path=<colon-separated list of options> default: "%workspace%"
A colon-separated list of where to look for packages. Elements beginning with '%workspace%' are relative to the enclosing workspace. If omitted or empty, the default is the output of 'bazel info default-package-path'.
Options category 'remote':
--experimental_remote_platform_override=<a string> default: see description
Temporary, for testing only. Manually set a Platform to pass to remote execution.
--grpc_max_batch_inputs=<an integer> default: "100"
The maximal number of input file to be sent in a single batch. For client mode only.
--grpc_max_batch_size_bytes=<an integer> default: "10485760"
The maximal number of input bytes to be sent in a single batch. For client mode only.
--grpc_max_chunk_size_bytes=<an integer> default: "400000"
The maximal number of bytes to be sent in a single message. For client mode only.
--grpc_timeout_seconds=<an integer> default: "60"
The maximal number of seconds to wait for remote calls. For client mode only.
--hazelcast_client_config=<a string> default: see description
A file path to a hazelcast client config XML file. For client mode only.
--hazelcast_node=<a string> default: see description
A comma separated list of hostnames of hazelcast nodes. For client mode only.
--[no]remote_accept_cached default: "true"
Whether to accept remotely cached action results.
--[no]remote_allow_local_fallback default: "true"
Whether to fall back to standalone strategy if remote fails.
--remote_cache=<a string> default: see description
Hostname and port number of remote gRPC cache in the form of host:port. For client mode only.
--[no]remote_local_exec_upload_results default: "true"
Whether to upload action results to the remote cache after executing locally.
--remote_worker=<a string> default: see description
Hostname and port number of remote worker in the form of host:port. For client mode only.
--rest_cache_url=<a string> default: see description
A base URL for a RESTful cache server for storing build artifacts.It has to support PUT, GET, and HEAD requests.
Semantics options, which affect the build commands and/or output file contents:
--experimental_multi_cpu=<comma-separated list of options> multiple uses are accumulated
This flag allows specifying multiple target CPUs. If this is specified, the -- cpu option is ignored.
Strategy options, which affect how bazel will execute the build:
--[no]analysis_warnings_as_errors default: "false"
Treat visible analysis warnings as errors.
--local_resources=<comma-separated available amount of RAM (in MB), CPU (in cores) and available I/O (1.0 being average workstation)> default: see description
Explicitly set amount of local resources available to Bazel. By default, Bazel will query system configuration to estimate amount of RAM (in MB) and number of CPU cores available for the locally executed build actions. It would also assume default I/O capabilities of the local workstation (1.0). This options allows to explicitly set all 3 values. Note, that if this option is used, Bazel will ignore --ram_utilization_factor.
--[no]discard_analysis_cache default: "false"
Discard the analysis cache immediately after the analysis phase completes. Reduces memory usage by ~10%, but makes further incremental builds slower.
--experimental_persistent_javac
Enable the experimental persistent Java compiler.
Expands to:
  --strategy=Javac=worker
  --strategy=JavaIjar=local
  --strategy=JavaDeployJar=local
  --strategy=JavaSourceJar=local
  --strategy=Turbine=local
--genrule_strategy=<a string> default: ""
Specify how to execute genrules.'standalone' means run all of them locally.'sandboxed' means run them in namespaces based sandbox (available only on Linux)
--[no]ignore_unsupported_sandboxing default: "false"
Do not print a warning when sandboxed execution is not supported on this system.
--jobs=<an integer> [-j] default: "200"
The number of concurrent jobs to run. 0 means build sequentially. Values above 2000 are not allowed, and values above 1000 may cause memory issues.
--[no]keep_going [-k] default: "false"
Continue as much as possible after an error. While the target that failed, and those that depend on it, cannot be analyzed (or built), the other prerequisites of these targets can be analyzed (or built) all the same.
--ram_utilization_factor=<an integer> default: "67"
Specify what percentage of the system's RAM Bazel should try to use for its subprocesses. This option affects how many processes Bazel will try to run in parallel. If you run several Bazel builds in parallel, using a lower value for this option may avoid thrashing and thus improve overall throughput. Using a value higher than the default is NOT recommended. Note that Bazel's estimates are very coarse, so the actual RAM usage may be much higher or much lower than specified. Note also that this option does not affect the amount of memory that the Bazel server itself will use.
--[no]sandbox_debug default: "false"
Let the sandbox print debug information on execution. This might help developers of Bazel or Skylark rules with debugging failures due to missing input files, etc.
--[no]sandbox_fake_hostname default: "false"
Change the current hostname to 'localhost' for sandboxed actions.
--spawn_strategy=<a string> default: ""
Specify how spawn actions are executed by default.'standalone' means run all of them locally.'sandboxed' means run them in namespaces based sandbox (available only on Linux)
--strategy=<a 'name=value' assignment> multiple uses are accumulated
Specify how to distribute compilation of other spawn actions. Example: ' Javac=local' means to spawn Java compilation locally. ' JavaIjar=sandboxed' means to spawn Java Ijar actions in a sandbox.
--[no]resource_autosense default: "false"
This flag has no effect, and is deprecated
--worker_extra_flag=<a 'name=value' assignment> multiple uses are accumulated
Extra command-flags that will be passed to worker processes in addition to -- persistent_worker, keyed by mnemonic (e.g. --worker_extra_flag=Javac=--debug.
--worker_max_instances=<an integer> default: "4"
How many instances of a worker process (like the persistent Java compiler) may be launched if you use the 'worker' strategy.
--worker_max_retries=<an integer> default: "3"
If a worker fails during work, retry <worker_max_retries> times before giving up.
--[no]worker_quit_after_build default: "false"
If enabled, all workers quit after a build is done.
--[no]worker_sandboxing default: "false"
If enabled, workers will be executed in a sandboxed environment.
--[no]worker_verbose default: "false"
If enabled, prints verbose messages when workers are started, shutdown, ...
Options that affect how bazel runs tests:
--local_test_jobs=<an integer> default: "0"
The max number of local test jobs to run concurrently. 0 means local resources will limit the number of local test jobs to run concurrently instead. Setting this greater than the value for --jobs is ineffectual.
--[no]runs_per_test_detects_flakes default: "false"
If true, any shard in which at least one run/attempt passes and at least one run/attempt fails gets a FLAKY status.
--flaky_test_attempts=<an integer in 1-10 range or the string "default"> default: "default"
Each test will be retried up to the specified number of times in case of any test failure. Tests that required more than one attempt to pass would be marked as 'FLAKY' in the test summary. If this option is set, it should specify an int N or the string 'default'. If it's an int, then all tests will be run up to N times. If it is not specified or its value is ' default', then only a single test attempt will be made for regular tests and three for tests marked explicitly as flaky by their rule (flaky=1 attribute).
--[no]check_tests_up_to_date default: "false"
Don't run tests, just check if they are up-to-date. If all tests results are up-to-date, the testing completes successfully. If any test needs to be built or executed, an error is reported and the testing fails. This option implies --check_up_to_date behavior.
--[no]test_keep_going default: "true"
When disabled, any non-passing test will cause the entire build to stop. By default all tests are run, even if some do not pass.
--test_output=<summary, errors, all or streamed> default: "summary"
Specifies desired output mode. Valid values are 'summary' to output only test status summary, 'errors' to also print test logs for failed tests, 'all' to print logs for all tests and 'streamed' to output logs for all tests in real time (this will force tests to be executed locally one at a time regardless of --test_strategy value).
--test_strategy=<a string> default: ""
Specifies which strategy to use when running tests.
--test_summary=<short, terse, detailed or none> default: "short"
Specifies the desired format ot the test summary. Valid values are ' short' to print information only about tests executed, 'terse', to print information only about unsuccessful tests,'detailed' to print detailed information about failed test cases, and 'none' to omit the summary.
--test_timeout=<a single integer or comma-separated list of 4 integers> default: "-1"
Override the default test timeout values for test timeouts (in secs). If a single positive integer value is specified it will override all categories. If 4 comma-separated integers are specified, they will override the timeouts for short, moderate, long and eternal (in that order). In either form, a value of -1 tells bazel to use its default timeouts for that category.
--test_tmpdir=<a path> default: see description
Specifies the base temporary directory for 'bazel test' to use.
Verbosity options, which control what bazel prints:
--[no]announce default: "false"
Deprecated. No-op.
--explain=<a path> default: see description
Causes the build system to explain each executed step of the build. The explanation is written to the specified log file.
--show_result=<an integer> default: "1"
Show the results of the build. For each target, state whether or not it was brought up-to-date, and if so, a list of output files that were built. The printed files are convenient strings for copy+pasting to the shell, to execute them. This option requires an integer argument, which is the threshold number of targets above which result information is not printed. Thus zero causes suppression of the message and MAX_INT causes printing of the result to occur always. The default is one.
--progress_report_interval=<an integer in 0-3600 range> default: "0"
The number of seconds to wait between two reports on still running jobs. The default value 0 means to use the default 10:30:60 incremental algorithm.
--[no]show_loading_progress default: "true"
If enabled, causes Bazel to print "Loading package:" messages.
--[no]show_package_location default: "false"
If enabled, causes Bazel to print the location on the --package_path from which each package was loaded.
--[no]subcommands [-s] default: "false"
Display the subcommands executed during a build.
--[no]verbose_explanations default: "false"
Increases the verbosity of the explanations issued if --explain is enabled. Has no effect if --explain is not enabled.
--[no]verbose_failures default: "false"
If a command fails, print out the full command line.
Output selection options, for determining what to build/test:
--build_tag_filters=<comma-separated list of options> default: ""
Specifies a comma-separated list of tags. Each tag can be optionally preceded with '-' to specify excluded tags. Only those targets will be built that contain at least one included tag and do not contain any excluded tags. This option does not affect the set of tests executed with the 'test' command; those are be governed by the test filtering options, for example ' --test_tag_filters'
--[no]build_tests_only default: "false"
If specified, only *_test and test_suite rules will be built and other targets specified on the command line will be ignored. By default everything that was requested will be built.
--[no]check_up_to_date default: "false"
Don't perform the build, just check if it is up-to-date. If all targets are up-to-date, the build completes successfully. If any step needs to be executed an error is reported and the build fails.
--[no]compile_one_dependency default: "false"
Compile a single dependency of the argument files. This is useful for syntax checking source files in IDEs, for example, by rebuilding a single target that depends on the source file to detect errors as early as possible in the edit/build/test cycle. This argument affects the way all non-flag arguments are interpreted; instead of being targets to build they are source filenames. For each source filename an arbitrary target that depends on it will be built.
--loading_phase_threads=<an integer> default: "-1"
Number of parallel threads to use for the loading/analysis phase.
--[no]build default: "true"
Execute the build; this is the usual behaviour. Specifying --nobuild causes the build to stop before executing the build actions, returning zero iff the package loading and analysis phases completed successfully; this mode is useful for testing those phases.
--test_lang_filters=<comma-separated list of options> default: ""
Specifies a comma-separated list of test languages. Each language can be optionally preceded with '-' to specify excluded languages. Only those test targets will be found that are written in the specified languages. The name used for each language should be the same as the language prefix in the *_test rule, e.g. one of 'cc', 'java', 'py', etc.This option affects --build_tests_only behavior and the test command.
--test_size_filters=<comma-separated list of values: small, medium, large or enormous> default: ""
Specifies a comma-separated list of test sizes. Each size can be optionally preceded with '-' to specify excluded sizes. Only those test targets will be found that contain at least one included size and do not contain any excluded sizes. This option affects --build_tests_only behavior and the test command.
--test_tag_filters=<comma-separated list of options> default: ""
Specifies a comma-separated list of test tags. Each tag can be optionally preceded with '-' to specify excluded tags. Only those test targets will be found that contain at least one included tag and do not contain any excluded tags. This option affects --build_tests_only behavior and the test command.
--test_timeout_filters=<comma-separated list of values: short, moderate, long or eternal> default: ""
Specifies a comma-separated list of test timeouts. Each timeout can be optionally preceded with '-' to specify excluded timeouts. Only those test targets will be found that contain at least one included timeout and do not contain any excluded timeouts. This option affects --build_tests_only behavior and the test command.
Options category 'build':
--ios_cpu=<a string> default: "x86_64"
Specifies to target CPU of iOS compilation.
--ios_sdk_version=<a dotted version (for example '2.3' or '3.3alpha2.4')> default: see description
Specifies the version of the iOS SDK to use to build iOS applications.
--macos_sdk_version=<a dotted version (for example '2.3' or '3.3alpha2.4')> default: see description
Specifies the version of the macOS SDK to use to build macOS applications.
--tvos_sdk_version=<a dotted version (for example '2.3' or '3.3alpha2.4')> default: see description
Specifies the version of the tvOS SDK to use to build tvOS applications.
--watchos_sdk_version=<a dotted version (for example '2.3' or '3.3alpha2.4')> default: see description
Specifies the version of the watchOS SDK to use to build watchOS applications.
--xcode_version=<a dotted version (for example '2.3' or '3.3alpha2.4')> default: see description
If specified, uses Xcode of the given version for relevant build actions. If unspecified, uses the executor default version of Xcode.
Checking options, which control bazel's error checking and/or warnings:
--[no]check_licenses default: "false"
Check that licensing constraints imposed by dependent packages do not conflict with distribution modes of the targets being built. By default, licenses are not checked.
--[no]check_visibility default: "true"
If disabled, visibility errors are demoted to warnings.
--check_constraint=<a string> multiple uses are accumulated
Check the listed constraint.
Experimental options, which control experimental (and potentially risky) features:
--experimental_action_listener=<a build target label> multiple uses are accumulated
Use action_listener to attach an extra_action to existing build actions.
--[no]experimental_proto_extra_actions default: "false"
Run extra actions for alternative Java api versions in a proto_library.
--experimental_extra_action_filter=<a comma-separated list of regex expressions with prefix '-' specifying excluded paths> default: ""
Filters set of targets to schedule extra_actions for.
--[no]experimental_extra_action_top_level_only default: "false"
Only schedules extra_actions for top level targets.
--[no]experimental_extra_action_top_level_only_with_aspects default: "true"
If true and --experimental_extra_action_top_level_only=true, will include actions from aspects injected by top-level rules. This is an escape hatch in case commit df9e5e16c370391098c4432779ad4d1c9dd693ca breaks something.
--[no]experimental_incremental_dexing_error_on_missed_jars default: "false"
Do not use.
--[no]experimental_incremental_dexing_for_lite_protos default: "false"
Do not use.
--[no]experimental_inmemory_dotd_files default: "false"
If enabled, C++ .d files will be passed through in memory directly from the remote build nodes instead of being written to disk.
--[no]experimental_interleave_loading_and_analysis default: "true"
No-op.
--[no]experimental_prune_more_modules default: "false"
Deprecated. No effect.
--[no]reuseJavaCompileActionsFromProtoLibrary default: "false"
When true, a java_proto_library that wraps a proto_library with java_api_version!=0will reuse its actions. This saves memory and prevents duplicate jars from appearing on a Java compilation's classpath
--[no]experimental_skip_unused_modules default: "false"
Deprecated. No effect.
--[no]experimental_skyframe_native_filesets default: "false"
If true, Bazel will use the skyframe-native implementation of the Fileset rule. This offers improved performance in incremental builds of Filesets as well as correct incremental behavior, but is not yet stable. The default is false, meaning Bazel uses the legacy impelementation of Fileset.
--[no]experimental_use_llvm_covmap default: "false"
If specified, Bazel will generate llvm-cov coverage map information rather than gcov when collect_code_coverage is enabled.
Flags options, for passing options to other tools:
--apple_bitcode=<none, embedded_markers or embedded> default: "none"
Specify the Apple bitcode mode for compile steps. Values: 'none', ' embedded_markers', 'embedded'.
--[no]apple_generate_dsym default: "false"
Whether to generate debug symbol(.dSYM) file(s).
--[no]autofdo_lipo_data default: "false"
If true then the directory name for non-LIPO targets will have a '- lipodata' suffix in AutoFDO mode.
--conlyopt=<a string> multiple uses are accumulated
Additional option to pass to gcc when compiling C source files.
--copt=<a string> multiple uses are accumulated
Additional options to pass to gcc.
--objccopt=<a string> multiple uses are accumulated
Additional options to pass to Objective C compilation.
--swiftcopt=<a string> multiple uses are accumulated
Additional options to pass to Swift compilation.
--cxxopt=<a string> multiple uses are accumulated
Additional option to pass to gcc when compiling C++ source files.
--features=<a string> multiple uses are accumulated
The given features will be enabled or disabled by default for all packages. Specifying -<feature> will disable the feature globally. Negative features always override positive ones. This flag is used to enable rolling out default feature changes without a Bazel release.
--[no]device_debug_entitlements default: "true"
If set, and compilation mode is not 'opt', objc apps will include debug entitlements when signing.
--[no]enable_apple_binary_native_protos default: "true"
If set, apple_binary will generate and link objc protos into the output binary.
--[no]objc_enable_binary_stripping default: "false"
Whether to perform symbol and dead-code strippings on linked binaries. Binary strippings will be performed if both this flag and --compilationMode=opt are specified.
--[no]swift_whole_module_optimization default: "false"
Whether to enable Whole Module Optimization
--[no]experimental_objc_header_thinning default: "false"
If set then ObjcCompile actions will have their action inputs reduced by running a tool to detect which headers are actually required for compilation.
--[no]explicit_jre_deps default: "true"
Requires JRE dependencies to be declared in j2objc_library's jre_deps attribute.
--extra_entitlements=<a build target label> default: see description
Location of a .entitlements file that is merged into any iOS signing action in this build.
--fdo_instrument=<a path> default: see description
Generate binaries with FDO instrumentation. Specify the relative directory name for the .gcda files at runtime with GCC compiler. With Clang/LLVM compiler, it also accepts the directory name underwhich the raw profile file(s) will be dumped at runtime.
--fdo_optimize=<a string> default: see description
Use FDO profile information to optimize compilation. Specify the name of the zip file containing the .gcda file tree or an afdo file containing an auto profile. This flag also accepts files specified as labels, for example //foo/bar:file.afdo. Such labels must refer to input files; you may need to add an exports_files directive to the corresponding package to make the file visible to Bazel. It also accepts an indexed LLVM profile file.
--[no]objc_generate_linkmap default: "false"
Specifies whether to generate a linkmap file.
--[no]deprecated_generate_xcode_project default: "true"
If set, will generate xcode project for targets that support this. Will be removed soon.
--host_copt=<a string> multiple uses are accumulated
Additional options to pass to gcc for host tools.
--host_cxxopt=<a string> multiple uses are accumulated
Additional options to pass to gcc for host tools.
--ios_minimum_os=<a dotted version (for example '2.3' or '3.3alpha2.4')> default: "7.0"
Minimum compatible iOS version for target simulators and devices.
--ios_multi_cpus=<comma-separated list of options> default: ""
Comma-separated list of architectures to build an ios_application with. The result is a universal binary containing all specified architectures.
--ios_signing_cert_name=<a string> default: see description
Certificate name to use for iOS signing. If not set will fall back to provisioning profile. May be the certificate's keychain identity preference or (substring) of the certificate's common name, as per codesign's man page (SIGNING IDENTITIES).
--javacopt=<a string> multiple uses are accumulated
Additional options to pass to javac.
--jvmopt=<a string> multiple uses are accumulated
Additional options to pass to the Java VM. These options will get added to the VM startup options of each java_binary target.
--linkopt=<a string> multiple uses are accumulated
Additional option to pass to gcc when linking.
--lipo_context=<a build target label> default: see description
Specifies the binary from which the LIPO profile information comes.
--lipo=<off or binary> default: "off"
Enable LIPO optimization (lightweight inter-procedural optimization, The allowed values for this option are 'off' and 'binary', which enables LIPO. This option only has an effect when FDO is also enabled. Currently LIPO is only supported when building a single cc_binary rule.
--ltoindexopt=<a string> multiple uses are accumulated
Additional option to pass to the LTO indexing step (under --features=thin_lto).
--macos_cpus=<comma-separated list of options> default: "x86_64"
Comma-separated list of architectures for which to build Apple macOS binaries.
--macos_minimum_os=<a dotted version (for example '2.3' or '3.3alpha2.4')> default: "10.10"
Minimum compatible macOS version for targets.
--output_filter=<a valid Java regular expression> default: see description
Only shows warnings for rules with a name matching the provided regular expression.
--plugin_copt=<An option for a plugin> multiple uses are accumulated
Plugin options
--plugin=<a build target label> multiple uses are accumulated
Plugins to use in the build. Currently works with java_plugin.
--[no]objc_includes_prioritize_static_libs default: "false"
If set, the linker invocation will contain static library includes before frameworks and system libraries.
--proto_compiler=<a build target label> default: "@com_google_protobuf//:protoc"
The label of the proto-compiler.
--proto_toolchain_for_cc=<a build target label> default: "@com_google_protobuf_cc//:cc_toolchain"
Label of proto_lang_toolchain() which describes how to compile C++ protos
--proto_toolchain_for_java=<a build target label> default: "@com_google_protobuf_java//:java_toolchain"
Label of proto_lang_toolchain() which describes how to compile Java protos
--proto_toolchain_for_javalite=<a build target label> default: "@com_google_protobuf_javalite//:javalite_toolchain"
Label of proto_lang_toolchain() which describes how to compile JavaLite protos
--protocopt=<a string> multiple uses are accumulated
Additional options to pass to the protobuf compiler.
--strip=<always, sometimes or never> default: "sometimes"
Specifies whether to strip binaries and shared libraries (using "-Wl,-- strip-debug"). The default value of 'sometimes' means strip iff -- compilation_mode=fastbuild.
--stripopt=<a string> multiple uses are accumulated
Additional options to pass to strip when generating a '<name>. stripped' binary.
--[no]output_symbol_counts default: "false"
If enabled, every C++ binary linked with gold will store the number of used symbols per object file in a .sc file.
--target_environment=<a build target label> multiple uses are accumulated
Declares this build's target environment. Must be a label reference to an "environment" rule. If specified, all top-level targets must be compatible with this environment.
--j2objc_translation_flags=<comma-separated list of options> multiple uses are accumulated
Additional options to pass to the J2ObjC tool.
--tvos_cpus=<comma-separated list of options> default: "x86_64"
Comma-separated list of architectures for which to build Apple tvOS binaries.
--tvos_minimum_os=<a dotted version (for example '2.3' or '3.3alpha2.4')> default: see description
Minimum compatible tvOS version for target simulators and devices.
--[no]objc_use_dotd_pruning default: "true"
If set, .d files emited by clang will be used to prune the set of inputs passed into objc compiles.
--watchos_cpus=<comma-separated list of options> default: "i386"
Comma-separated list of architectures for which to build Apple watchOS binaries.
--watchos_minimum_os=<a dotted version (for example '2.3' or '3.3alpha2.4')> default: see description
Minimum compatible watchOS version for target simulators and devices.
--xcode_toolchain=<a string> default: see description
The identifier of an Xcode toolchain to use for builds. Currently only the toolchains that ship with Xcode are supported. For example, in addition to the default toolchain Xcode 8 has 'com.apple.dt.toolchain.Swift_2_3' which can be used for building legacy Swift code.
Miscellaneous options:
--platform_suffix=<a string> default: see description
Specifies a suffix to be added to the configuration directory.
--[no]ios_memleaks default: "false"
Enable checking for memory leaks in ios_test targets.
--symlink_prefix=<a string> default: see description
The prefix that is prepended to any of the convenience symlinks that are created after a build. If '/' is passed, then no symlinks are created and no warning is emitted. If omitted, the default value is the name of the build tool.
Options that specify how to locate packages:
--deleted_packages=<comma-separated list of package names> default: ""
A comma-separated list of names of packages which the build system will consider non-existent, even if they are visible somewhere on the package path. Use this option when deleting a subpackage 'x/y' of an existing package 'x'. For example, after deleting x/y/BUILD in your client, the build system may complain if it encounters a label '//x:y/z' if that is still provided by another package_path entry. Specifying --deleted_packages x/y avoids this problem.
--package_path=<colon-separated list of options> default: "%workspace%"
A colon-separated list of where to look for packages. Elements beginning with '%workspace%' are relative to the enclosing workspace. If omitted or empty, the default is the output of 'bazel info default-package-path'.
Options specific to 'bazel run':
--ios_simulator_device=<a string> default: "iPhone 5s"
The device to simulate when running an iOS application in the simulator, e.g. 'iPhone 6'. You can get a list of devices by running 'xcrun simctl list devicetypes' on the machine the simulator will be run on.
--ios_simulator_version=<a dotted version (for example '2.3' or '3.3alpha2.4')> default: "9.3"
The version of iOS to run on the simulator when running or testing. This is ignored for ios_test rules if a target device is specified in the rule.
--run_under=<a prefix in front of command> default: see description
Prefix to insert in front of command before running. Examples: --run_under=valgrind --run_under=strace --run_under='strace -c' --run_under='valgrind --quiet --num-callers=20' --run_under=//package:target --run_under='//package:target --options'
--tvos_simulator_device=<a string> default: "Apple TV 1080p"
The device to simulate when running an tvOS application in the simulator, e.g. 'Apple TV 1080p'. You can get a list of devices by running 'xcrun simctl list devicetypes' on the machine the simulator will be run on.
--tvos_simulator_version=<a dotted version (for example '2.3' or '3.3alpha2.4')> default: "9.0"
The version of tvOS to run on the simulator when running or testing.
--watchos_simulator_device=<a string> default: "Apple Watch - 38mm"
The device to simulate when running an watchOS application in the simulator, e. g. 'Apple Watch - 38mm'. You can get a list of devices by running ' xcrun simctl list devicetypes' on the machine the simulator will be run on.
--watchos_simulator_version=<a dotted version (for example '2.3' or '3.3alpha2.4')> default: "2.0"
The version of watchOS to run on the simulator when running or testing.
Semantics options, which affect the build commands and/or output file contents:
--action_env=<a 'name=value' assignment with an optional value part> multiple uses are accumulated
Specifies the set of environment variables available to actions. Variables can be either specified by name, in which case the value will be taken from the invocation environment, or by the name=value pair which sets the value independent of the invocation environment. This option can be used multiple times; for options given for the same variable, the latest wins, options for different variables accumulate.
--android_crosstool_top=<a build target label> default: "//external:android/crosstool"
The location of the C++ compiler used for Android builds.
--[no]build_test_dwp default: "false"
If enabled, when building C++ tests statically and with fission the .dwp file for the test binary will be automatically built as well.
--[no]translations default: "auto"
Translate Java messages; bundle all translations into the jar for each affected rule.
--[no]check_fileset_dependencies_recursively default: "true"
If false, fileset targets will, whenever possible, create symlinks to directories instead of creating one symlink for each file inside the directory. Disabling this will significantly speed up fileset builds, but targets that depend on filesets will not be rebuilt if files are added, removed or modified in a subdirectory which has not been traversed.
--define=<a 'name=value' assignment> multiple uses are accumulated
Each --define option specifies an assignment for a build variable.
--compilation_mode=<fastbuild, dbg or opt> [-c] default: "fastbuild"
Specify the mode the binary will be built in. Values: 'fastbuild', ' dbg', 'opt'.
--android_compiler=<a string> default: see description
The Android target compiler.
--android_cpu=<a string> default: "armeabi"
The Android target CPU.
--cpu=<a string> default: ""
The target CPU.
--custom_malloc=<a build target label> default: see description
Specifies a custom malloc implementation. This setting overrides malloc attributes in build rules.
--dynamic_mode=<off, default or fully> default: "default"
Determines whether C++ binaries will be linked dynamically. 'default' means bazel will choose whether to link dynamically. 'fully' means all libraries will be linked dynamically. 'off' means that all libraries will be linked in mostly static mode.
--[no]experimental_omitfp default: "false"
If true, use libunwind for stack unwinding, and compile with -fomit-frame- pointer and -fasynchronous-unwind-tables.
--fat_apk_cpu=<comma-separated list of options> default: "armeabi-v7a"
Setting this option enables fat APKs, which contain native binaries for all specified target architectures, e.g., --fat_apk_cpu=x86,armeabi-v7a. If this flag is specified, then --android_cpu is ignored for dependencies of android_binary rules.
--fission=<a set of compilation modes> default: "no"
Specifies which compilation modes use fission for C++ compilations and links. May be any combination of {'fastbuild', 'dbg', 'opt'} or the special values 'yes' to enable all modes and 'no' to disable all modes.
--[no]force_ignore_dash_static default: "false"
If set, '-static' options in the linkopts of cc_* rules will be ignored.
--[no]force_pic default: "false"
If enabled, all C++ compilations produce position-independent code ("- fPIC"), links prefer PIC pre-built libraries over non-PIC libraries, and links produce position-independent executables ("-pie").
--[no]java_header_compilation default: "true"
Compile ijars directly from source.
--host_cpu=<a string> default: ""
The host CPU.
--host_crosstool_top=<a build target label> default: see description
By default, the --crosstool_top and --compiler options are also used for the host configuration. If this flag is provided, Bazel uses the default libc and compiler for the given crosstool_top.
--host_java_launcher=<a build target label> default: see description
The Java launcher used by tools that are executed during a build.
--[no]incremental_dexing default: "false"
Does most of the work for dexing separately for each Jar file. Incompatible with Jack and Jill.
--[no]instrument_test_targets default: "false"
When coverage is enabled, specifies whether to consider instrumenting test rules. When set, test rules included by --instrumentation_filter are instrumented. Otherwise, test rules are always excluded from coverage instrumentation.
--instrumentation_filter=<a comma-separated list of regex expressions with prefix '-' specifying excluded paths> default: "-/javatests[/:]"
When coverage is enabled, only rules with names included by the specified regex- based filter will be instrumented. Rules prefixed with '-' are excluded instead. Note that only non-test rules are instrumented unless -- instrument_test_targets is enabled.
--[no]experimental_android_jack_sanity_checks default: "false"
Enables sanity checks for Jack and Jill compilation.
--java_classpath=<off, javabuilder or bazel> default: "javabuilder"
Enables reduced classpaths for Java compilations.
--java_launcher=<a build target label> default: see description
The Java launcher to use when building Java binaries. The "launcher" attribute overrides this flag.
--[no]legacy_whole_archive default: "true"
When on, use --whole-archive for cc_binary rules that have linkshared=1 and either linkstatic=1 or '-static' in linkopts. This is for backwards compatibility only. A better alternative is to use alwayslink=1 where required.
--[no]experimental_link_compile_output_separately default: "false"
This flag is experimental and may go away at any time. If true, dynamically linked binary targets will build and link their own srcs as a dynamic library instead of directly linking it in.
--android_manifest_merger=<legacy or android> default: "android"
Selects the manifest merger to use for android_binary rules. Flag to help thetransition to the Android manifest merger from the legacy merger.
--experimental_multi_cpu=<comma-separated list of options> multiple uses are accumulated
This flag allows specifying multiple target CPUs. If this is specified, the -- cpu option is ignored.
--non_incremental_per_target_dexopts=<comma-separated list of options> default: "--no-locals"
dx flags that that prevent incremental dexing for binary targets that list any of the flags listed here in their 'dexopts' attribute, which are ignored with incremental dexing (superseding -- dexopts_supported_in_incremental_dexing). Defaults to --no-locals for safety but can in general be used to make sure the listed dx flags are honored, with additional build latency. Please notify us if you find yourself needing this flag.
--per_file_copt=<a comma-separated list of regex expressions with prefix '-' specifying excluded paths followed by an @ and a comma separated list of options> multiple uses are accumulated
Additional options to selectively pass to gcc when compiling certain files. This option can be passed multiple times. Syntax: regex_filter@option_1, option_2,...,option_n. Where regex_filter stands for a list of include and exclude regular expression patterns (Also see --instrumentation_filter). option_1 to option_n stand for arbitrary command line options. If an option contains a comma it has to be quoted with a backslash. Options can contain @. Only the first @ is used to split the string. Example: --per_file_copt=//foo/. *\.cc,-//foo/bar\.cc@-O0 adds the -O0 command line option to the gcc command line of all cc files in //foo/ except bar.cc.
--[no]process_headers_in_dependencies default: "false"
When building a target //a:a, process headers in all targets that //a:a depends on (if header processing is enabled for the toolchain).
--[no]send_transitive_header_module_srcs default: "true"
Obsolete. Don't use.
--[no]experimental_skip_static_outputs default: "false"
This flag is experimental and may go away at any time. If true, linker output for mostly-static C++ executables is a tiny amount of dummy dependency information, and NOT a usable binary. Kludge, but can reduce network and disk I/O load (and thus, continuous build cycle times) by a lot. NOTE: use of this flag REQUIRES --distinct_host_configuration.
--[no]stamp default: "false"
Stamp binaries with the date, username, hostname, workspace information, etc.
--[no]strict_filesets default: "false"
If this option is enabled, filesets crossing package boundaries are reported as errors. It does not work when check_fileset_dependencies_recursively is disabled.
--strict_java_deps=<off, warn, error, strict or default> default: "default"
If true, checks that a Java target explicitly declares all directly used targets as dependencies.
--strict_proto_deps=<off, warn, error, strict or default> default: "strict"
If true, checks that a proto_library target explicitly declares all directly used targets as dependencies.
--message_translations=<a string> multiple uses are accumulated
The message translations used for translating messages in Java targets.
--[no]android_resource_shrinking default: "false"
Enables resource shrinking for android_binary APKs that use ProGuard.
--[no]experimental_android_use_jack_for_dexing default: "false"
Switches to the Jack and Jill toolchain for dexing instead of javac and dx.
Strategy options, which affect how bazel will execute the build:
--[no]analysis_warnings_as_errors default: "false"
Treat visible analysis warnings as errors.
--local_resources=<comma-separated available amount of RAM (in MB), CPU (in cores) and available I/O (1.0 being average workstation)> default: see description
Explicitly set amount of local resources available to Bazel. By default, Bazel will query system configuration to estimate amount of RAM (in MB) and number of CPU cores available for the locally executed build actions. It would also assume default I/O capabilities of the local workstation (1.0). This options allows to explicitly set all 3 values. Note, that if this option is used, Bazel will ignore --ram_utilization_factor.
--[no]build_runfile_links default: "true"
If true, build runfiles symlink forests for all targets. If false, write only manifests when possible.
--[no]discard_analysis_cache default: "false"
Discard the analysis cache immediately after the analysis phase completes. Reduces memory usage by ~10%, but makes further incremental builds slower.
--[no]java_deps default: "true"
Generate dependency information (for now, compile-time classpath) per Java target.
--jobs=<an integer> [-j] default: "200"
The number of concurrent jobs to run. 0 means build sequentially. Values above 2000 are not allowed, and values above 1000 may cause memory issues.
--[no]keep_going [-k] default: "false"
Continue as much as possible after an error. While the target that failed, and those that depend on it, cannot be analyzed (or built), the other prerequisites of these targets can be analyzed (or built) all the same.
--[no]legacy_external_runfiles default: "true"
If true, build runfiles symlink forests for external repositories under . runfiles/wsname/external/repo (in addition to .runfiles/repo).
--[no]parse_headers_verifies_modules default: "false"
If enabled, the parse_headers feature verifies that a header module can be built for the target in question instead of doing a separate compile of the header.
--[no]prune_cpp_modules default: "true"
If enabled, use the results of input discovery to reduce the number of used modules.
--ram_utilization_factor=<an integer> default: "67"
Specify what percentage of the system's RAM Bazel should try to use for its subprocesses. This option affects how many processes Bazel will try to run in parallel. If you run several Bazel builds in parallel, using a lower value for this option may avoid thrashing and thus improve overall throughput. Using a value higher than the default is NOT recommended. Note that Bazel's estimates are very coarse, so the actual RAM usage may be much higher or much lower than specified. Note also that this option does not affect the amount of memory that the Bazel server itself will use.
--[no]share_native_deps default: "true"
If true, native libraries that contain identical functionality will be shared among different targets
--[no]strict_system_includes default: "false"
If true, headers found through system include paths (-isystem) are also required to be declared.
--[no]distinct_host_configuration default: "true"
Build all the tools used during the build for a distinct configuration from that used for the target program. When this is disabled, the same configuration is used for host and target programs. This may cause undesirable rebuilds of tools such as the protocol compiler (and then everything downstream) whenever a minor change is made to the target configuration, such as setting the linker options. When this enabled (the default), a distinct configuration will be used to build the tools, preventing undesired rebuilds. However, certain libraries will then need to be compiled twice, once for each configuration, which may cause some builds to be slower. As a rule of thumb, this option is likely to benefit users that make frequent changes in configuration (e.g. opt/dbg). Please read the user manual for the full explanation.
--[no]use_ijars default: "true"
If enabled, this option causes Java compilation to use interface jars. This will result in faster incremental compilation, but error messages can be different.
--[no]interface_shared_objects default: "true"
Use interface shared objects if supported by the toolchain. All ELF toolchains currently support this setting.
--[no]resource_autosense default: "false"
This flag has no effect, and is deprecated
--[no]start_end_lib default: "true"
Use the --start-lib/--end-lib ld options if supported by the toolchain.
Options that affect how bazel runs tests:
--[no]cache_test_results [-t] default: "auto"
If 'auto', Bazel will only rerun a test if any of the following conditions apply: (1) Bazel detects changes in the test or its dependencies (2) the test is marked as external (3) multiple test runs were requested with -- runs_per_test (4) the test failed If 'yes', the caching behavior will be the same as 'auto' except that it may cache test failures and test runs with --runs_per_test. If 'no', all tests will be always executed.
--[no]collect_code_coverage default: "false"
If specified, Bazel will instrument code (using offline instrumentation where possible) and will collect coverage information during tests. Only targets that match --instrumentation_filter will be affected. Usually this option should not be specified directly - 'bazel coverage' command should be used instead.
--[no]microcoverage default: "false"
If specified with coverage, Bazel will collect microcoverage (per test method coverage) information during tests. Only targets that match -- instrumentation_filter will be affected. Usually this option should not be specified directly - 'bazel coverage --microcoverage' command should be used instead.
--coverage_report_generator=<a build target label> default: "@bazel_tools//tools/test:coverage_report_generator"
Location of the binary that is used to generate coverage reports. This must currently be a filegroup that contains a single file, the binary. Defaults to '//tools/test:coverage_report_generator'.
--coverage_support=<a build target label> default: "@bazel_tools//tools/test:coverage_support"
Location of support files that are required on the inputs of every test action that collects code coverage. Defaults to '//tools/test: coverage_support'.
--java_debug
Causes the Java virtual machine of a java test to wait for a connection from a JDWP-compliant debugger (such as jdb) before starting the test. Implies - test_output=streamed.
Expands to:
  --test_arg=--wrapper_script_flag=--debug
  --test_output=streamed
  --test_strategy=exclusive
  --test_timeout=9999
  --nocache_test_results
--local_test_jobs=<an integer> default: "0"
The max number of local test jobs to run concurrently. 0 means local resources will limit the number of local test jobs to run concurrently instead. Setting this greater than the value for --jobs is ineffectual.
--runs_per_test=<a positive integer or test_regex@runs. This flag may be passed more than once> multiple uses are accumulated
Specifies number of times to run each test. If any of those attempts fail for any reason, the whole test would be considered failed. Normally the value specified is just an integer. Example: --runs_per_test=3 will run all tests 3 times. Alternate syntax: regex_filter@runs_per_test. Where runs_per_test stands for an integer value and regex_filter stands for a list of include and exclude regular expression patterns (Also see --instrumentation_filter). Example: -- runs_per_test=//foo/.*,-//foo/bar/.*@3 runs all tests in //foo/ except those under foo/bar three times. This option can be passed multiple times.
--[no]runs_per_test_detects_flakes default: "false"
If true, any shard in which at least one run/attempt passes and at least one run/attempt fails gets a FLAKY status.
--test_arg=<a string> multiple uses are accumulated
Specifies additional options and arguments that should be passed to the test executable. Can be used multiple times to specify several arguments. If multiple tests are executed, each of them will receive identical arguments. Used only by the 'bazel test' command.
--flaky_test_attempts=<an integer in 1-10 range or the string "default"> default: "default"
Each test will be retried up to the specified number of times in case of any test failure. Tests that required more than one attempt to pass would be marked as 'FLAKY' in the test summary. If this option is set, it should specify an int N or the string 'default'. If it's an int, then all tests will be run up to N times. If it is not specified or its value is ' default', then only a single test attempt will be made for regular tests and three for tests marked explicitly as flaky by their rule (flaky=1 attribute).
--[no]check_tests_up_to_date default: "false"
Don't run tests, just check if they are up-to-date. If all tests results are up-to-date, the testing completes successfully. If any test needs to be built or executed, an error is reported and the testing fails. This option implies --check_up_to_date behavior.
--test_env=<a 'name=value' assignment with an optional value part> multiple uses are accumulated
Specifies additional environment variables to be injected into the test runner environment. Variables can be either specified by name, in which case its value will be read from the Bazel client environment, or by the name=value pair. This option can be used multiple times to specify several variables. Used only by the 'bazel test' command.
--test_filter=<a string> default: see description
Specifies a filter to forward to the test framework. Used to limit the tests run. Note that this does not affect which targets are built.
--[no]test_keep_going default: "true"
When disabled, any non-passing test will cause the entire build to stop. By default all tests are run, even if some do not pass.
--test_output=<summary, errors, all or streamed> default: "summary"
Specifies desired output mode. Valid values are 'summary' to output only test status summary, 'errors' to also print test logs for failed tests, 'all' to print logs for all tests and 'streamed' to output logs for all tests in real time (this will force tests to be executed locally one at a time regardless of --test_strategy value).
--test_result_expiration=<an integer> default: "-1"
This option is deprecated and has no effect.
--test_sharding_strategy=<explicit, experimental_heuristic or disabled> default: "explicit"
Specify strategy for test sharding: 'explicit' to only use sharding if the 'shard_count' BUILD attribute is present. 'disabled' to never use test sharding. 'experimental_heuristic' to enable sharding on remotely executed tests without an explicit 'shard_count' attribute which link in a supported framework. Considered experimental.
--test_strategy=<a string> default: ""
Specifies which strategy to use when running tests.
--test_summary=<short, terse, detailed or none> default: "short"
Specifies the desired format ot the test summary. Valid values are ' short' to print information only about tests executed, 'terse', to print information only about unsuccessful tests,'detailed' to print detailed information about failed test cases, and 'none' to omit the summary.
--test_timeout=<a single integer or comma-separated list of 4 integers> default: "-1"
Override the default test timeout values for test timeouts (in secs). If a single positive integer value is specified it will override all categories. If 4 comma-separated integers are specified, they will override the timeouts for short, moderate, long and eternal (in that order). In either form, a value of -1 tells bazel to use its default timeouts for that category.
--test_tmpdir=<a path> default: see description
Specifies the base temporary directory for 'bazel test' to use.
Verbosity options, which control what bazel prints:
--[no]announce default: "false"
Deprecated. No-op.
--explain=<a path> default: see description
Causes the build system to explain each executed step of the build. The explanation is written to the specified log file.
--show_result=<an integer> default: "1"
Show the results of the build. For each target, state whether or not it was brought up-to-date, and if so, a list of output files that were built. The printed files are convenient strings for copy+pasting to the shell, to execute them. This option requires an integer argument, which is the threshold number of targets above which result information is not printed. Thus zero causes suppression of the message and MAX_INT causes printing of the result to occur always. The default is one.
--progress_report_interval=<an integer in 0-3600 range> default: "0"
The number of seconds to wait between two reports on still running jobs. The default value 0 means to use the default 10:30:60 incremental algorithm.
--[no]show_loading_progress default: "true"
If enabled, causes Bazel to print "Loading package:" messages.
--[no]show_package_location default: "false"
If enabled, causes Bazel to print the location on the --package_path from which each package was loaded.
--[no]subcommands [-s] default: "false"
Display the subcommands executed during a build.
--[no]verbose_explanations default: "false"
Increases the verbosity of the explanations issued if --explain is enabled. Has no effect if --explain is not enabled.
--[no]verbose_failures default: "false"
If a command fails, print out the full command line.
Version options, for selecting which version of other tools will be used:
--apple_crosstool_top=<a build target label> default: "@bazel_tools//tools/cpp:toolchain"
The label of the crosstool package to be used in Apple and Objc rules and their dependencies.
--compiler=<a string> default: see description
The C++ compiler to use for compiling the target.
--crosstool_top=<a build target label> default: "@bazel_tools//tools/cpp:toolchain"
The label of the crosstool package to be used for compiling C++ code.
--force_python=<py2, py3, py2and3, py2only or py3only> default: see description
Overrides default_python_version attribute. Can be "PY2" or " PY3".
--glibc=<a string> default: see description
The version of glibc the target should be linked against. By default, a suitable version is chosen based on --cpu.
--host_force_python=<py2, py3, py2and3, py2only or py3only> default: see description
Overrides default_python_version attribute for the host configuration. Can be "PY2" or "PY3".
--host_javabase=<a string> default: "@bazel_tools//tools/jdk:jdk"
JAVABASE used for the host JDK. This is the JAVABASE which is used to execute tools during a build.
--host_java_toolchain=<a build target label> default: "@bazel_tools//tools/jdk:toolchain"
The Java toolchain used to build tools that are executed during a build.
--host_grte_top=<a label> default: see description
If specified, this setting overrides the libc top-level directory (--grte_top) for the host configuration.
--javabase=<a string> default: "@bazel_tools//tools/jdk:jdk"
JAVABASE used for the JDK invoked by Bazel. This is the JAVABASE which will be used to execute external Java commands.
--java_toolchain=<a build target label> default: "@bazel_tools//tools/jdk:toolchain"
The name of the toolchain rule for Java.
--grte_top=<a label> default: see description
A label to a checked-in libc library. The default value is selected by the crosstool toolchain, and you almost never need to override it.
--proguard_top=<a build target label> default: see description
Specifies which version of ProGuard to use for code removal when building a Java binary.
--python2_path=<a string> default: "python"
Local path to the Python2 executable.
--python3_path=<a string> default: "python3"
Local path to the Python3 executable.
--android_sdk=<a build target label> default: "@bazel_tools//tools/android:sdk"
Specifies Android SDK/platform that is used to build Android applications.
--experimental_stl=<a build target label> default: see description
If set, use this label instead of the default STL implementation. This option is EXPERIMENTAL and may go away in a future release.
Output selection options, for determining what to build/test:
--build_tag_filters=<comma-separated list of options> default: ""
Specifies a comma-separated list of tags. Each tag can be optionally preceded with '-' to specify excluded tags. Only those targets will be built that contain at least one included tag and do not contain any excluded tags. This option does not affect the set of tests executed with the 'test' command; those are be governed by the test filtering options, for example ' --test_tag_filters'
--[no]build_tests_only default: "false"
If specified, only *_test and test_suite rules will be built and other targets specified on the command line will be ignored. By default everything that was requested will be built.
--[no]check_up_to_date default: "false"
Don't perform the build, just check if it is up-to-date. If all targets are up-to-date, the build completes successfully. If any step needs to be executed an error is reported and the build fails.
--[no]compile_one_dependency default: "false"
Compile a single dependency of the argument files. This is useful for syntax checking source files in IDEs, for example, by rebuilding a single target that depends on the source file to detect errors as early as possible in the edit/build/test cycle. This argument affects the way all non-flag arguments are interpreted; instead of being targets to build they are source filenames. For each source filename an arbitrary target that depends on it will be built.
--loading_phase_threads=<an integer> default: "-1"
Number of parallel threads to use for the loading/analysis phase.
--[no]build default: "true"
Execute the build; this is the usual behaviour. Specifying --nobuild causes the build to stop before executing the build actions, returning zero iff the package loading and analysis phases completed successfully; this mode is useful for testing those phases.
--[no]save_temps default: "false"
If set, temporary outputs from gcc will be saved. These include .s files (assembler code), .i files (preprocessed C) and .ii files (preprocessed C++).
--test_lang_filters=<comma-separated list of options> default: ""
Specifies a comma-separated list of test languages. Each language can be optionally preceded with '-' to specify excluded languages. Only those test targets will be found that are written in the specified languages. The name used for each language should be the same as the language prefix in the *_test rule, e.g. one of 'cc', 'java', 'py', etc.This option affects --build_tests_only behavior and the test command.
--test_size_filters=<comma-separated list of values: small, medium, large or enormous> default: ""
Specifies a comma-separated list of test sizes. Each size can be optionally preceded with '-' to specify excluded sizes. Only those test targets will be found that contain at least one included size and do not contain any excluded sizes. This option affects --build_tests_only behavior and the test command.
--test_tag_filters=<comma-separated list of options> default: ""
Specifies a comma-separated list of test tags. Each tag can be optionally preceded with '-' to specify excluded tags. Only those test targets will be found that contain at least one included tag and do not contain any excluded tags. This option affects --build_tests_only behavior and the test command.
--test_timeout_filters=<comma-separated list of values: short, moderate, long or eternal> default: ""
Specifies a comma-separated list of test timeouts. Each timeout can be optionally preceded with '-' to specify excluded timeouts. Only those test targets will be found that contain at least one included timeout and do not contain any excluded timeouts. This option affects --build_tests_only behavior and the test command.
Options category 'xcode':
--xcode_override_workspace_root=<a string> default: ""
If set, then this path will be used as workspace_root and mainGroup path when generating an .xcodeproj/project.pbxproj file.

Canonicalize-flags Options

Miscellaneous options:
--for_command=<a string> default: "build"
The command for which the options should be canonicalized.
--invocation_policy=<a string> default: ""
Applies an invocation policy to the options to be canonicalized.

Clean Options

Inherits all options from build.

Options category 'clean':
--[no]async default: "false"
If specified, clean asynchronously removes the entire working tree for this % {product} instance, which includes all bazel-created temporary and build output files. When this command completes, it will be safe to execute new commands in the same client, even though the deletion may continue in the background.
Expands to:
  --clean_style=async
--clean_style=<a string> default: ""
Can be 'expunge', 'expunge_async', or 'async'.
--[no]expunge default: "false"
If specified, clean removes the entire working tree for this bazel instance, which includes all bazel-created temporary and build output files, and stops the bazel server if it is running.
Expands to:
  --clean_style=expunge
--[no]expunge_async default: "false"
If specified, clean asynchronously removes the entire working tree for this % {product} instance, which includes all bazel-created temporary and build output files, and stops the bazel server if it is running. When this command completes, it will be safe to execute new commands in the same client, even though the deletion may continue in the background.
Expands to:
  --clean_style=expunge_async

Coverage Options

Inherits all options from test.

Dump Options

Verbosity options, which control what bazel prints:
--[no]action_cache default: "false"
Dump action cache content.
--[no]packages default: "false"
Dump package cache content.
--[no]rule_classes default: "false"
Dump rule classes.
--skyframe=<off, summary or detailed> default: "off"
Dump Skyframe graph: 'off', 'summary', or 'detailed'.
--[no]vfs default: "false"
Dump virtual filesystem cache content.

Fetch Options

Options that specify how to locate packages:
--deleted_packages=<comma-separated list of package names> default: ""
A comma-separated list of names of packages which the build system will consider non-existent, even if they are visible somewhere on the package path. Use this option when deleting a subpackage 'x/y' of an existing package 'x'. For example, after deleting x/y/BUILD in your client, the build system may complain if it encounters a label '//x:y/z' if that is still provided by another package_path entry. Specifying --deleted_packages x/y avoids this problem.
--package_path=<colon-separated list of options> default: "%workspace%"
A colon-separated list of where to look for packages. Elements beginning with '%workspace%' are relative to the enclosing workspace. If omitted or empty, the default is the output of 'bazel info default-package-path'.
Strategy options, which affect how bazel will execute the build:
--[no]keep_going [-k] default: "false"
Continue as much as possible after an error. While the target that failed and those that depend on it cannot be analyzed, other prerequisites of these targets can be.
Verbosity options, which control what bazel prints:
--[no]show_loading_progress default: "true"
If enabled, causes Bazel to print "Loading package:" messages.
--[no]show_package_location default: "false"
If enabled, causes Bazel to print the location on the --package_path from which each package was loaded.

Help Options

Help options:
--help_verbosity=<long, medium or short> default: "medium"
Select the verbosity of the help command.
--long [-l]
Show full description of each option, instead of just its name.
Expands to:
  --help_verbosity=long
--short
Show only the names of the options, not their types or meanings.
Expands to:
  --help_verbosity=short

Info Options

Inherits all options from build.

Miscellaneous options:
--[no]show_make_env default: "false"
Include the "Make" environment in the output.

Mobile-install Options

Inherits all options from build.

Options category 'mobile-install':
--adb=<a string> default: ""
adb binary to use for the 'mobile-install' command. If unspecified, the one in the Android SDK specified by the --android_sdk command line option (or the default SDK if --android_sdk is not specified) is used.
--adb_arg=<a string> multiple uses are accumulated
Extra arguments to pass to adb. Usually used to designate a device to install to.
--adb_jobs=<an integer> default: "2"
The number of instances of adb to use in parallel to update files on the device
--[no]incremental default: "false"
Whether to do an incremental install. If true, try to avoid unnecessary additional work by reading the state of the device the code is to be installed on and using that information to avoid unnecessary work. If false (the default), always do a full install.
--incremental_install_verbosity=<a string> default: ""
The verbosity for incremental install. Set to 1 for debug logging.
--[no]split_apks default: "false"
Whether to use split apks to install and update the application on the device. Works only with devices with Marshmallow or later
--start=<no, cold, warm or debug> default: "NO"
How the app should be started after installing it. Set to WARM to preserve and restore application state on incremental installs.
--start_app
Whether to start the app after installing it.
Expands to:
  --start=COLD
Options category 'mobile_install':
--debug_app
Whether to wait for the debugger before starting the app.
Expands to:
  --start=DEBUG

Query Options

Options that specify how to locate packages:
--deleted_packages=<comma-separated list of package names> default: ""
A comma-separated list of names of packages which the build system will consider non-existent, even if they are visible somewhere on the package path. Use this option when deleting a subpackage 'x/y' of an existing package 'x'. For example, after deleting x/y/BUILD in your client, the build system may complain if it encounters a label '//x:y/z' if that is still provided by another package_path entry. Specifying --deleted_packages x/y avoids this problem.
--package_path=<colon-separated list of options> default: "%workspace%"
A colon-separated list of where to look for packages. Elements beginning with '%workspace%' are relative to the enclosing workspace. If omitted or empty, the default is the output of 'bazel info default-package-path'.
Options affecting the 'bazel query' dependency query command:
--aspect_deps=<off, conservative or precise> default: "conservative"
How to resolve aspect dependencies when the output format is one of {xml,proto, record}. 'off' means no aspect dependencies are resolved, ' conservative' (the default) means all declared aspect dependencies are added regardless of whether they are viable given the rule class of direct dependencies, 'precise' means that only those aspects are added that are possibly active given the rule class of the direct dependencies. Note that precise mode requires loading other packages to evaluate a single target thus making it slower than the other modes. Also note that even precise mode is not completely precise: the decision whether to compute an aspect is decided in the analysis phase, which is not run during 'bazel query'.
--[no]graph:factored default: "true"
If true, then the graph will be emitted 'factored', i.e. topologically- equivalent nodes will be merged together and their labels concatenated. This option is only applicable to --output=graph.
--graph:node_limit=<an integer> default: "512"
The maximum length of the label string for a graph node in the output. Longer labels will be truncated; -1 means no truncation. This option is only applicable to --output=graph.
--[no]host_deps default: "true"
If enabled, dependencies on 'host configuration' targets will be included in the dependency graph over which the query operates. A 'host configuration' dependency edge, such as the one from any ' proto_library' rule to the Protocol Compiler, usually points to a tool executed during the build (on the host machine) rather than a part of the same 'target' program. Queries whose purpose is to discover the set of things needed during a build will typically enable this option; queries aimed at revealing the structure of a single program will typically disable this option.
--[no]implicit_deps default: "true"
If enabled, implicit dependencies will be included in the dependency graph over which the query operates. An implicit dependency is one that is not explicitly specified in the BUILD file but added by bazel.
--null
Whether each format is terminated with instead of newline.
Expands to:
  --line_terminator_null=true
--[no]line_terminator_null default: "false"
Whether each format is terminated with instead of newline.
--noorder_results
Output the results in dependency-ordered (default) or unordered fashion. The unordered output is faster but only supported when --output is not minrank, maxrank, or graph.
Expands to:
  --order_output=no
--order_output=<no, deps, auto or full> default: "auto"
Output the results unordered (no), dependency-ordered (deps), or fully ordered (full). The default is 'auto', meaning that results are output either dependency-ordered or fully ordered, depending on the output formatter (dependency-ordered for proto, minrank, maxrank, and graph, fully ordered for all others). When output is fully ordered, nodes that would otherwise be unordered by the output formatter are alphabetized before output.
--order_results
Output the results in dependency-ordered (default) or unordered fashion. The unordered output is faster but only supported when --output is not minrank, maxrank, or graph.
Expands to:
  --order_output=auto
--output=<a string> default: "label"
The format in which the query results should be printed. Allowed values are: label, label_kind, minrank, maxrank, package, location, graph, xml, proto, record.
--[no]proto:default_values default: "true"
If true, attributes whose value is not explicitly specified in the BUILD file are included; otherwise they are omitted. This option is applicable to -- output=proto
--query_file=<a string> default: ""
If set, query will read the query from the file named here, rather than on the command line. It is an error to specify a file here as well as a command-line query.
--[no]relative_locations default: "false"
If true, the location of BUILD files in xml and proto outputs will be relative. By default, the location output is an absolute path and will not be consistent across machines. You can set this option to true to have a consistent result across machines.
--[no]strict_test_suite default: "false"
If true, the tests() expression gives an error if it encounters a test_suite containing non-test targets.
--universe_scope=<comma-separated list of options> default: ""
A comma-separated set of target patterns (additive and subtractive). The query may be performed in the universe defined by the transitive closure of the specified targets.
--[no]xml:line_numbers default: "true"
If true, XML output contains line numbers. Disabling this option may make diffs easier to read. This option is only applicable to --output=xml.
--[no]xml:default_values default: "false"
If true, rule attributes whose value is not explicitly specified in the BUILD file are printed; otherwise they are omitted.
Strategy options, which affect how bazel will execute the build:
--[no]keep_going [-k] default: "false"
Continue as much as possible after an error. While the target that failed, and those that depend on it, cannot be analyzed, other prerequisites of these targets can be.
Verbosity options, which control what bazel prints:
--[no]show_loading_progress default: "true"
If enabled, causes Bazel to print "Loading package:" messages.
--[no]show_package_location default: "false"
If enabled, causes Bazel to print the location on the --package_path from which each package was loaded.

Run Options

Inherits all options from build.

Options specific to 'bazel run':
--script_path=<a path> default: see description
If set, write a shell script to the given file which invokes the target. If this option is set, the target is not run from bazel. Use 'bazel run --script_path=foo //foo && ./foo' to invoke target ' //foo' This differs from 'bazel run //foo' in that the % {product} lock is released and the executable is connected to the terminal' s stdin.

Shutdown Options

Miscellaneous options:
--iff_heap_size_greater_than=<an integer> default: "0"
Iff non-zero, then shutdown will only shut down the server if the total memory (in MB) consumed by the JVM exceeds this value.

Test Options

Inherits all options from build.

Verbosity options, which control what bazel prints:
--[no]test_verbose_timeout_warnings default: "false"
If true, print additional warnings when the actual test execution time does not match the timeout defined by the test (whether implied or explicit).
--[no]verbose_test_summary default: "true"
If true, print additional information (timing, number of failed runs, etc) in the test summary.

Version Options