Implement --frontend-file
This is what soong uses to take control of ninja's output. Ninja will
just be quiet but write protobuf-encoded status messages to a file that
soong_ui reads.
Not all fields of the protobuf are implemented in this cl, but it's
enough to display a functional UI in an android build. Missing things
include:
- A bunch of fields related to how much time/memory an action took
- A critical path time estimate used in displaying an ETA, but that
requires the infrastructure about the time of prior builds used
to schedule slower actions with higher priority in regular ninja
- The inputs that changed that caused an action to rerun, used in
some telemetry
Bug: 318434287
Test: cargo test
Change-Id: I79432cdab965ff5fc7e0d5b42c645488b2e9093b
n2 (pronounced “into”) implements enough of Ninja to successfully build some projects that build with Ninja. Compared to Ninja, n2 missing some features but is faster to build and has a better UI; see a more detailed comparison.
Here's a small demo of n2 building some of Clang.
$ cargo install --git https://github.com/evmar/n2 # (installs into ~/.cargo/bin/) $ n2 -C some/build/dir some-target
When CMake generates Ninja files it attempts run a program named ninja with some particular Ninja behaviors. In particular, it attempts to inform Ninja/n2 that its generated build files are up to date so that the build system doesn't attempt to rebuild them.
n2 can emulate the expected CMake behavior when invoked as ninja. To do this you create a symlink named ninja somewhere in your $PATH, such that CMake can discover it.
ln -s path/to/n2 ninjamklink ninja.exe path\to\n2New-Item -Type Symlink ninja.exe -Target path\to\n2Warning
If you don't have Ninja installed at all, you must install such a symlink because CMake attempts to invokeninjaitself!
While building, n2 displays build progress like this:
[=========================--------- ] 2772/4459 done, 8/930 running Building foo/bar (2s) Building foo/baz
The progress bar always covers all build steps needed for the targets, regardless of whether they need to be executed or not.
The bar shows three categories of state:
= signs show the build steps that are already up to date.- signs show steps that are in-progress; if you had enough CPUs they would all be executing. The 8/930 running after shows that n2 is currently executing 8 of the 930 available steps.The lines below the progress bar show some build steps that are currrently running, along with how long they've been running if it has been a while. Their text is controlled by the input build.ninja file.
I wrote n2 to explore some alternative ideas I had around how to structure a build system. In a very real sense the exploration is more important than the actual software itself, so you can view the design notes as one of the primary artifacts of this.