Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

csmoe
Copy link

@csmoe csmoe commented Aug 30, 2023

Fix #1544

Cherry-picked #1546 and addressed the comments.
May I have your code review @jhasse ? Thanks

@csmoe csmoe force-pushed the compdb-target branch 6 times, most recently from 3eb2357 to 96ebb17 Compare August 30, 2023 16:13
src/ninja.cc Outdated Show resolved Hide resolved
@csmoe csmoe force-pushed the compdb-target branch 2 times, most recently from 0655263 to cafc5eb Compare September 5, 2023 06:06
@jhasse jhasse added this to the 1.12.0 milestone Sep 5, 2023
src/ninja.cc Outdated Show resolved Hide resolved
src/ninja.cc Outdated Show resolved Hide resolved
src/ninja.cc Outdated Show resolved Hide resolved
src/ninja.cc Outdated Show resolved Hide resolved
src/ninja.cc Outdated Show resolved Hide resolved
src/ninja.cc Outdated Show resolved Hide resolved
    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]>
@csmoe
Copy link
Author

csmoe commented Jan 28, 2024

@digit-google thanks for your comments, they're addressed.

@digit-google
Copy link
Contributor

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?

Copy link
Collaborator

@jhasse jhasse left a 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) {
Copy link
Collaborator

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) {
Copy link
Collaborator

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'},
Copy link
Collaborator

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) {
Copy link
Collaborator

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>
Copy link
Collaborator

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.

@jhasse jhasse modified the milestones: 1.12.0, 1.13.0 Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Allow 'ninja -t compdb' accept one target
3 participants