-
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
Allow 'ninja -t compdb' accept targets #2319
base: master
Are you sure you want to change the base?
Conversation
3eb2357
to
96ebb17
Compare
0655263
to
cafc5eb
Compare
Test: ./ninja -t compdb --target wrong_target (fail) ./ninja -t compdb --target test_target (empty due to lack of rules) ./ninja -t compdb --target ninja,ninja_test cc cxx (ok) ./ninja -t compdb --target test_target cc cxx (ok) ./ninja -t compdb cxx (ok, regression test) ./ninja ninja_test && ./ninja_test (passed) Co-authored-by: Linkun Chen <[email protected]> Co-authored-by: csmoe <[email protected]>
@digit-google thanks for your comments, they're addressed. |
This looks good to me, but will require @jhasse 's approval. Can I ask you to add some regression test in misc/output_test.py for this feature though? |
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.
Thanks for having another go at this :)
for (vector<Edge*>::iterator e = state_.edges_.begin(); | ||
e != state_.edges_.end(); ++e) { | ||
if ((*e)->inputs_.empty()) | ||
for (Edge* e: edges_to_process) { |
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.
Please add a space before :
(or does our .clang-format suggest otherwise?).
return 1; | ||
} | ||
} | ||
if (user_interested_edges.size() > 0) { |
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.
Please use !user_interested_edges.empty()
instead.
@@ -920,19 +949,51 @@ int NinjaMain::ToolCompilationDatabase(const Options* options, int argc, | |||
|
|||
optind = 1; | |||
int opt; | |||
while ((opt = getopt(argc, argv, const_cast<char*>("hx"))) != -1) { | |||
const option long_options[] = { | |||
{"target", required_argument, NULL, 't'}, |
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.
Please use nullptr
instead of NULL
.
}; | ||
|
||
std::vector<Edge*> edges_to_process = state_.edges_; | ||
while ((opt = getopt_long(argc, argv, "x:", long_options, NULL)) != -1) { |
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 "x:"
instead of "hx"
?
@@ -17,6 +17,9 @@ | |||
#include <stdio.h> | |||
#include <stdlib.h> | |||
#include <string.h> | |||
#include <sstream> | |||
#include <set> | |||
#include <assert.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.
Please use #include <cassert>
instead.
Fix #1544
Cherry-picked #1546 and addressed the comments.
May I have your code review @jhasse ? Thanks