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
12
votes
2 answers

Building a simple library with bazel, fixing include path

I have a very simple directory structure: . ├── libs │   └── foo │   ├── BUILD │   ├── include │   │   └── foo │   │   └── func.h │   └── src │   └── func.cxx └── WORKSPACE With func.h: #pragma once int square(int…
Barry
  • 286,269
  • 29
  • 621
  • 977
12
votes
1 answer

How to understand Bazel's output time?

Everytime after a build is done, I see something like: Elapsed time: 1034.748s, Critical Path: 257.54s Wondering what's the difference between Elapsed Time and Critical Path? What can be causing the time difference? Forwarded from:…
Yun Peng
  • 353
  • 1
  • 7
12
votes
2 answers

How can I link a system library statically in Bazel?

How can I link a system library statically in mostly static mode (linkstatic=1)? I tried to use "-Wl,-Bstatic -lboost_thread -Wl,-Bdynamic" or "-Wl,-Bstatic", "-lboost_thread", "-Wl,-Bdynamic", but none of them worked. I don't want to hard code the…
user3701366
  • 474
  • 1
  • 5
  • 7
11
votes
0 answers

Bazel equivalent of include what you use?

Is there a Bazel equivalent of include what you use? I'm looking for a tool that will eliminate false dependencies in a Bazel build by removing dependencies from BUILD files and checking if the project still builds. Is there any reason this approach…
razeh
  • 2,725
  • 1
  • 20
  • 27
11
votes
2 answers

Bazel run vs test

What's the difference between bazel test vs bazel run on the the java test rule? When I run the bazel run command, my test passes just fine, while with bazel test I get an error. If needed, I can provide more details, but I was interested in general…
nme
  • 647
  • 1
  • 7
  • 22
11
votes
4 answers

How do we run a single test using Google bazel

For running all the tests under a target I use the command line command bazel test //src/code_path:target_name What should be additional parameters to run a test single_test from the above target?
raju
  • 4,788
  • 15
  • 64
  • 119
11
votes
2 answers

How to force-rebuild a package in Bazel to measure build time

I am currently trying to measure the time bazel build //api/... takes to build our "api" project with different --spawn_strategys. I am having a hard time doing so because Bazel doesn't rebuild anything as long as I don't touch the source files. I…
Vogelsgesang
  • 684
  • 1
  • 4
  • 15
11
votes
1 answer

How does bazel choose the python version?

I'm running a python binary target with bazel run xxx and in the target I'm doing print(sys.version). This outputs Python version 3.6.8 (default, Jan 14 2019, 11:02:34) When I type the python command directly, I get Python 3.7.3 (default, Apr 3…
Mark
  • 5,286
  • 5
  • 42
  • 73
11
votes
2 answers

How can you run the executables of other rules within a Bazel rule?

Say I have a custom rule, my_object. It looks like: my_object( name = "foo", deps = [ //services/image-A:push, //services/image-B:push, ] ) Where the labels in deps are rules_docker's container_push rules. I want to be able to bazel…
thundergolfer
  • 527
  • 1
  • 5
  • 18
11
votes
2 answers

Gradle vs Bazel performance of builds

So everyone is talking about bazel now, but migration to it isn't automated (gradle is better in this regard when migrating from maven). So I don't want to invest time into manually converting any repository to it. But I can't find any information…
user1685095
  • 5,787
  • 9
  • 51
  • 100
11
votes
2 answers

Bazel run - passing main arguments

I created an image using java_image but I would like to pass arguments to my main function (i.e. String args[]). How can I do that when I use "bazel run name_of_image" command?
Adib Rastegarnia
  • 494
  • 1
  • 7
  • 21
11
votes
3 answers

How do I make a bazel `sh_binary` target depend on other binary targets?

I have set up bazel to build a number of CLI tools that perform various database maintenance tasks. Each one is a py_binary or cc_binary target that is called from the command line with the path to some data file: it processes that file and stores…
psigen
  • 163
  • 1
  • 2
  • 9
11
votes
2 answers

What's the difference between -c opt and --config=opt when building TensorFlow from source?

When building TensorFlow from source, we're asked to set --config=opt (which by default will enable the gcc flag -march=native) but across the web I see a lot of people using -c opt instead, but according to Bazel's documentation -c is actually…
Carl Thomé
  • 2,703
  • 3
  • 19
  • 41
11
votes
1 answer

why is bazel faster than gradle

originally, I use gradle to build my android project, but recently, I migrate it to bazel, and I find that bazel is truly fast than gradle, so I want to know why, but the doc of bazel doesn't give much idea about this, can anyone help me? Thanks…
ldjhust
  • 401
  • 3
  • 13
10
votes
0 answers

output '_coverage/_coverage_report.dat' was not created when using bazel coverage to generate lcov coverage file

I am using bazel to manage our golang project and I found an option online that I can generate coverage html file by generating a lcov coverage.dat file first and then use genhtml to generate the html. However, I cannot get the first step…
Peiti Li
  • 4,634
  • 9
  • 40
  • 57