Build Tool
I’ve interacted with 3 different build tools for C++:
Bazel is much better for large codebases apparently. But why exactly?
Resources
- https://igormcoelho.medium.com/building-cross-platform-c-gmp-library-with-vcpkg-cmake-and-bazel-lessons-learned-ea2cba4b697d
- What’s Bazel? Why should you care?
Challenges of build systems:
- Speed and efficiency (build things fast)
- Fixed with caching
- Reproducibility (if a dependency is updated, you want to make sure things can be reproduced)
- If you simply
apt installa package, that’s not very precise. Which machine is it on. WH
- If you simply
- Configurability (support different platforms for example, x86 vs. ARM)
- Extensibility (adding a new language)
- integrations (large codebases, support multiple tools)
Working on various platforms (configurable for various platforms)
The timeline
1. g++
Bad
- Have
- No maching
2. Make (improvement with caching)
- Glorified shell script
- Naive caching based on timestamp
- Hard to reuse tooling
- Hard to read
3. CMake
CMake doesn’t actually build anything. It generates a build script based on higher level code. It’s a higher level build system, but it doesn’t build the code. Makes it more readable, and reuse. More concise.
Now you have: Configurability + Extensibility
Build is still executed by another build system (make, ninja).
- Still another build system
- Suffers from the underlying build system
Sidenote: Language specific build systems
Build systems are really hard to configure → 15:00
It’s hard to improve performance, to tune. Hard to integrate different projects together.
A new build system for each language.
why is bazel more correct than make? like sometimes i need to run make clean
Because make mostly relies on the timestamp? And checks imports dependencies? Whereas bazel uses a strict dependency graph.
4. Bazel
This guy really starts praising.
Google has a huge monorepo. Lots of problems arise. Millions of code.
Internally, it’s called Blaze.
Bazel is a system that was designed to scale.
Bazel focuses on correctness and determinism.
(almost) Never need to run bazel clean.
Speed follows correctness. Specify granular targets.
Enables distributed caching. You can build in parallel. Possible because it checks for correctness.
How is this correctness achieved?