Bazel (software)
{{Short description|Software tool that automates software builds and tests}}
{{Multiple issues|
{{More citations needed|date=February 2024}}
{{Promotional|date=October 2019}}
}}
{{Infobox software
| name = Bazel
| logo = Bazel logo.svg
| screenshot =
| caption =
| collapsible =
| developer = Google
| released = {{Start date and age|2015|03}}
| latest release version = {{wikidata|property|edit|reference|P348}}
| latest release date = {{start date and age|{{wikidata|qualifier|P348|P577}}}}
| programming language = Java
| operating system = Cross-platform
| genre =
| license = Apache License 2.0
}}
Bazel ({{IPAc-en|ˈ|b|eɪ|z|əl}}{{cite web |url=https://bazel.build/faq.html#how-do-you-pronounce-bazel |title=FAQ - Bazel |website=bazel.build |url-status=dead |archive-url=https://web.archive.org/web/20161106034446/http://bazel.build/faq.html |archive-date=2016-11-06}}) is a free and open-source software tool used for the automation of building and testing software.{{cite journal|last1=Yegulalp|first1=Serdar|title=Google open-sources language-agnostic, scalable software tool|journal=InfoWorld|date=Sep 11, 2015|url=https://www.infoworld.com/article/2983495/development-tools/google-open-sources-language-agnostic-scalable-software-tool.html|access-date=25 June 2016|archive-url=https://web.archive.org/web/20171025022213/https://www.infoworld.com/article/2983495/development-tools/google-open-sources-language-agnostic-scalable-software-tool.html|archive-date=25 October 2017|url-status=live}}
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,{{Cite web|url=https://bazel.build/rules/language|title=Starlark - Bazel|website=blog.bazel.build|language=en|access-date=2018-10-18}} 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.{{cite web|title=FAQ - Bazel|url=https://bazel.build/faq.html|website=bazel.build|access-date=25 June 2016}}
History
In 2006,{{cite web|last1=Vermeulen|first1=Steve|title=Bazel, From Blaze to Buck2 — A Brief History of Modern Monorepo Build Systems|date=21 November 2023 |url=https://betterprogramming.pub/from-blaze-to-buck2-a-brief-history-of-modern-monorepo-build-systems-563becbcb987}} Google started the development of a build tool called Blaze.{{cite book|last1=Beyer|first1=Betsy|last2=Jones|first2=Chris|last3=Petoff|first3=Jennifer|last4=Murphy|first4=Niall Richard|title=Site Reliability Engineering: How Google Runs Production Systems|date=23 March 2016|publisher="O'Reilly Media, Inc."|isbn=9781491951187|page=90|url=https://books.google.com/books?id=_4rPCwAAQBAJ&q=Bazel+build&pg=PA90|access-date=25 June 2016|language=en}} The motivation was to have a build system that provides both speed and correctness in a large monorepo.{{cite book |last1=Winters |first1=Titus |last2=Manshreck |first2=Tom |last3=Wright |first3=Hyrum |title=Software Engineering at Google |publisher=O'Reilly |page=372}}
Bazel was created as an open-source port of Blaze, using its anagram as a name.{{cite web|last1=Bolton|first1=David|title=Bazel, Google's Open Source Build System - The New Stack|url=https://thenewstack.io/bazel-googles-open-source-build-system/|website=thenewstack.io|publisher=The New Stack|access-date=25 June 2016|date=27 April 2015|archive-url=https://web.archive.org/web/20171024153418/https://thenewstack.io/bazel-googles-open-source-build-system/|archive-date=24 October 2017|url-status=live}} Bazel was first released in March 2015 and entered beta by September 2015.{{cite web|last1=Daws|first1=Ryan|title=Google's software build tool Bazel heads into beta|url=https://www.developer-tech.com/news/2015/sep/10/googles-software-build-tool-bazel-heads-beta/|website=www.developer-tech.com|date=10 September 2015|publisher=Developer Tech|access-date=25 June 2016|archive-url=https://web.archive.org/web/20171023140229/https://www.developer-tech.com/news/2015/sep/10/googles-software-build-tool-bazel-heads-beta/|archive-date=23 October 2017|url-status=live}} Version 1.0 was released in October 2019.{{Cite web |title=Bazel 1.0 |url=https://blog.bazel.build/2019/10/10/bazel-1.0.html |access-date=2023-10-29 |website=blog.bazel.build |language=en}}
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.{{cite journal|title = Build Systems à la Carte|author=Mokhov, Andrey and Mitchell, Neil and Peyton Jones, Simon|journal=Proceedings of the ACM on Programming Languages|volume=2|issue=ICFP|year = 2018|pages=1–29 |doi=10.1145/3236774 |doi-access=free}} 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.{{cite web |title=Starlark Language |url=https://bazel.build/rules/language |website=bazel.build}} 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,{{cite web|url=http://www.pantsbuild.org/|title=Pants: A fast, scalable build system}} Buck,{{cite web|url=https://buckbuild.com/|title=Buck: A high-performance build tool}} Please,[https://please.build/faq.html Please FAQ] and the Brazil build system used internally at Amazon.[https://gist.github.com/terabyte/15a2d3d407285b8b5a0a7964dd6283b0 Amazon's Build System] 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.{{cite web|url=http://gittup.org/tup/build_system_rules_and_algorithms.pdf|first=Mike|last=Shal|date=2009|title=Build System Rules and Algorithms}}
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
.{{cite web |url=https://github.com/bazelbuild/bazel/blob/4dfc83d5f11e9190e9e25dee4c7dc2a71cd7b8fd/tools/cpp/osx_cc_wrapper.sh#L84-L102 |title=tools/cpp/osx_cc_wrapper.sh|date=5 February 2022|publisher=Github}}
Logo
File:Bazel (software) logo.png
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,{{cite web|url=https://blog.bazel.build/2017/07/05/new-logo-and-homepage.html|first=Steren|last=Giannini|date=5 July 2017|title=A new logo and homepage for Bazel}} consisting of three green building blocks arranged to shape a heart.
Adoption
Bazel is commonly used by companies.{{cite web | url=https://bazel.build/community/users | title=Who's Using Bazel }} A few notable users include Google, SpaceX,{{cite web | url=https://www.youtube.com/watch?v=t_3bckhV_YI | title=Building Real-time Systems with Bazel w/ SpaceX | via=YouTube | date=11 December 2017 }} Stripe,{{cite web | url=https://stripe.com/blog/fast-secure-builds-choose-two | title=Fast builds, secure builds. Choose two | date=4 May 2022 }} Tinder,{{cite web | url=https://medium.com/tinder/bazel-hermetic-toolchain-and-tooling-migration-c244dc0d3ae | title=Bazel Hermetic Toolchain and Tooling Migration | work=Medium | date=13 June 2022 | author1=Tinder }} and Uber.{{cite web | url=https://www.uber.com/en-DE/blog/go-monorepo-bazel/ | title=Building Uber's Go Monorepo with Bazel | Uber Blog }}
See also
{{Portal|Computer programming}}
References
{{Reflist}}
External links
- {{Official website}}
{{Google FOSS}}