C++ Logo

sg15

Advanced search

Re: Header units again.

From: Ben Boeckel <ben.boeckel_at_[hidden]>
Date: Thu, 13 Oct 2022 17:16:32 -0400
On Thu, Oct 13, 2022 at 19:37:40 +0000, Gabriel Dos Reis wrote:
> > Yes, but we can't then add a rule to `build.ninja` to say "hey, make a
> > BMI of this header file no one knew about until we started building
> > stuff".
>
> I suppose that raises the question: at what point do you run the
> dependency scanner? During build?

Yes, it has to be run during the build. Consider the following cases:

- generated source files

Source files which are built during the build by tools built during the
build cannot exist when CMake runs the first time. Doing some kind of
"phased generation" adds in a new build graph to consider for each phase
when considering "is this robust?".

Even if we did scan files that exist now and wait on those that will be
generated later, we cannot say "module X doesn't exist" until we scan
all of those generated sources to know that it doesn't come from there.

- changing a source file

With pre-scanning, changing a source file would require rerunning CMake
and regenerating the build scripts on any source file that *might*
import or export a module to update the graph in case its module
dependencies change. This is not something a discrete build system can
support (a continuous build tool might theoretically be able to adapt to
source changes and build the in-memory graph up again though I worry
about behaviors of invalid syntax, partial writes, etc. in these cases).

--Ben

Received on 2022-10-13 21:16:34