VOOZH about

URL: https://thenewstack.io/bazel-googles-open-source-build-system/

⇱ Bazel, Google's Open Source Build System - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2015-04-27 07:52:20
Bazel, Google's Open Source Build System

Bazel, Google’s Open Source Build System

Apr 27th, 2015 7:52am by David Bolton
👁 Featued image for: Bazel, Google’s Open Source Build System
Feature image via Flickr Creative Commons.

One of the most important, yet unsung, applications in a software developer’s life is the Make utility, or its equivalent. Make first appeared in 1977 and has been with us ever since. There are a very large number of build utilities, some based on Make, others completely different. The principle remains the same. The build system has a set of rules that tell it how to build an application from source files, usually fetched from a version control system. The Make utility reads the rules, then runs the compilers and linkers to do the build. The really good ones will run tests, as well.

Google has been using their own system, called Blaze, and open-sourced part of it as the anagrammatically named Bazel — recently released at alpha status. In this article I’ll give a general overview of Bazel.

So what’s different about Bazel? It aims to do two things: build quickly and correctly. It uses a massive shared code repository where all software is built from source. Speed is achieved using both caching and parallelism. Blaze solves a slightly different problem from Bazel as it is designed for Google’s internal systems. Any Google engineer can build any Google product from source on any machine by invoking a Blaze command. Here’s what one Google engineer said about Blaze on Hacker News:

Working at Google, Blaze is one of the technologies that amazes me most. Any engineer can build any Google product from source on any machine just by invoking a Blaze command. I may not want to build GMail from source (could take a while) but it’s awesome to know that I can.

I think this could be hugely useful to very large open source projects (like databases or operating systems) that may be intimidating for contributors to build and test.

Using Bazel

Bazel works on packages — collections of files with interdependencies, and sub-directories — and sub-packages. Each package is a directory containing a file called BUILD.

The packages define targets as either files or rules. Files are either source files or files generated by build tools such as .obj files or resource files. Rules describe how to generate output files from input files, including other rules, and the steps needed to build the output files.

Bazel is run as a client server on Linux and Mac environments. Windows doesn’t currently seem to be a high priority for the Bazel team, presumably because they don’t develop for it and it’s not a platform they use internally.

The client is command line-based with commands like ‘bazel’ to invoke the client or ‘bazel test’ to run tests. The Bazel client talks to a long running server, or starts one if it isn’t present; there’s one server per workspace, which is a directory containing the source code that you’re building. Bazel has been designed to avoid the problems with errors in a Make process that require a ‘make clean’ prior to rebuilding everything once the error is fixed. Success or failure of build stages in Bazel is tracked in a database, and if the input stages are unchanged, then no rebuilds happen. Bazel guarantees that after a successful build, during which no edits were done, the build will be in a consistent state.

Programming Language Support

The technology behind Bazel is mainly Java and Bash scripts. Programming language support is provided for C/C++, Objective-C, Java, Python and Bourne Shell scripts. Currently Bazel is at the alpha stage, but it plans to add JavaScript and Go after it reaches beta sometime in June 2015.

Extending Bazel

Bazel can extend rules and macros through the Skylark language. Macros are functions called from the BUILD file and are used to create rules for the build. Skylark’s syntax is a subset of Python, although some features not supported are class, while, break, continue, lambda and a few others. It’s also thread-safe, data structures are immutable, global values are constant and cannot be reassigned nor can a variable type be changed. These restrictions help speed up builds, because they allow parts of builds to run in parallel.

Test Support

There are Bazel build rules that define automatic tests run by the command ‘bazel test.’ The test runner works on multiple test executables, created by running test rules, and are time limited, depending on the tests size or a specified timeout. The Test Encyclopedia strongly suggests tests be reduced to minimum dependencies so the results can be reproduced reliably.

Bazel Query

A particularly strong feature is the Bazel Query language, which is used to analyze build dependencies. This involves a learning curve; however,  you may not even need it for simpler builds. Basically, you apply filters to return targets. These can be paths, files, rules, etc. It’s a powerful system, and knowledge of graph theory would come in very handy!

Conclusions

Given the vast amounts of software Google builds, it’s encouraging to see them advancing the state of build technology. But note — only 10 percent of these rules have been open-sourced, the rest are Google build-specific, so they won’t make sense to an outsider.

Bazel is aimed, in particular, at projects with a combination of the following characteristics: they have a large shared codebase that supports multiple platforms, they are written in multiple languages and have an extensive test suite. If that’s your project, take a closer look at Bazel.

Given how many enterprises use Windows and develop software for it, I wonder if that might limit Bazel’s take up.

TRENDING STORIES
SHARE THIS STORY
TRENDING STORIES
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.