ArticleslgStudy

computer science

Bazel (software)

Bazel (software) is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Bazel (software) rather than just read about it. In short: Bazel () is a free and open-source software tool used for the automation of building and testing software. Similar to build tools like Make, Apache Ant, and Apache Maven, Bazel builds software applications from source code using rules.

Bazel (software) — main illustration
Bazel (software) — illustration

Key takeaways

  • Bazel (software) belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Bazel (software) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Bazel (software) from memory before moving on to harder problems.

Reference excerpt

Bazel () is a free and open-source software tool used for the automation of building and testing software. Similar to build tools like Make, Apache Ant, and Apache Maven, Bazel builds software applications from source code using rules. Rules and macros are created in the Starlark language, a dialect of Python. There are built-in rules for building software written in Java, Kotlin, Scala, C, C++, Go, Python, Rust, JavaScript, Objective-C, and bash scripts. Bazel can produce software application packages suitable for deployment for the Android and iOS operating systems.

History In 2006, Google started the development of a build tool called Blaze. The motivation was to have a build system that provides both speed and correctness in a large monorepo. Bazel was created as an open-source port of Blaze, using its anagram as a name. Bazel was first released in March 2015 and entered beta by September 2015. Version 1.0 was released in October 2019.

Rationale Bazel has been described as "one of the first openly available cloud build systems". It is able to save the history of previously run commands and share the results across multiple users. To do so, Bazel requires that the inputs and outputs of build targets are fully specified.

Starlark language

Bazel is extensible with the Starlark programming language. Starlark is an embedded language whose syntax is a subset of the Python syntax. However, it doesn't implement many of Python's language features, such as the ability to access the file I/O, in order to avoid extensions that could create side-effects or create build outputs not known to the build system itself. Such side-effects could potentially lead to incorrect analysis of the build dependency graph.

Languages Bazel was designed as a multilanguage build system. It is able to build software combining multiple programming languages within the same repository. Many commonly used build systems are designed with a preference for a specific programming language. Examples of such systems include Ant and Maven for Java, Leiningen for Clojure, sbt for Scala, etc. In a repository with multiple languages, combining separate build systems and achieving the build speed and correctness benefits described above can be difficult and problematic.

Relation to other build tools Build systems most similar to Bazel are Pants, Buck, Please, and the Brazil build system used internally at Amazon. Pants and Buck both aim for similar technical design objectives as Bazel, with Pants being inspired by the Blaze build system used internally at Google. Bazel, Pants, Buck, and Please adopted Starlark as a BUILD file parser, respective to its BUILD file syntax. Independently developed build systems with similar uses in efficient dependency graph analysis and automated build artifact tracking have been implemented in build systems such as tup.

Sandbox Bazel uses a sandbox for compilation steps. When Bazel performs a separate compilation, it creates a new directory and fills it with symlinks to the explicit input dependencies for the rule. For languages like C or C++, this requires the user to be explicit about the dependencies and it prevents the unexpected inclusion of a similarly named header file from another including directory. This sandbox approach leads to issues with common build tools, resulting in a number of workarounds required to correctly compile code under different architectures. For example, when performing separate compilation for Mac/Darwin architectures, the compiler writes the input paths into SO and OSO symbols in the Mach-O binary, which can be seen with a command like nm -a mybinary | grep SO. These paths are needed for finding symbols during debugging. As a result, builds in Bazel must correct the compiled objects after the fact, trying to correct path-related issues that arose from the sandbox construction using flags like -fdebug-prefix-map and -oso_prefix, the latter having become available in Xcode 11.0. Similar handling needs to take place in linking phases, rewriting the rpath values in shared object libraries with a command like install_name_tool.

Logo

Since Bazel's initial release the logo was a green letter "b" stylized into a stem of a basil plant with two leaves. On July 5, 2017, the Bazel Blog announced a new logo, consisting of three green building blocks arranged to shape a heart.

Adoption Bazel is commonly used by companies. A few notable users include BMW, Google, SpaceX, Stripe, Tinder, Spotify, and Uber.

See also List of build automation software Monorepo

References

External links Official website

Illustrations

Bazel (software) illustration
Bazel (software): Old Bazel logo
Old Bazel logo

Worked examples

Example 1 — a first encounter with Bazel (software)

Start with the simplest possible case. Write down what Bazel (software) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Bazel (software) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Bazel (software) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Bazel (software)

In research
Bazel (software) appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Bazel (software) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Bazel (software) is common in secondary-school and first-year university syllabi. It links to neighbouring topics Build automation, Compiling tools, Google software, so understanding it makes those chapters shorter.
In everyday life
Look for Bazel (software) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Bazel (software)” →

How to study Bazel (software) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Bazel (software) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Bazel (software) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Bazel (software) in simple terms?

Bazel () is a free and open-source software tool used for the automation of building and testing software. Similar to build tools like Make, Apache Ant, and Apache Maven, Bazel builds software applications from source code using rules.

Why does Bazel (software) matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Bazel (software)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Bazel (software).

Tags

  • Build automation
  • Compiling tools
  • Google software
  • Software using the Apache license

Keep exploring