CLI Reference for Bazel v5.4.1
Return to release homeCommands
analyze-profile
Analyzes build profile data.
bazel analyze-profile <path>
- Option inheritance
- None
- Hidden
- False
- Must run in workspace
- False
- Triggers build
- False
aquery
Analyzes the given targets and queries the action graph.
bazel aquery <label>
- Option inheritance
configuration
build
- Hidden
- False
- Must run in workspace
- True
- Triggers build
- True
build
Builds the specified targets.
bazel build <label>
- Option inheritance
configuration
- Hidden
- False
- Must run in workspace
- True
- Triggers build
- True
canonicalize-flags
Canonicalizes a list of bazel options.
bazel canonicalize-flags
- Option inheritance
build
- Hidden
- False
- Must run in workspace
- False
- Triggers build
- False
clean
Removes output files and optionally stops the server.
bazel clean
- Option inheritance
build
- Hidden
- False
- Must run in workspace
- True
- Triggers build
- True
config
Displays details of configurations.
bazel config <string>
- Option inheritance
configuration
build
- Hidden
- True
- Must run in workspace
- True
- Triggers build
- True
coverage
Generates code coverage report for specified test targets.
bazel coverage <label-test>
- Option inheritance
test
- Hidden
- False
- Must run in workspace
- True
- Triggers build
- True
cquery
Loads, analyzes, and queries the specified targets w/ configurations.
bazel cquery <label>
- Option inheritance
configuration
test
- Hidden
- False
- Must run in workspace
- True
- Triggers build
- True
dump
Dumps the internal state of the bazel server process.
bazel dump
- Option inheritance
- None
- Hidden
- False
- Must run in workspace
- False
- Triggers build
- False
fetch
Fetches external repositories that are prerequisites to the targets.
bazel fetch <label>
- Option inheritance
- None
- Hidden
- False
- Must run in workspace
- True
- Triggers build
- False
help
Prints help for commands, or the index.
bazel help <command|{startup_options,target-syntax,info-keys}>
- Option inheritance
- None
- Hidden
- False
- Must run in workspace
- False
- Triggers build
- False
info
Displays runtime info about the bazel server.
bazel info <info-key>
- Option inheritance
build
- Hidden
- False
- Must run in workspace
- True
- Triggers build
- True
license
Prints the license of this software.
bazel license
- Option inheritance
- None
- Hidden
- False
- Must run in workspace
- False
- Triggers build
- False
mobile-install
Installs targets to mobile devices.
bazel mobile-install <label>
- Option inheritance
build
- Hidden
- False
- Must run in workspace
- True
- Triggers build
- True
print_action
Prints the command line args for compiling a file.
bazel print_action <label>
- Option inheritance
build
- Hidden
- False
- Must run in workspace
- True
- Triggers build
- True
query
Executes a dependency graph query.
bazel query <label>
- Option inheritance
- None
- Hidden
- False
- Must run in workspace
- True
- Triggers build
- False
run
Runs the specified target.
bazel run <label-bin>
- Option inheritance
build
- Hidden
- False
- Must run in workspace
- True
- Triggers build
- True
shutdown
Stops the bazel server.
bazel shutdown
- Option inheritance
- None
- Hidden
- False
- Must run in workspace
- False
- Triggers build
- False
sync
Syncs all repositories specified in the workspace file
bazel sync
- Option inheritance
- None
- Hidden
- False
- Must run in workspace
- True
- Triggers build
- False
test
Builds and runs the specified test targets.
bazel test <label-test>
- Option inheritance
build
- Hidden
- False
- Must run in workspace
- True
- Triggers build
- True
version
Prints version information for bazel.
bazel version
- Option inheritance
- None
- Hidden
- False
- Must run in workspace
- False
- Triggers build
- False
Options
--action_cache
🔗
Use with: dump
Dump action cache content.
--[no]action_cache
- Allows multiple
- False
- Documentation category
output_selection
- Option effect tags
bazel_monitoring
--action_env
🔗
Use with: configuration
Specifies the set of environment variables available to actions with target configuration. 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.
--action_env
- Allows multiple
- True
- Documentation category
output_parameters
- Option effect tags
action_command_lines
--adb
🔗
Use with: mobile-install
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
- Allows multiple
- False
- Documentation category
toolchain
- Option effect tags
changes_inputs
--adb_arg
🔗
Use with: mobile-install
Extra arguments to pass to adb. Usually used to designate a device to install to.
--adb_arg
- Allows multiple
- True
- Documentation category
output_parameters
- Option effect tags
action_command_lines
--all_incompatible_changes
🔗
Use with: common
No-op, being removed. See https://github.com/bazelbuild/bazel/issues/13892
--all_incompatible_changes
- Allows multiple
- False
- Documentation category
uncategorized
- Option effect tags
no_op
- Option metadata tags
incompatible_change
--allow_analysis_failures
🔗
Use with: configuration
If true, an analysis failure of a rule target results in the target's propagation of an instance of AnalysisFailureInfo containing the error description, instead of resulting in a build failure.
--[no]allow_analysis_failures
- Allows multiple
- False
- Documentation category
testing
- Option effect tags
loading_and_analysis
- Option metadata tags
experimental
--allowed_local_actions_regex
🔗
Use with: build
A regex whitelist for action types which may be run locally. If unset, all actions are allowed to execute locally
--allowed_local_actions_regex
- Allows multiple
- False
- Documentation category
undocumented
- Option effect tags
unknown
--always_profile_slow_operations
🔗
Use with: common
Whether profiling slow operations is always turned on
--[no]always_profile_slow_operations
- Allows multiple
- False
- Documentation category
undocumented
- Option effect tags
affects_outputs
bazel_internal_configuration
--analysis_testing_deps_limit
🔗
Use with: configuration
Sets the maximum number of transitive dependencies through a rule attribute with a for_analysis_testing configuration transition. Exceeding this limit will result in a rule error.
--analysis_testing_deps_limit
- Allows multiple
- False
- Documentation category
testing
- Option effect tags
loading_and_analysis
--analysis_warnings_as_errors
🔗
Use with: build
Treat visible analysis warnings as errors.
--[no]analysis_warnings_as_errors
- Allows multiple
- False
- Deprecation warning
- analysis_warnings_as_errors is now a no-op and will be removed in an upcoming Blaze release
- Documentation category
undocumented
- Option effect tags
no_op
--analyze
🔗
Use with: build
Execute the loading/analysis phase; this is the usual behaviour. Specifying --noanalyzecauses the build to stop before starting the loading/analysis phase, just doing target pattern parsing and returning zero iff that completed successfully; this mode is useful for testing.
--[no]analyze
- Allows multiple
- False
- Documentation category
undocumented
- Option effect tags
loading_and_analysis
affects_outputs
--android_compiler
🔗
Use with: configuration
The Android target compiler.
--android_compiler
- Allows multiple
- False
- Documentation category
toolchain
- Option effect tags
affects_outputs
loading_and_analysis
loses_incremental_state
--android_cpu
🔗
Use with: configuration
The Android target CPU.
--android_cpu
- Allows multiple
- False
- Documentation category
output_parameters
- Option effect tags
affects_outputs
loading_and_analysis
loses_incremental_state
--android_crosstool_top
🔗
Use with: configuration
The location of the C++ compiler used for Android builds.
--android_crosstool_top
- Allows multiple
- False
- Documentation category
toolchain
- Option effect tags
affects_outputs
changes_inputs
loading_and_analysis
loses_incremental_state
--android_databinding_use_androidx
🔗
Use with: configuration
Generate AndroidX-compatible data-binding files. This is only used with databinding v2.
--[no]android_databinding_use_androidx
- Allows multiple
- False
- Documentation category
output_parameters
- Option effect tags
affects_outputs
loading_and_analysis
loses_incremental_state
- Option metadata tags
experimental
--android_databinding_use_v3_4_args
🔗
Use with: configuration
Use android databinding v2 with 3.4.0 argument
--[no]android_databinding_use_v3_4_args
- Allows multiple
- False
- Documentation category
output_parameters
- Option effect tags
affects_outputs
loading_and_analysis
loses_incremental_state
- Option metadata tags
experimental
--android_dynamic_mode
🔗
Use with: configuration
Determines whether C++ deps of Android rules will be linked dynamically when a cc_binary does not explicitly create a shared library. '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.
--android_dynamic_mode
- Allows multiple
- False
- Documentation category
output_parameters
- Option effect tags
affects_outputs
loading_and_analysis
--android_fixed_resource_neverlinking
🔗
Use with: configuration
If true, resources will properly not get propagated through neverlinked libraries. Otherwise, the old behavior of propagating those resources if no resource-related attributes are specified in the neverlink library will be preserved.
--[no]android_fixed_resource_neverlinking
- Allows multiple
- False
- Documentation category
undocumented
- Option effect tags
loading_and_analysis
--android_grte_top
🔗
Use with: configuration
The Android target grte_top.
--android_grte_top
- Allows multiple
- False
- Documentation category
toolchain
- Option effect tags
changes_inputs
loading_and_analysis
loses_incremental_state
--android_include_proguard_location_references
🔗
Use with: configuration
When using aapt2 to generate proguard configurations, include location references. This will make the build nondeterministic.
--[no]android_include_proguard_location_references
- Allows multiple
- False
- Documentation category
undocumented
- Option effect tags
affects_outputs
--android_manifest_merger
🔗
Use with: configuration
Selects the manifest merger to use for android_binary rules. Flag to help thetransition to the Android manifest merger from the legacy merger.
--android_manifest_merger
- Allows multiple
- False
- Documentation category
toolchain
- Option effect tags
affects_outputs
loading_and_analysis
loses_incremental_state
--android_manifest_merger_order
🔗
Use with: configuration
Sets the order of manifests passed to the manifest merger for Android binaries. ALPHABETICAL means manifests are sorted by path relative to the execroot. ALPHABETICAL_BY_CONFIGURATION means manifests are sorted by paths relative to the configuration directory within the output directory. DEPENDENCY means manifests are ordered with each library's manifest coming before the manifests of its dependencies.
--android_manifest_merger_order
- Allows multiple
- False
- Documentation category
output_parameters
- Option effect tags
action_command_lines
execution
--android_migration_tag_check
🔗
Use with: configuration
If enabled, strict usage of the Starlark migration tag is enabled for android rules. Prefer using --incompatible_disable_native_android_rules.
--[no]android_migration_tag_check
- Allows multiple
- False
- Documentation category
undocumented
- Option effect tags
eagerness_to_exit