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

[Feature Request] Allow 'ninja -t compdb' accept one target #1544

Open
lk-chen opened this issue Mar 24, 2019 · 6 comments · May be fixed by #2497
Open

[Feature Request] Allow 'ninja -t compdb' accept one target #1544

lk-chen opened this issue Mar 24, 2019 · 6 comments · May be fixed by #2497
Labels

Comments

@lk-chen
Copy link

lk-chen commented Mar 24, 2019

Currently, compdb iterates all edges. I am proposing an option to accept one target name, and only iterate edges it depends on.

e.g.
ninja -t compdb -a //foo:main cc cxx

New help message will be:
usage: ninja -t compdb [options] [target] [rules]

options:
-x expand @rspfile style response file invocations
-a accept one target name, and only dump compilation database for this target

@lk-chen lk-chen changed the title Allow 'ninja -t compdb' accept one target [Feature Request] Allow 'ninja -t compdb' accept one target Mar 24, 2019
@jhasse jhasse added the feature label Mar 24, 2019
@lk-chen
Copy link
Author

lk-chen commented Mar 24, 2019

CI fails due to gcc 4.8.4 didn't enable c++11, any suggestions?
https://travis-ci.org/ninja-build/ninja/jobs/510697426

@jhasse
Copy link
Collaborator

jhasse commented Mar 24, 2019

Ninja isn't using C++11 yet. I would use std::set instead of std::unordered_set in your code.

@Yogaht
Copy link

Yogaht commented Sep 19, 2022

@jhasse Hi, is this feature supported now? I think it's very useful expecially in large system.

@mathstuf
Copy link
Contributor

The issue is still open and the linked PR is not merged…so I'd say "no, not yet".

@itavero
Copy link

itavero commented Dec 1, 2022

I just wanted to add a use case that we have for such a feature: we use CMake (with ninja) and also have some static code analysis tools that work off of a compilation database file.
This worked well initially, as we could tell CMake to simply generate a compilation database containing all sources in the project.

However, now we are taking in more external projects, which still get compiled (doing a lot of bare metal embedded stuff, so we have different compile/linker options depending on the targets, making it difficult to maintain a set of precompiled binaries for all external dependencies/projects).
This also means that they are included in the compilation database, but for our SCA we don't really care about these sources (or have different rules for them).

Currently this means configuring the SCA tools to exclude sources from these external projects.
This however is difficult to maintain and I'd rather explicitly include the targets we want to check.
This is where this feature would come into play. Since the rules in Ninja are generated (by CMake), basically the only known reference I have is the target name.
If I could pass this to ninja -t compdb than I can generate specific compilation databases for the SCA tools.

Is there anything I can do to hopefully help move this request (and the linked PR) forward?

@jhasse
Copy link
Collaborator

jhasse commented Dec 1, 2022

Is there anything I can do to hopefully help move this request (and the linked PR) forward?

Yes: I've left some comments in the PR which weren't addressed. You could create a new PR based on the existing one which addresses those or first add some comments if you think my concerns are justified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants