Bazel 0.23.0 has arrived with an exciting mix of new features, important bug fixes, and updated documentation.
This version of Bazel has been regression-tested against 51 open-source projects, including Gerrit, Protocol Buffers, TensorFlow and the full suite of rules hosted in bazelbuild's GitHub organization. This makes it our most comprehensively tested release yet. Want to get your open-source project on Bazel's CI to ensure that we catch any regressions or have suggestions what we should test against? File a GitHub issue.
Incompatible changes
Before updating to Bazel 0.23, first check if your codebase is compatible either
by running bazelisk --migrate
or by
building your code with Bazel 0.22 and the following flags:
-
--incompatible_require_feature_configuration_for_pic
-
--incompatible_linkopts_in_user_link_flags
-
--incompatible_dont_emit_static_libgcc
-
--incompatible_expand_directories
-
--incompatible_strict_argument_ordering
-
--incompatible_disallow_data_transition
-
--incompatible_use_jdk10_as_host_javabase
-
--incompatible_disable_tools_defaults_package
-
--incompatible_generate_javacommon_source_jar
For more information about the changes, please click on the links and read the GitHub issues. Comment there if you need help.
If you use external repositories, you might first have to update the dependencies in your WORKSPACE file.
Starlark
- The
--incompatible_disallow_struct_provider_syntax
flag has been added. This flag removes the ability for rule implementation functions to return a struct. Such functions should return a list of providers instead. See the documentation about Migrating from Legacy Providers. - Some old flags have been removed:
--incompatible_range_type
,--incompatible_disallow_slash_operator
,--incompatible_disallow_conflicting_providers
.
Android
- For
android_local_test
, you can now use theaapt_version
attribute or the--android_aapt
flag to pick the aapt version.
Apple / iOS
- The
objc_framework
rule has been removed. Please refer toapple_dynamic_framework_import
andapple_static_framework_import
rules available inrules_apple
. - The
objc_bundle_library
rule has been removed. Please migrate torules_apple
'sapple_resource_bundle
. - Added
--host_swiftcopt
for custom flags to pass to swiftc when building tools written in Swift in the host configuration. - Changed the default
apple_platform_type
value from iOS to macOS. You no longer need to pass--apple_platform_type=macos
when building targets on macOS that previously required it.
C++
- Introduced the
--host_compiler
flag to allow setting a compiler for host compilation when--host_crosstool_top
is specified. - Toolchain resolution for cc rules has been enabled via the incompatible flag
--incompatible_enable_cc_toolchain_resolution
. The legacy flag, --enabledtoolchaintypes, has been deprecated and will be removed. -
cc_common.create_cc_toolchain_config_info
is now stable and available for production use. See updatedcc_toolchain tutorial
and the reference
Java
- Bazel now verifies that
JAVA_HOME
points to a valid JDK. Otherwise, it falls back to auto-detection by looking up the path of javac. - The
--incompatible_use_jdk11_as_host_javabase
flag has been added. This flag forces Bazel to use JDK 11 as its default--host_javabase
. - The
--incompatible_generate_javacommon_source_jar
flag has been added. This flag forcesjava_common.compile
to always generate a source .jar file. - The
--incompatible_use_toolchain_providers_in_java_common
flag has been added. This flag forces Bazel to pass JavaToolchainInfo and JavaRuntimeInfo providers tojava_common
APIs instead of configured targets. - An optional
output_source_jar
parameter has been added tojava_common.compile
.
Python
- Python rules now accept and return a PyInfo provider in addition to the legacy "py" struct provider, which is being deprecated. You can preview the deprecation by enabling --incompatibledisallowlegacypyprovider
- The
default_python_version
attribute and--force_python
flags are being renamed. Usepython_version
and--python_version
respectively instead. You can preview the removal of the deprecated names with--incompatible_remove_old_python_version_api
. - The
--python_version
flag will soon no longer override the declared version of apy_binary
orpy_test
target. This allows Python 3 binaries to have data dependencies on Python 2 binaries and vice versa. You can preview this new behavior with--incompatible_allow_python_version_transitions
.
aquery
- Documentation for the
aquery
command is now available. - Chaining of the same
function type (inputs, outputs, mnemonic) in
aquery
is now allowed. - The content of parameter files can now be displayed in
aquery
output using the--include_param_files
flag. -
aquery
text output now highlights if an artifact is a TreeArtifact.
Caching & Execution
- Locally-executed spawns tagged
no-cache
no longer upload their outputs to the remote cache. - Bazel now supports reading cache hits from a repository cache, even if it doesn't have write access to the cache.
- Fixed a longstanding bug in the HTTP remote cache where the value passed to
--remote_timeout
would be interpreted as milliseconds instead of seconds. - The incompatible flag
--incompatible_strict_action_env
has been flipped to "false" again, as we discovered breakages for local execution users. We'll need some more time to figure out the best way to make this work for local and remote execution (#7026). - The flag value
--test_sharding_strategy=experimental_heuristic
has been removed.
Other changes
- Bazel binary is 20MB smaller by using a minimized embedded JDK.
- The embedded JDK version is upgraded to 11.0.2.
- Incompatible flag
--incompatible_auto_configure_host_platform
has been added. When set, the default value of--host_platform
and--platforms
will not be dependent on the configuration. This means that setting--cpu
or--host_cpu
will not affect the target or host platform. - Introduces
--local_ram_resources
and--local_cpu_resources
, which will take the place of--local_resources
. - In
--keep_going
mode, Bazel now correctly returns a non-zero exit code when encountering a package loading error during target pattern parsing of patterns like//foo:all
and//foo/...
. - For tests that do not generate a
test.xml
, Bazel now uses a separate action to generate one; this results in minor differences in the generatedtest.xml
, and makes thetest.xml
generation more reliable overall.
Community
- Square published
bazel_maven_repository
, a Bazel ruleset creating a more idiomatic Bazel representation of a maven repo using a pinned list of artifacts. - Travis Cline created
rules_homebrew
, to manage brew packages. - Wix engineer Natan Silnitsky wrote about their experience: Migrating to Bazel from Maven or Gradle? 5 crucial questions you should ask yourself.
- Rahul Malik, iOS Platform Tech Lead, wrote about developing fast & reliable iOS builds at Pinterest (Part one).
- Christian Gruber wrote a blog post: Bazely thinking and the tale of the content-addressable cache.
- Rosen Vladimirov published an article about Building NativeScript Apps with Google's Bazel.
- Bazelisk, a wrapper for Bazel, has
been improved. It can be used to try your code with a specific version of
Bazel, or to ensure your code is forward compatible (see the
--migrate
flag).
Contributors
This release contains contributions from many people at Google, as well as Benjamin Peterson, Ed Schouten, erenon, George Gensure, Igal Tabachnik, Ittai Zeidman, Jannis Andrija Schnitzer, John Millikin, Keith Smiley, Kelly Campbell, Max Vorobev, nicolov, and Robin Nabel.