Book Deep-Read · Software Engineering at Google · Chapter 18

Build Systems and Build Philosophy

Software Engineering at Google · Ch 18 · Build Systems and Build Philosophy · Erik Kuefler · 2020

中文 →

What is this chapter about?

Programmers write text that people can read; computers run a different kind of file that only machines understand. The "translate and assemble" step in between is called the build. Every app on your phone, every update, has gone through it. This chapter is about how Google made that step both fast and dependable — fast enough that a one-line change comes back in seconds, dependable enough that whichever of tens of thousands of engineers runs it, the result is identical.

A surprising fact first

Ask Google engineers what they like best about the company, free food aside, and many will say: the build system. In an internal survey it ranked fourth out of 19 tools. Stranger still, it works so well precisely because it does not let engineers do whatever they want — it takes some of their freedom away.

Why the old way was hard

The old way was like a handwritten recipe where each step could say anything at all. The head chef could not tell what any step really did, so they never dared let two cooks work at once, in case both grabbed the same pan; nor dared skip a step, in case it quietly used stale ingredients. So every meal was cooked from scratch, slower and slower. Worse, the recipe often only worked in the kitchen of whoever wrote it — on another computer, a missing tool or the wrong version and the dish failed.

How it works, intuitively

What it brings / how to choose

What you get: change a little and only that little is redone; you almost never need to "wipe and start over"; a new hire can build any code on day one, and automated testing and releases can safely sit on top. The honest cost: you can no longer toss off a script that does anything you like — you play by its rules — and moving a big project already built the old way is not cheap.

One line to remember

Turn the build from "run a list of steps" into "declare the products you want": give up a little freedom, and the system can run in parallel, reuse results and spread work over thousands of machines — while guaranteeing the same result everywhere.

Want to see why task-based builds can't safely parallelize or go incremental, how Bazel's sandboxes and toolchains pin the environment down, how remote caching and remote execution fit together, and why strict transitive dependencies and the One-Version Rule were worth years of rollout? → Switch to the deep read