-
Notifications
You must be signed in to change notification settings - Fork 8
Interdependencies
The outputs of one phase can serve as the inputs for another. Under the hood, Ninja will know how to create the outputs in the most efficient order, using multiple CPU cores when available. You can specify the relationship easily in Rōnin:
Phase(project=project,
name='compile',
executor=GccCompile(),
inputs=glob('src/*.c'))
Phase(project=project,
name='link',
executor=GccLink(),
inputs_from=[compile],
output='myprogram')
Note that inputs_from
is a list: you can gather inputs from more than one phase. Also,
each element of inputs_from
can be a string instead of a Phase
instance, which will be
interpreted as the name of another phase on the same project. (You cannot relate to a phase on
another project because it's in a separate Ninja file.)
Sometimes you may want to force a phase to run only if another is complete, but you don't actually
want to treat one's outputs as the other's inputs. Use build_if_from
:
Phase(project=project,
name='archive',
executor=Archive(),
build_if_from=[compile1, compile2],
output='myarchive')
In Ninja, this is implemented as "order-only dependencies" (single bar). You can also specify individual files
using build_if
. You can similarly use rebuild_on
and rebuild_on_from
to specify Ninja "implicit
dependencies" (double bar).