Denylist of build targets

86 views
Skip to first unread message

Rohan Pavone

unread,
Jul 1, 2022, 2:42:21 AM7/1/22
to ninja-build
Is it possible to specify a denylist/inverse of listed targets when trying to build?

EG, current default behavior of:

`ninja -C <build dir> [targets]` is to build all the targets given. When no target is given, it builds the default target in the build dir (build.ninja file lists this, IIUC). This is effectively an intersect of available targets and the listed targets

Is it possible to produce an "inverse" of the given targets? Behavior would be something like:
`ninja -C <build dir> --inverse [target]` would build all available targets except the listed targets? This would be like an XOR or symmetric difference of all available targets and the listed targets (essentially, a denylist).

Is this currently possible?

David Turner

unread,
Jul 1, 2022, 10:54:04 AM7/1/22
to Rohan Pavone, ninja-build
Le ven. 1 juil. 2022 à 08:42, 'Rohan Pavone' via ninja-build <ninja...@googlegroups.com> a écrit :
Is it possible to specify a denylist/inverse of listed targets when trying to build?

EG, current default behavior of:

`ninja -C <build dir> [targets]` is to build all the targets given. When no target is given, it builds the default target in the build dir (build.ninja file lists this, IIUC). This is effectively an intersect of available targets and the listed targets

Technically, if one or your targets is not in the graph, Ninja will give you an error, so it is more a subset than an intersect.
 
Is it possible to produce an "inverse" of the given targets? Behavior would be something like:
`ninja -C <build dir> --inverse [target]` would build all available targets except the listed targets? This would be like an XOR or symmetric difference of all available targets and the listed targets (essentially, a denylist).

Is this currently possible?

This is not directly possible, but you can use `ninja -t targets` to print all top-level targets in the graph, remove everything you don't want with a script, then pass the result to another ninja call. You can also use `ninja -t targets all` to print all targets instead.
I think that should cover your use case easily (as it also handles intersections properly) without adding extra code to Ninja.



--
You received this message because you are subscribed to the Google Groups "ninja-build" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ninja-build...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ninja-build/cf187140-27e0-4900-b7f2-db65c5f8afadn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages