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

Add a new ninja tool: finddeps. #723

Closed
wants to merge 1 commit into from
Closed

Conversation

ar1nd4m
Copy link

@ar1nd4m ar1nd4m commented Mar 26, 2014

This will find and output the dependency path from one target to
another.

It uses DFS to search for nodes starting from the [from] node, and then
going up the dependency tree until it finds the first path to the [to]
node.

Due to memoization, it's not trivially possible to find all paths, and
also by definition this returns the smallest path.

A sample output when run on the ninja project is:

$ ninja -t finddeps ninja src/browse.cc
Path: ninja
    > build/libninja.a
    > build/browse.o
    > src/browse.cc

$

I've found this very useful navigating the dependency tree in order to break dependency of one target from another.

This will find and output the dependency path from one target to
another.

It uses DFS to search for nodes starting from the [from] node, and then
going up the dependency tree until it finds the first path to the [to]
node.

Due to memoization, it's not trivially possible to find all paths, and
also by definition this returns the smallest path.

A sample output when run on the ninja project is:

```
$ ninja -t finddeps ninja src/browse.cc
Path: ninja
    > build/libninja.a
    > build/browse.o
    > src/browse.cc

$
```
@buildhive
Copy link

Evan Martin » ninja #697 SUCCESS
This pull request looks good
(what's this?)

@evmar evmar added the feature label Nov 11, 2015
@evmar
Copy link
Collaborator

evmar commented Nov 11, 2015

By the way, you can also use -d explain if you're trying to diagnose why something is being built.

@ar1nd4m
Copy link
Author

ar1nd4m commented Nov 12, 2015

I haven't used ninja for a while now. If similar features have gone in, this is probably outdated. I will let you deal with the patch as you feel best, but do let me know if you need any help from my side.

However, last I checked, -d explain option was present, but it was not sufficient for my task. I was trying to see all the modules that depend on a particular library, in my attempt to eradicate that library.

@evmar
Copy link
Collaborator

evmar commented Nov 15, 2015

Another idea is that we already have this support for the "query" tool and the graph so it's sorta something that belongs in there.

I have experience with this kind of dependency-breaking ("why does module X pull in module Y?") with Google's build system (now open source as "bazel") and I know it has a pretty sophisticated querying language. I worry if we provide some functionality now we'll slowly slide into their complex requirements.

Which makes me think: perhaps this kind of logic belongs in the generator program, since it ought to have more knowledge about relationships between parts of the project.

@jhasse
Copy link
Collaborator

jhasse commented Apr 11, 2019

In order to reduce the number of open PRs I'm closing this one, feel free to reopen if you still think this should be merged.

@jhasse jhasse closed this Apr 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants