Enhance bootstrap stage selection

This simplifies the bootstrap process while making it more flexible by
moving the stage selection into a go binary(choosestage). It will now be
possible to have more than two build stages.

Now each stage has a ninja template(main.ninja.in) and a timestamp
file(main.ninja.in.timestamp). The timestamp file may be updated by any
build stage that wishes to regenerate the ninja template. If the
choosestage binaries sees that the timestamp is newer than the template,
it will choose the prior stage.

The main stage no longer writes to the source tree to update the
build.ninja.in file. This was a problem for read-only source trees.
Instead, the choosestage binary first checks to see if that file is
newer than the last bootstrap.ninja.in, copies it in place, and starts
the boostrap stage.

The bootstrap stage regenerates it's own ninja template, but that
required a loop through the main stage to actually run it. The
choosestage binary now detects if the template has changed for the
current stage, and will restart the stage.

One change is that if dependencies do get messed up, instead of silently
failing, there's a higher chance that the bootstrap step will just
continue looping, doing nothing. This can happen if the main stage
has a dependency that triggers the bootstrap stage, but the bootstrap
stage doesn't see anything required to rebuild the main ninja file. A
side effect of this requirement is that changes to test code will now
rebuild the main ninja file.

Change-Id: I9965cfba79dc0dbbd3af05f5944f7653054455a2
14 files changed
tree: 1a074f9126d2f730bf67fc873e78c0526339f0a0
  1. bootstrap/
  2. bpfmt/
  3. bpmodify/
  4. choosestage/
  5. deptools/
  6. gotestmain/
  7. parser/
  8. pathtools/
  9. proptools/
  10. tests/
  11. .gitignore
  12. .travis.yml
  13. Blueprints
  14. bootstrap.bash
  15. build.ninja.in
  16. context.go
  17. context_test.go
  18. CONTRIBUTING.md
  19. doc.go
  20. LICENSE
  21. live_tracker.go
  22. mangle.go
  23. module_ctx.go
  24. ninja_defs.go
  25. ninja_strings.go
  26. ninja_strings_test.go
  27. ninja_writer.go
  28. ninja_writer_test.go
  29. package_ctx.go
  30. README.md
  31. scope.go
  32. singleton_ctx.go
  33. splice_modules_test.go
  34. unpack.go
  35. unpack_test.go
README.md

Blueprint Build System

Build Status

Blueprint is a meta-build system that reads in Blueprints files that describe modules that need to be built, and produces a Ninja manifest describing the commands that need to be run and their dependencies. Where most build systems use built-in rules or a domain-specific language to describe the logic for converting module descriptions to build rules, Blueprint delegates this to per-project build logic written in Go. For large, heterogenous projects this allows the inherent complexity of the build logic to be maintained in a high-level language, while still allowing simple changes to individual modules by modifying easy to understand Blueprints files.