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
15
votes
1 answer

How to program with C++ API library on Windows using Bazel?

What I want to do First of all, my goal is using Tensorflow C++ API as a library on Windows, which is part of my project, instead of building my project inside Tensorflow. Background I had achieved this by building Tensorflow with CMake. However,…
Guikarist
  • 181
  • 7
14
votes
2 answers

How to find all publicly visible targets in a Bazel workspace

I am trying to query the list of Bazel targets having public visibility. Some of our Bazel targets have visibility specified explicitly, e.g.: cc_library( name = "xxx_util", visibility = ["//visibility:public",], ... ) while most…
Curious
  • 2,783
  • 3
  • 29
  • 45
14
votes
1 answer

C++ debugging with gdb & bazel (& emacs)

I want to debug an executable generated with Bazel. The gdb debugger is lost with the links generated by Bazel and is not able to show me the C++ source code. How to fix that? The project root directory is /home/.../Cpp/ ./Cpp/ ├── bazel-bin ->…
Picaud Vincent
  • 10,518
  • 5
  • 31
  • 70
14
votes
1 answer

see compilation warnings on cached bazel targets

Bazel displays all compilation warnings during the clean compilation (java). But - when we rerun bazel build - we lose all the warnings. Is there any flag that would make it display the original warnings for cached targets? Example repo:…
orshachar
  • 4,837
  • 14
  • 45
  • 68
14
votes
2 answers

Error with multiple Bazel BUILD files: "Target 'bar' is not visible from target 'foo'"

My project as the following structure: $ tree . ├── bar │   ├── bar.cpp │   └── BUILD ├── BUILD ├── foo.cpp └── WORKSPACE Content of ./BUILD: cc_binary( name = "foo", srcs = [ "foo.cpp" ], deps = [ "//bar" ], ) Content of…
morxa
  • 3,221
  • 3
  • 27
  • 43
13
votes
1 answer

Bazel + Angular + SocketIO Causes: Uncaught TypeError: XMLHttpRequest is not a constructor

I want to add ngx-socket-io to my Angular application. I use Bazel to run my Angular dev-server. Unfortunately ngx-socket-io doesn't seem to work with the ts_devserver out of the box. I get this error in the browser console: Uncaught TypeError:…
Florian Ludewig
  • 4,338
  • 11
  • 71
  • 137
13
votes
2 answers

Aosp does not have tools/vendor/google3 project

When I build Android Studio from source code using: 'bazel build //tools/adt/idea/...' command can't always find 'tools/vendor/google3' module, isn't google no open source project? zhangyang@zhangyang-OptiPlex-7040:~/aosp/gradle_3.1.2$ bazel build…
yangzaiCN
  • 141
  • 5
13
votes
3 answers

How to resolve bazel "undeclared inclusion(s)" error?

I'm new to bazel, and I'm getting a failure to build my C++ package with ERROR: /path/to/package/BUILD:linenumber:1 undeclared inclusion(s) in rule '//path/to/package:name': this rule is missing dependency declarations for the following files…
Die in Sente
  • 9,546
  • 3
  • 35
  • 41
13
votes
3 answers

How can I make bazel use external storage when building?

When building certain code with bazel I'm running out of storage space. I'd like bazel to store its things on a USB drive instead of in my ~/.cache folder. How can I tell bazel to do this?
Matt Kleinsmith
  • 1,017
  • 3
  • 13
  • 24
13
votes
4 answers

Is there a migration path from Maven to Bazel?

Now that Bazel (http://bazel.io/) has been opensourced, is there an incremental process by which I can gradually migrate (a large repository) from Maven to Bazel?
Niel de Wet
  • 7,806
  • 9
  • 63
  • 100
12
votes
1 answer

How can I compile a C++ library statically with Bazel to use in Rust?

My goal is to get a .a static library on linux from the MediaPipe project, which is built with Bazel. To my knowledge, there is no bazel rule for doing so. I really don't want to integrate with Bazel - I want it to produce what I need, and use it in…
Sam Sieber
  • 490
  • 6
  • 12
12
votes
1 answer

what does k8 mean in bazel info local_cpu_resources' output

When I run bazel info --local_cpu_resources HOST_CPUS on macos and ubuntu In Macos `bazel-bin: .../9dcdc19e81f948a3daf2cc314e0d4bf1/execroot/demo/bazel-out/darwin-fastbuild/bin` `bazel-genfiles:…
mo6114
  • 123
  • 1
  • 7
12
votes
5 answers

How do I use pytest with Bazel?

I have a my_module.py file that implements my_module and a file test_my_module.py that does import my_module and runs some tests written with pytest on it. Normally I run the tests by cding into the directory that contains these two files and then…
Boris Verkhovskiy
  • 14,854
  • 11
  • 100
  • 103
12
votes
1 answer

How to specify custom timeout for bazel test

bazel test command uses default timeout of 75 seconds for tests tagged size = small in my setup (version 0.12.0) (while the documentation mentions this as 60 seconds) Is there a way to supply a custom timeout say 10 seconds, on bazel command line,…
Curious
  • 2,783
  • 3
  • 29
  • 45
12
votes
2 answers

Build docker image from Dockerfile using Bazel

I have a fairly simple Dockerfile and now would like to build a docker image using rules_docker. Trying to use container_image, it seems like I cannot use the Dockerfile as input. Is there any way to build with a Dockerfile?
abergmeier
  • 13,224
  • 13
  • 64
  • 120