-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make the output of ninja -t inputs
deterministic
#2075
Conversation
c0f6f9e
to
e351648
Compare
This is a followup to the very uesful #1730 which just got merged. Note that this doesn't change the content of the output, though the documentation states that this tool is supposed to list all inputs necessary for a group of targets, the implementation currently only lists explicit inputs, not implicit and order-only ones (or those stored in .ninja_deps, but that's probably ok). Maybe a different issue though. |
LGTM @naarcini what do you think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally LGTM % a couple of suggestions
I have added a unit-test for Edge::CollectInputs. It seems there are no good ways to test tools though. Should we want to add these, should we go with regression tests (e.g. scripts that invoke Ninja with pre-determined build plans, and verify behaviour), or refactor ninja.cc to make tools unit-testable? Probably not in this PR though :-) |
Some very basic regression tests are in Line 117 in cd967ab
Making tools unit-testable is probably a good idea though. |
e351648
to
222497a
Compare
Thanks, I could add a regression test to I'm still concerned about the fact that we do not include implicit inputs in the the tool's output. The fact that they are not listed in the command line itself doesn't make them less important. And I don't see a use case where you would want only the explicit inputs anyway. should we add an "explicit-inputs" tool for these otherwise? |
222497a
to
e2708f4
Compare
Friendly ping. Actually, we have a use case where we need to really get all inputs, including order-only ones to pick up the right set of files from the build directory after an incremental build (i.e. this allows us to skip any stale outputs from a previous build, since @naarcini i, can you tell us why you designed the tool in this way? I'm curious about your use case. Otherwise, what would be the best way to configure a tool for multiple types of outputs? I.e. Multiple tool names (e.g. 'explicit-inputs', 'explicit-and-implicit-inputs', 'all-inputs') or additional flags (e.g. |
@digit-google In my specific use case, we only needed the explicit dependencies. At the time, I was trying to improve upon a project in Chromium that audits certain metadata in code (Network Traffic Annotation Auditor). In that case, all I needed was specifically the code files that are used to build a particular target. Since Chromium's tooling does a pretty good job of explicitly listing all dependencies, I found that "explicit" was enough to fulfill this requirement. I'm not opposed to adding an additional flag or changing the default behavior to include more information. That'd still work fine for my use case and I suspect it'd work fine for most other peoples' use cases too. If I get a vote, I vote for using an additional flag instead of multiple tool names :) |
Thanks, I'll update the code to add a flag plus the proper checks tomorrow :-) |
e2708f4
to
289a858
Compare
Latest update adds |
56ba9a2
to
1f780ae
Compare
Friendly ping, anything else to get this merged? I would really prefer if the existing behavior was not part of the next 1.11 release :-/ |
The Also:
Sounds like a bug of the cleandead tool? |
Well, I have a use case where I need all implicit + explicit dependencies, and @naarcini only wants the explicit ones, so a This is not really a bug in This tool would be one of the different ways we want to work around this problem. I'll update the PR to make the `--type flag its own commit. |
1f780ae
to
4e06491
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and @naarcini only wants the explicit ones
If I understood him correctly, he wouldn't mind the implicit ones, but doesn't need them?
The extra InputsType
struct is quite a lot of code and I only merged the inputs tool because it was such a small change.
src/ninja.cc
Outdated
" -t TOOL run a subtool (use '-t list' to list subtools)\n" | ||
" terminates toplevel options; further flags are passed to the tool\n" | ||
" -w FLAG adjust warnings (use '-w list' to list warnings)\n", | ||
kNinjaVersion, config.parallelism); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, because I had changed this text a little bit in a previous version of this pull request, and clang-format
hapilly re-indented everything. I later removed the change, but without the reformatting, sorry. This is now fixed, and I have added //clang-format off
and //clang-format on
directives to avoid that this happens again in the future, unless intended of course.
src/ninja.cc
Outdated
#include "clean.h" | ||
#include "debug_flags.h" | ||
#include "depfile_parser.h" | ||
#include "deps_log.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason for this reordering?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-format
did it, I swear! :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Can you still move it back? Best to avoid unnecessary noise in the diff.
4e06491
to
40dc0c7
Compare
src/ninja.cc
Outdated
#include "clean.h" | ||
#include "debug_flags.h" | ||
#include "depfile_parser.h" | ||
#include "deps_log.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-format
did it, I swear! :-)
src/ninja.cc
Outdated
" -t TOOL run a subtool (use '-t list' to list subtools)\n" | ||
" terminates toplevel options; further flags are passed to the tool\n" | ||
" -w FLAG adjust warnings (use '-w list' to list warnings)\n", | ||
kNinjaVersion, config.parallelism); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, because I had changed this text a little bit in a previous version of this pull request, and clang-format
hapilly re-indented everything. I later removed the change, but without the reformatting, sorry. This is now fixed, and I have added //clang-format off
and //clang-format on
directives to avoid that this happens again in the future, unless intended of course.
I pushed a new version with the changes you requested 10 days ago, but forgot to submit my review comments, which I just did. Sorry. Let me know if there is something else to do to get this submitted. Thanks. |
40dc0c7
to
bde3f2f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think that the tool shouldn't include the --type
option and always print all inputs, at least for 1.11.0.
src/ninja.cc
Outdated
#include "clean.h" | ||
#include "debug_flags.h" | ||
#include "depfile_parser.h" | ||
#include "deps_log.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Can you still move it back? Best to avoid unnecessary noise in the diff.
bde3f2f
to
3199119
Compare
Done, let me know what you think :) |
This sorts the output of `ninja -t inputs` to make it deterministic and remove duplicates, and adds a regression test in output_test.py + Ensure all inputs are listed, not only explicit ones. + Document the `inputs` tool in doc/manual.asciidoc.
3199119
to
65c82b7
Compare
I have refactored the two commits so that the first one would print all inputs in a deterministic way (and update the documentation), while the second one adds the |
65c82b7
to
988c847
Compare
Done, the current PR only contains the fix to the output. The |
Thanks! |
This sorts the output of
ninja -t inputs
to make itdeterministic and remove duplicates.