Software Engineering at Google Chapter #18 - Build Systems and Build Philosophy (2 of 3)

  • “Task based” build systems such as Maven, Ant, Gradle, Grunt, and Rake are essentially a series of build files with each file being run as an independent task
  • In general each task will determine dependencies, compile things, then move onto next task
  • Task-based build systems have downsides such as…
    • It gives the developer too much power and is too flexible which leads to inconsistencies and non-standard builds
    • You can’t do task-based builds in parallel, they must be done sequentially
    • Incremental builds are good but fail in task-based because the tasks can’t easily figure out if they have already been completed / need to be re-run. it must do all steps to guarantee correctness
  • Artifact-based build systems (such as Bazaz) don’t let engineers define custom build tasks
  • Instead, an artifact-based build system pre-defines the tasks and then gives the engineers options to change certain parameters of the build
  • Essentially, in an artifact-based build system the developer tells the system what to build and build system determines how to build it
  • Artifact based build systems use a declarative language. This means the developer tells the system what the end result should be and the build system determines how to arrive at the desired result
  • An artifact-based builds “targets” and outputs artifact(s)
  • Artifact-based build systems attempt to execute things in parallel by looking at dependencies
  • Another advantage of artifact-based build systems is that they can determine if a rebuild is needed by looking at inputs. If part of the code did not change then there is no reason to rebuild that code - it can just re-use the existing artifact from the previous build
  • Build tools are also considered dependencies. All builds need a compiler, but some builds may need a particular version of the compiler, not just any version or the version that happens to be installed on your laptop by default
  • Use toolchains instead of just tools. Toolchains can be platform specific
  • One should use sandboxes to restrict what the build can see (containers, Docker, LXC, etc) as to reduce conflicts and confusion



Thank you for your time and attention.
Apply what you've learned here.
Enjoy it all.