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_syntaxflag 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_versionattribute or the--android_aaptflag to pick the aapt version.
Apple / iOS
- The
objc_frameworkrule has been removed. Please refer toapple_dynamic_framework_importandapple_static_framework_importrules available inrules_apple. - The
objc_bundle_libraryrule has been removed. Please migrate torules_apple'sapple_resource_bundle. - Added
--host_swiftcoptfor custom flags to pass to swiftc when building tools written in Swift in the host configuration. - Changed the default
apple_platform_typevalue from iOS to macOS. You no longer need to pass--apple_platform_type=macoswhen building targets on macOS that previously required it.
C++
- Introduced the
--host_compilerflag to allow setting a compiler for host compilation when--host_crosstool_topis 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_infois now stable and available for production use. See updatedcc_toolchain tutorialand the reference
Java
- Bazel now verifies that
JAVA_HOMEpoints to a valid JDK. Otherwise, it falls back to auto-detection by looking up the path of javac. - The
--incompatible_use_jdk11_as_host_javabaseflag has been added. This flag forces Bazel to use JDK 11 as its default--host_javabase. - The
--incompatible_generate_javacommon_source_jarflag has been added. This flag forcesjava_common.compileto always generate a source .jar file. - The
--incompatible_use_toolchain_providers_in_java_commonflag has been added. This flag forces Bazel to pass JavaToolchainInfo and JavaRuntimeInfo providers tojava_commonAPIs instead of configured targets. - An optional
output_source_jarparameter 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_versionattribute and--force_pythonflags are being renamed. Usepython_versionand--python_versionrespectively instead. You can preview the removal of the deprecated names with--incompatible_remove_old_python_version_api. - The
--python_versionflag will soon no longer override the declared version of apy_binaryorpy_testtarget. 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
aquerycommand is now available. - Chaining of the same
function type (inputs, outputs, mnemonic) in
aqueryis now allowed. - The content of parameter files can now be displayed in
aqueryoutput using the--include_param_filesflag. -
aquerytext output now highlights if an artifact is a TreeArtifact.
Caching & Execution
- Locally-executed spawns tagged
no-cacheno 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_timeoutwould be interpreted as milliseconds instead of seconds. - The incompatible flag
--incompatible_strict_action_envhas 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_heuristichas 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_platformhas been added. When set, the default value of--host_platformand--platformswill not be dependent on the configuration. This means that setting--cpuor--host_cpuwill not affect the target or host platform. - Introduces
--local_ram_resourcesand--local_cpu_resources, which will take the place of--local_resources. - In
--keep_goingmode, Bazel now correctly returns a non-zero exit code when encountering a package loading error during target pattern parsing of patterns like//foo:alland//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.xmlgeneration 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
--migrateflag).
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.