Questions tagged [bazel]

Bazel is a build tool that builds code quickly and reliably. It is used to build the majority of Google's software, and thus it has been designed to handle build problems present in Google's development.

From the Documentation: Overview:

What is Bazel?

Bazel is an open-source build and test tool similar to Make, Maven, and Gradle. It uses a human-readable, high-level build language. Bazel supports projects in multiple languages and builds outputs for multiple platforms. Bazel supports large codebases across multiple repositories, and large numbers of users.

Why should I use Bazel?

Bazel offers the following advantages:

  • High-level build language. Bazel uses an abstract, human-readable language to describe the build properties of your project at a high semantical level. Unlike other tools, Bazel operates on the concepts of libraries, binaries, scripts, and data sets, shielding you from the complexity of writing individual calls to tools such as compilers and linkers.

  • Bazel is fast and reliable. Bazel caches all previously done work and tracks changes to both file content and build commands. This way, Bazel knows when something needs to be rebuilt, and rebuilds only that. To further speed up your builds, you can set up your project to build in a highly parallel and incremental fashion.

  • Bazel is multi-platform. Bazel runs on Linux, macOS, and Windows. Bazel can build binaries and deployable packages for multiple platforms, including desktop, server, and mobile, from the same project.

  • Bazel scales. Bazel maintains agility while handling builds with 100k+ source files. It works with multiple repositories and user bases in the tens of thousands.

  • Bazel is extensible. Many languages are supported, and you can extend Bazel to support any other language or framework.


Resource


Presentation


Community


Related Plugins

3196 questions
9
votes
2 answers

How to pass custom flags to `bazel test` command

I have used gflags in my test to define custom flags. How can I pass such a flag to my test while running the test via bazel test command? For example: I can run a test multiple times using: bazel test //xyz:my_test --runs_per_test 10 In the same…
Curious
  • 2,783
  • 3
  • 29
  • 45
9
votes
0 answers

Poor performance in bazel fetch

I have a reasonably sized Bazel project and I've noticed that bazel fetch //... takes about 5 minutes in CI (~100 archives for a total of ~3 GB). I first assumed that it was due to downloading all of the external packages but I ruled that out by…
marczych
  • 967
  • 7
  • 15
9
votes
3 answers

How to set c++ compiler on OS X with bazel?

How can you tell bazel to use a different C++ compiler on OS X? bazel build --action_env CC=/path/to/compiler //:target works on linux. But -s shows that bazel always runs with external/local_config_cc/wrapped_clang (clang) on OSX regardless of…
Ryan Burn
  • 2,126
  • 1
  • 14
  • 35
9
votes
3 answers

Using Bazel to generate coverage report

I am using genhtml command to generate html coverage report from Bazel generated coverage.dat file: genhtml bazel-testlogs/path/to/TestTarget/coverage.dat --output-directory coverage The problem with using genhtml is that I have to provide the…
Zeitgeist
  • 1,382
  • 2
  • 16
  • 26
9
votes
2 answers

Use generated code in a bazel build

$ python gencpp.py This command generates a cpp file foo.cpp in the working directory. I'd like to run this command in bazel before building to be able to include foo.cpp in cc_binary's srcs attribute. What I've tried: genrule( name = 'foo', …
Ghilas BELHADJ
  • 13,412
  • 10
  • 59
  • 99
9
votes
2 answers

Tensorflow installation error - (directory not empty)

I'm trying to install tensorflow 0.11.0 by running ./configure I'm getting an error saying : ERROR: /home/abc/.cache/bazel/_bazel_abc/235fe154e0/server (Directory not empty). I'm not sure if they are related, but before the error message, I also…
kerouac
  • 360
  • 5
  • 14
9
votes
4 answers

bazel rules for the protobuf C++ compiler

I'm using Bazel and Google's protocol buffers. I want to add a Bazel rule so I can generate the C++ API from the .proto files. In GNU make, I would do (simplified example): %.h: %.cc %.cc: %.proto protoc --cpp_out=. $< How can I accomplish the…
morxa
  • 3,221
  • 3
  • 27
  • 43
9
votes
1 answer

Bazel header file code generator

I am trying to add a code generator to my bazel build by writing a rule to execute the generator, but i am stuck at adding the generated header file as an include path dependency to the library i am trying to build. The rule looks like this: def…
Jan
  • 1,359
  • 1
  • 13
  • 18
8
votes
0 answers

Finding java imports inVSCode with Bazel

Not sure if this is a Bazel question or VScode question but probably a bit of both. I'm new to VSCode and am trying to setup a project using Bazel as my build system if that matters. I'm trying to find a way to get the imports for classes used in…
Chris Tei
  • 296
  • 2
  • 4
  • 12
8
votes
1 answer

Some questions about bazel concept

I am learning Bazel and confused by many basic concepts. load("//bazel/rules:build_tools.bzl", "build_tools_deps") build_tools_deps() //build_tools_deps is macro or rules? load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") …
dingrui
  • 417
  • 2
  • 5
  • 15
8
votes
1 answer

Get dependency tree for a bazel target

I am trying to migrate my maven Integration Tests to bazel. There in runtime I am facing some issues. To debug that I want to compare maven dependency:tree to bazel's dependency tree. So as to avoid any extra dependencies OR to detect if I am…
rishi007bansod
  • 1,283
  • 2
  • 19
  • 45
8
votes
1 answer

Electron webpack issue with selenium-webdriver [bazel-genfiles]

For my electron app project (used boilerplate), I want to execute a few selenium node commands using selenium-webdriver and chromedriver. The problem is, when I added the module selenium-webdriver, suddenly my app is throwing error and warning in…
abhishake
  • 763
  • 9
  • 16
8
votes
2 answers

How to know all Bazel targets affected by a git commit?

A git commit may change some workspace rules, some source files, .bazelrc, etc. How to get all Bazel targets affected, thus need to rebuild and test, after such change? In Buck, we can run buck targets --show-rulekey //... to see all rule key…
Zebra Propulsion Lab
  • 1,736
  • 1
  • 17
  • 28
8
votes
2 answers

How can I setup vscode for Go project built with bazel?

I am trying to browse code for gVisor with VScode. However, unlike other Go projects, gVisor is built with bazel, and the source code is not located under $GOROOT or $GOPATH. Maybe this prevents gVisor packages from being searched by VSCode go…
shpark
  • 369
  • 2
  • 7
8
votes
3 answers

How to create a directory structure in bazel

I want to create the following structure in bazel. dir1 |_ file1 |_ file2 |_ dir2 |_file3 Creating a specific structure doesn't seem trivial. I'm hoping there's a simple and reusable rule. Something like: makedir( name =…
GGhe
  • 663
  • 5
  • 17