I would like to launch multiple ninja
builds simultaneously. Each build is in its own directory and has its own build.ninja
file.
I could just do the following:
cd <build-dir-1>
ninja &
cd <build-dir-2>
ninja &
...
cd <build-dir-last>
ninja
....but there are a couple of issues with this:
- The default number of threads used by Ninja probably isn't optimal when launching multiple independent builds simultaneously.
- Output will, I expect, be interleaved in a non-sensible way.
EDIT I could also just keep the ninja
calls in the foreground (which is what I'm currently doing), but then there would be no easy way to estimate what the current progress of the (entire) build is.
So, I would like to do one of the following:
- merge the
build.ninja
files into one big file that can perform both builds in oneninja
invocation. - somehow launch
ninja
with multiple targetbuild.ninja
scripts.
It doesn't look like that second option is supported by ninja
, but the first seems like it could be done easily enough using subninja <build-dir-n>/build.ninja
. Has anyone done something like this before? Are there any hidden pitfalls? Alternatively, I could just perform the builds in sequence (i.e. the above sequence but without the &
s), but this doesn't feel like the right solution.
Use-case
I'm using CMake
, which generates a separate build.ninja
file for each build configuration (release and debug). I'm also targeting multiple platforms, so I have multiple compiler, and CMake must be run separately for each platform. So if I want to build release and debug code for all platforms, I need to run ninja
multiple times.