Live data from Hacker News

Ninja: A simple way to do builds

jvns.ca

1–10 of 92 posts

Re: Ninja: A simple way to do builds

#5
post #2

That's just BASH with extra steps.

Ninja hasn't been created for small one-liners like in this blog post, but for massive C++ builds with tens- or hundreds-of-thousands of source files arranged in a complex dependency tree.

Figuring out quickly what needs to be rebuilt for massive builds like this isn't trivial, but that's essentially the one important thing that ninja does.

Also see:

https://ninja-build.org/manual.html#_design_goals

Re: Ninja: A simple way to do builds

#6
If you don't know it, CMake can use ninja instead of make for compilation so instead of "mkdir build && cd build && cmake .. && make" you can run "mkdir build && cd build && cmake -GNinja && ninja".

It feels faster on my side projects (haven't benchmarked it really), but most importantly, when running a parallel build it does not interleave the output of the different steps, making it much easier to read warnings and errors.

Re: Ninja: A simple way to do builds

#7
post #2

That's just BASH with extra steps.

Ninja hasn't been created for small one-liners like in this blog post, but for massive C++ builds with tens- or hundreds-of-thousands of source files arranged in a complex dependency tree. Figuring out quickly what needs to be rebuilt for massive builds like this isn't trivial, but that's essentially the one important thing that ninja does. Also see: https://ninja-build.org/manual.html#_design_goals

... What mechanism is used to perform incremental builds? It is referenced in the article and unexplained from what I can tell. What enables "quickly" for you to determine what needs to be built? Make simply compares timestamps I believe.

... What mechanisms/tricks speed up builds? Or is it just the "simplicity" that is the BFD?

Edit: It sure would have been helpful if somewhere was stated: "the build system of Chrome":-)

That statement indicates a huge difference between some rando build system on someone's personal project, and a build system on operating-system-size codebase that is over a decade old.

Re: Ninja: A simple way to do builds

#8

Earlier quoted context omitted.

Ninja hasn't been created for small one-liners like in this blog post, but for massive C++ builds with tens- or hundreds-of-thousands of source files arranged in a complex dependency tree. Figuring out quickly what needs to be rebuilt for massive builds like this isn't trivial, but that's essentially the one important thing that ninja does. Also see: https://ninja-build.org/manual.html#_design_goals

... What mechanism is used to perform incremental builds? It is referenced in the article and unexplained from what I can tell. What enables "quickly" for you to determine what needs to be built? Make simply compares timestamps I believe. ... What mechanisms/tricks speed up builds? Or is it just the "simplicity" that is the BFD? Edit: It sure would have been helpful if somewhere was stated: "the build system of Chrom…

Ninja uses time stamps. See the “Comparison to Make” section in the linked manual.

Re: Ninja: A simple way to do builds

#9

If you don't know it, CMake can use ninja instead of make for compilation so instead of "mkdir build && cd build && cmake .. && make" you can run "mkdir build && cd build && cmake -GNinja && ninja". It feels faster on my side projects (haven't benchmarked it really), but most importantly, when running a parallel build it does not interleave the output of the different steps, making it much easier to read warnings and…

If anyone wants to know more about preventing interleaving, try using `make -O` or adding `GNUMAKEFLAGS += --output-sync` to the top of your Makefile.
Post reply on HN