Skip to content
This repository has been archived by the owner on May 12, 2020. It is now read-only.

Filtering on dev-dependencies not working #4

Closed
bvssvni opened this issue Nov 12, 2015 · 9 comments
Closed

Filtering on dev-dependencies not working #4

bvssvni opened this issue Nov 12, 2015 · 9 comments

Comments

@bvssvni
Copy link
Contributor

bvssvni commented Nov 12, 2015

cargo graph --dev-deps=false | dot -Tpng > Cargo.png

Also tried:

cargo graph --dev-color red | dot -Tpng > Cargo.png

@bvssvni
Copy link
Contributor Author

bvssvni commented Nov 12, 2015

Tested on Conrod.

The dev dependencies are includes in the graph appear similar to normal dependencies.

@bvssvni
Copy link
Contributor Author

bvssvni commented Nov 12, 2015

Here is an image of the generated graph with the command:

cargo graph --manifest-file Cargo.toml --dev-deps=false | dot -Tpng > Cargo.png

cargo

@bvssvni
Copy link
Contributor Author

bvssvni commented Nov 12, 2015

Project::parse_root_deps looks right.

I wonder whether it should be any filtering in Project::parse_lock_file or the filtering is done when rendering the graph.

@bvssvni
Copy link
Contributor Author

bvssvni commented Nov 12, 2015

Seems that all are added as build dependencies https://github.com/kbknapp/cargo-graph/blob/master/src/project.rs#L111

@hauleth
Copy link

hauleth commented Nov 12, 2015

Same here

Octavo:

image

@bvssvni
Copy link
Contributor Author

bvssvni commented Nov 12, 2015

I think that a simple for loop might not be enough to do the filtering.

  • All packages depended on by a dev-dependency should count as DevKind::Dev unless it is depended on by a dependency
  • Packages might come in any order in Cargo.lock

I suggest the following:

  1. Loop through all packages, build a HashMap storing Option<DevKind> per package name.
  2. Loop while any entry in the HashMap gets changes, checking each dependency per package.
  3. The final loop, filtering using the HashMap.

@bvssvni
Copy link
Contributor Author

bvssvni commented Nov 12, 2015

The algorithm will "fill" the graph similar to a paint bucket algorithm, marking the dev-dependencies but overriding them as dependencies if they get are depended on by a normal dependency.

@kbknapp
Copy link
Owner

kbknapp commented Nov 13, 2015

Thanks for all the input! I'll start looking into this as well. Since I don't use many dev-deps it's difficult to test without picking crates I'm less familiar with. If you find the issue before me, put in a PR, I'm all about some contributors 👍

@kbknapp
Copy link
Owner

kbknapp commented Nov 13, 2015

@bvssvni I think you're correct

EDIT: closed by mistake

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants