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

How to avoid deleting cached files after build in Bazel

I have a genrule in Bazel that is supposed to manipulate some files. I think I'm not accessing these files by the correct path, so I want to look at the directory structure that Bazel is creating so I can debug. I added some echo statements to my…
Kerrick Staley
  • 1,583
  • 2
  • 20
  • 28
8
votes
3 answers

Build unit test for C with mocked dependencies using bazel

I have a C codebase I'm trying to build with Bazel. This codebase is covered with unit tests that use the fff library for generating function mocks in C. The actual library is not important though, I have a problem with the whole concept of function…
monnoroch
  • 390
  • 1
  • 10
8
votes
0 answers

Building Tensorflow with Bazel: Executing genrule //tensorflow:tensorflow_python_api_gen failed (Exit 1): bash failed: error executing command

I try to build TensorFlow source on Raspberry Pi 3, but got some build error. Did I miss to install any python module? The below is the ERROR log: ERROR: /home/pi/tf/tensorflow/tensorflow/tensorflow/BUILD:581:1: Executing genrule…
Patrick Liao
  • 103
  • 1
  • 7
8
votes
3 answers

How to get WORKSPACE directory in bazel rule

I order to use clang tools like clang-format, clang-tidy or generate a compilation database like this, I need to know the WORKSPACE directory within the .bzl file. How can I obtain it? Consider the following example where I just want to print the…
Mike van Dyke
  • 2,724
  • 3
  • 16
  • 31
8
votes
2 answers

How to build static library from the Generated source files using Bazel Build

I am trying to make a following setup run with Bazel. With calling “bazel build” a Python script should generate unknown number of *.cc files with random names, and then compile these into single static library (.a file), all within one Bazel call.…
Manan Maqbool
  • 123
  • 2
  • 11
8
votes
2 answers

Bazel, I want to avoid all the "convenience symlinks" to be generated

When you build a Bazel project, your WORKSPACE project root directory is populated by a bunch of convenience symlinks: / <== The workspace directory bazel-my-project => <...my-project> <== Symlink to…
Picaud Vincent
  • 10,518
  • 5
  • 31
  • 70
8
votes
3 answers

C++ Bazel project with a Data repository

I have a (basic) C++ project: ├── bin │   ├── BUILD │   ├── example.cpp ├── data │   └── someData.txt └── WORKSPACE where the executable example.cpp use some data files from data/ directory: #include #include int main() { …
Picaud Vincent
  • 10,518
  • 5
  • 31
  • 70
8
votes
1 answer

good practices to modify tensorflow sources

I'm trying to modify Tensorflow source code (core). After study the code I started to modify, recompile and run my own tests. But I'm not sure if I'm doing it in the best way possible. So I have some questions about it. 1 - Do I need to recompile…
Mauric
  • 81
  • 6
8
votes
1 answer

Bazel & automatically generated cpp / hpp files

I am starting to use Bazel as my C++ project build system. However I am stuck with the following problem: I am in a scenario where I automatically generate the file.hpp file.cpp (literate programming). To reproduce my problem one can simply use this…
Picaud Vincent
  • 10,518
  • 5
  • 31
  • 70
8
votes
2 answers

How to use Bazel's py_library imports argument

I'm trying to use Boto3 in a Bazel built project but can't seem to get the correct import for the library. Because of the Boto git repository, all the sources are in folders named botocore and boto3 in the root of the repository. The imports are all…
quittle
  • 856
  • 2
  • 10
  • 19
8
votes
2 answers

Verify step in bazel

I'm looking for a good recipe to run "checks" or "verify" steps in Bazel, like go vet, gofmt, pylint, cppcheck. These steps don't create any output file. The only thing that matters is the return code (like a test). Right now I'm using the following…
Antoine Pelisse
  • 12,871
  • 4
  • 34
  • 34
8
votes
3 answers

How to add external header files during bazel/tensorflow build

I am trying to add external header file (like OpenCL header file) for some experimentation for tensorflow. I tried to add this into BUILD file under tensorflow/core/BUILD file: # This includes implementations of all kernels built into…
7
votes
1 answer

Is it possible to use C++20 modules in bazel with custom rules?

Bazel does not have direct support for modules (See Issue #4005). However, it is possible to provide bazel with a custom CROSSTOOL. From https://docs.bazel.build/versions/0.22.0/crosstool-reference.html: By default, Bazel automatically configures…
Ryan Burn
  • 2,126
  • 1
  • 14
  • 35
7
votes
0 answers

Using C++ to load SavedModel - SavedModel load for tags { serve }; Status: fail: Not found

I have a SavedModel in a folder (generator_model_final) with the following content: - saved_model.pb - variables |- variables.data-00000-of-00002 |- variables.data-00001-of-00002 |- variables.index In the root of the directory, I have my .cc…
edualvarado
  • 353
  • 2
  • 12
7
votes
1 answer

How do I enable C++ intellisense for a Bazel project in VS code?

I would like to enable intellisense for my C++ project that is being built with bazel in VS code. There used to be a an extension that could do it, but it has been discontinued since the release of the official vscode-bazel extension which lacks…
Lawson Fulton
  • 309
  • 3
  • 9