Bazel Blog

Bazel 0.14

We've just released Bazel 0.14!

BUILD and bzl files

  • Labels starting with more than two slashes are disallowed (e.g. ///foo).
  • The / operator is deprecated in favor of // (floor integer division). Try the --incompatible_disallow_slash_operator flag to ensure your code is forward-compatible.
  • Args objects (ctx.actions.args()) have new methods add_all() and add_joined() for building command lines using depsets. The add() method has a new overload: args.add("--foo", val).
  • Added flag --incompatible_disallow_old_style_args_add to help migrate from args.add() to args.add_all() or args.add_joined() where appropriate.
  • FileType is deprecated and will be removed soon. Try the --incompatible_disallow_filetype flag to ensure your code is forward-compatible.
  • Removed flag --incompatible_disallow_toplevel_if_statement.
  • Introduce tools parameter to ctx.actions.run and ctx.actions.run_shell. Tools are label-type attributes marked executable=True, whose runfiles are available to the action. Currently tools are passed in using the inputs parameter, but in the future it will be required to pass them through tools instead.

sh rules

  • You can now access runfiles (data-dependencies) from shell scripts in sh_* rules in a platform-independent way. See top of //tools/bash/runfiles/runfiles.bash for usage information.

C++

  • optional_compiler_flag field was removed from CROSSTOOL. Use features instead.
  • Fixed start/end lib expansion for linking used with ld.gold and lld. There were many cases where archive files were still being used with toolchains that support start/end lib.
  • Introduce fdo_profile rule that allows architecture-sensitive specification of fdo profiles. This rule has the same function as --fdo_optimize and will replace it in the future.

Java

Other changes

  • Command canonicalize-flags no longer reorders the flags.
  • Remove vestigial deps and data attributes from proto_lang_toolchain
  • bazel run now lets one run interactive binaries. The BUILD_WORKSPACE_DIRECTORY and BUILD_WORKING_DIRECTORY environment variables indicate the working directory and the workspace root of the Bazel invocation. Tests are provided with an approximation of the official test environment.
  • Repository rules are no longer restricted to return None. This is the first step in the transition towards generating WORKSPACE.resolved files, where source-like repository rules are expected to return the information needed to be a reproducible versions of themselves (for more details see the design document). At the moment, the return value is simply ignored (and debug-printed), but lifting the restriction allows rules to transition already.
  • Bazel now supports running actions inside Docker containers. To use this feature, run bazel build --spawn_strategy=docker --experimental_docker_image=myimage:latest.
  • Remote execution works for Windows binaries with launchers.
  • We replaced the --experimental_local_disk_cache and --experimental_local_disk_cache_path flags into a single --disk_cache flag. Additionally, Bazel now tries to create the disk cache directory if it doesn't exist.
  • Allow --workermaxinstances to take MnemonicName=value to specify max for each worker.

Community

  • We shared plans around a Rules Curation process. The goal is to promote a set of high quality rules, reduce breakages and improve stability of these rules.
  • Yugui wrote a prototype version of rules_ruby.
  • There is a new Google codelab on Building Android Apps with Bazel.
  • cabal2bazel, a tool for fetching Haskell Cabal packages from Hackage into Bazel, was recently open sourced.
  • Luc Perkins has created Colossus, a project on GitHub showing how Bazel can be used in a multi-lingual, microservice-driven setting. It uses Kubernetes, Go, Java, Docker, and gRPC.
  • Ed Schouten started new rules for Latex.