Hi,
On Sun, Oct 20, 2024 at 23:04:56 -0700, Elliot Goodrich wrote:
> I'd like to share my project trimja
> <
https://github.com/elliotgoodrich/trimja> - a tool to cut down a Ninja
> build file to only the build commands that depend on or are needed by a set
> of paths. This can be used to reduce the amount of work done in CI by only
> building things that could be affected by the files changed by the pull
> request.
>
> The main restriction is that you need access to the .ninja_log and
> .ninja_deps files from a full, successful build in order for trimja to
> work. There's an implementation of a Github action to do this -
> trimja-action <
https://github.com/elliotgoodrich/trimja-action>.
Neat tool. Alas, needing a deps and log from a previous build means that
it is difficult to use from CI (paths need pinned, build configuration
needs to be compared, etc.). But for "simple" projects without 100s of
options, this sounds like a good tool to help out with that.
> If trimja + file hashes <
https://github.com/ninja-build/ninja/issues/1459>
> were both added to ninja, then we'd be able to dynamically remove
> additional work from the graph in situations were a file was modified but
> in a way that did not affect its output, e.g. changing comments in a C/C++
> source file.
Note that comments can affect output, particularly if debugging is
included as source locations can change based on comment content. Note
that you also might want to rerun due to comment modification for things
like `clang`'s `-Wdocumentation` flag that issues diagnostics based on
Doxygen syntax in comments.
I don't think a straight content hash is as useful as some kind of
"fingerprint" extractor that can actually ignore irrelevant changes to
the file (e.g., diffing a comment-aware AST to see that
if (foo)
bar;
and
if (foo) {
bar;
}
are the same (of course, debugging info can make even this a semantic
change, so the command line in use also matters).
See this issue:
https://github.com/ninja-build/ninja/issues/1459
Thanks,
--Ben