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
10
votes
3 answers

How to Install an Older Version of Bazel using Homebrew?

I tried to install an older version of Bazel using homebrew by specifying the commit I need (https://raw.githubusercontent.com/bazelbuild/homebrew-tap/c8a0ccc2a8b442d9887d88c6380f835f533ffd47/Formula/bazel.rb). I used the command brew install…
Malith
  • 685
  • 1
  • 8
  • 14
10
votes
2 answers

How to get Bazel, ccache, and sandboxing to work together (ccache read only filesystem)

I'm attempting to build a C++ application on Fedora 28 using Bazel 0.16.1 installed via copr and ccache 3.4.2 installed via DNF. I'm using the default cc_binary and cc_library rules. When I run the bazel build command, ccache errors out…
Matt W
  • 101
  • 1
  • 4
10
votes
1 answer

How to (hermetically) include Python interpreter in Bazel to build Python library (sdist)

How can I (hermetically) include python as an (executable) input to my genrule? Conceptually, I'm aware of the following approaches: include a python interpreter in the source repo at third_party/python have Bazel fetch python ala rules-go There…
Pedro Cattori
  • 2,735
  • 1
  • 25
  • 43
10
votes
3 answers

Can I use Python Debugger In Bazel Test

I am trying to debug my tests using pdb (Python debugger) while running them with bazel. This is a sample test I have: class TestMembersResource(TestCase): def test_get(self): response = self.client.get('/api/v1/members/') …
Mihai
  • 831
  • 6
  • 13
10
votes
1 answer

How do I reference a system library used by an external dependency if copts doesn't allow system paths?

For Bazel, I'm pulling in an external library from within my WORKSPACE: new_http_archive( name = "imgui", build_file = "deps/BUILD.imgui", sha256 = "c457fdc19b4e3aa74deccf6a2d9bc51f0d470b3acd9cc095bf04df16459d6474", …
Trevor Hickey
  • 36,288
  • 32
  • 162
  • 271
10
votes
3 answers

Bazel: genrule that outputs a directory

I'm just getting started working with Bazel. So, I apologize in advance that I haven't been able to figure this out. I'm trying to run a command that outputs a bunch of files to a directory and make this directory available for subsequent targets. I…
Skylar Saveland
  • 11,116
  • 9
  • 75
  • 91
10
votes
4 answers

How to run all tests in Bazel from a single java_test() rule?

I am adding tests in Bazel, but I don't want to write a test rule for every single test file. However, each test rule requires a test_class - the test class that is being ran, so there is no easy way to just run all tests with a single java_test…
Zeitgeist
  • 1,382
  • 2
  • 16
  • 26
9
votes
3 answers

Bazel - Build, Push, Deploy Docker Containers to Kubernetes within Monorepo

I have a monorepo with some backend (Node.js) and frontend (Angular) services. Currently my deployment process looks like this: Check if tests pass Build docker images for my services Push docker images to container registry Apply changes to…
Florian Ludewig
  • 4,338
  • 11
  • 71
  • 137
9
votes
1 answer

Up-level references ("..") in Bazel

In my bazel BUILD file, I have a line: srcs = glob([, , ...]) I tried to have one of my patterns be "../dir/*.cc" but I get an error that I'm not allowed to use the .. sequence here. Checking the documentation, I have found that…
Apollys supports Monica
  • 2,938
  • 1
  • 23
  • 33
9
votes
3 answers

How to build a simple C++ demo using Eigen with Bazel?

How can I use Eigen within a C++ project that is built using Bazel (version 0.25.2)? I like to fetch the Eigen dependency using http_archive or git_repository. I've tried the following: main.cpp #include #include using…
Vertexwahn
  • 7,709
  • 6
  • 64
  • 90
9
votes
0 answers

Bazel create C++ shared library with soname

I would like to create a shared c++ library with Bazel using a soname. With cmake I could set properties like: set_target_properties(my-library PROPERTIES SOVERSION 3 VERSION 3.2.0 ) which would then…
Chris Maes
  • 35,025
  • 12
  • 111
  • 136
9
votes
1 answer

Aggregate filegroups in subpackages into a large filegroup in bazel?

I have a parent directory foo, and child directories bar, baz, and qux. All four directories contain a bazel BUILD file and define filegroup rules that contain all files in the subdirectory (plus various other rules). The problem with this is that…
jonderry
  • 23,013
  • 32
  • 104
  • 171
9
votes
2 answers

What does the "@" symbol mean in Bazel?

I'm studying Bazel building system at present. I always see the @ symbol in Bazel script, but I cannot find any documentation about it. I searched it on the website of Bazel but the result seems useless. @ in Bazel. For example: filegroup( name =…
Robin Lew
  • 315
  • 4
  • 12
9
votes
1 answer

Is there verbose logging for Bazel?

I dig around Bazel source code, there aren't much logging it seems. Is there a way to enable some kind of verbose mode so I can see what bazel is doing? Also there seems to be various kind of debug options but I cant seem to comprehend yet, if I…
HoaPhan
  • 1,714
  • 1
  • 13
  • 35
9
votes
3 answers

Bazel and System Environment Variable

I am building my Java project with Bazel. I want to use environment variables at build/run time. According to the documentation --action_env=APP_ENV=Development should work. So I do bazel run myproject:app --action_env=APP_ENV=Development But…
flexxxit
  • 2,440
  • 5
  • 42
  • 69