commit | 8881a661ae63e1124eb47b45f08d9fa1225a5f00 | [log] [tgz] |
---|---|---|
author | Cole Faust <[email protected]> | Wed Jan 10 18:11:29 2024 -0800 |
committer | Evan Martin <[email protected]> | Tue Mar 05 11:03:56 2024 -0800 |
tree | 0d9a6e659f8bf87bfc1d8e7f1135e46e5bd5e175 | |
parent | 668d9ab5cdbd493a8af356078066423487ac81e2 [diff] |
Parse depfiles with multiple targets This is needed for android. It just treats all the deps of all targets in the depfile as deps for the Build. In task.rs there is a TODO to verify that the targets refer to the outputs of the Build, but adding that verification breaks the android build. In android's case, there are some depfiles that contain `foo.o: path/to/some/dep.asm` where it should instead be `path/to/foo.o: path/to/some/dep.asm`.
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 ninja
mklink ninja.exe path\to\n2
New-Item -Type Symlink ninja.exe -Target path\to\n2
Warning
If you don't have Ninja installed at all, you must install such a symlink because CMake attempts to invokeninja
itself!
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.