kbknapp / cargo-graph

A cargo subcommand for creating GraphViz DOT files and dependency graphs
BSD 3-Clause "New" or "Revised" License
216 stars 16 forks source link

"duplicated" regular and dev-dependencies are not separated #15

Closed bluss closed 8 years ago

bluss commented 8 years ago

I've got a crate with a mess like this:

[dependencies]
memchr = "0.1"
quickcheck = { version = "0.2", optional = true }
itertools = { version = "0.4", optional = true }
odds = { version = "0.2", optional = true }
jetscii = {version = "0.3", features= ["unstable"], optional = true }

[dev-dependencies]
regex = "0.1"
itertools = "0.4"
odds = "0.2"

custom_derive = "0.1"
newtype_derive = "0.1"
rand = "0.3.10"
bluss commented 8 years ago

Hum, my output was actually this:

command: --optional-line-style dotted --dev-line-style dashed > out.dot

digraph dependencies {
        N0[label="twoway"];
        N1[label="jetscii"];
        N2[label="quickcheck"];
        N3[label="rand"];
        N4[label="advapi32-sys"];
        N5[label="winapi"];
        N6[label="winapi-build"];
        N7[label="libc"];
        N8[label="log"];
        N0 -> N1[label="",style=dotted];
        N0 -> N2[label="",style=dotted];
        N0 -> N3[label="",style=dotted];
        N0 -> N4[label="",style=dotted];
        N0 -> N5[label="",style=dotted];
        N0 -> N6[label="",style=dotted];
        N0 -> N1[label="",style=dotted];
        N0 -> N7[label="",style=dotted];
        N0 -> N4[label="",style=dotted];
        N0 -> N8[label="",style=dotted];
        N0 -> N9[label=""];
        N5 -> N8[label="",style=dotted];
        N9 -> N3[label="",style=dotted];
}

It doesn't make any sense? :smile:

kbknapp commented 8 years ago

Yep, that doesn't make sense :smile:

I think before I was operating under the (old?) assumption that dev-deps couldn't be optional. Let me investigate some and see what I can find!

kbknapp commented 8 years ago

@bluss so part of the issue is dev-deps are ignored by default which is somewhat causing this bug. I'm assuming you're talking about your scratchspace repo (which looks awesome btw :wink:) so I cloned at did a

$ cargo graph --optional-line-style dashed --dev-deps true 
digraph dependencies {
    N0[label="twoway"];
    N1[label="itertools"];
    N2[label="jetscii"];
    N3[label="memchr"];
    N4[label="odds"];
    N5[label="quickcheck"];
    N6[label="custom_derive"];
    N7[label="newtype_derive"];
    N8[label="rand"];
    N9[label="regex"];
    N10[label="advapi32-sys"];
    N11[label="winapi"];
    N12[label="winapi-build"];
    N13[label="aho-corasick"];
    N14[label="libc"];
    N15[label="log"];
    N16[label="unreachable"];
    N17[label="regex-syntax"];
    N18[label="void"];
    N0 -> N1[label=""];
    N0 -> N2[label="",style=dashed];
    N0 -> N3[label=""];
    N0 -> N4[label=""];
    N0 -> N5[label="",style=dashed];
    N0 -> N6[label=""];
    N0 -> N1[label=""];
    N0 -> N7[label=""];
    N0 -> N4[label=""];
    N0 -> N8[label="",style=dashed];
    N0 -> N9[label=""];
    N10 -> N11[label="",style=dashed];
    N10 -> N12[label="",style=dashed];
    N13 -> N3[label=""];
    N15 -> N14[label="",style=dashed];
    N3 -> N14[label="",style=dashed];
    N4 -> N16[label=""];
    N5 -> N15[label="",style=dashed];
    N5 -> N8[label="",style=dashed];
    N8 -> N10[label="",style=dashed];
    N8 -> N14[label="",style=dashed];
    N8 -> N11[label="",style=dashed];
    N9 -> N13[label=""];
    N9 -> N3[label=""];
    N9 -> N17[label=""];
    N16 -> N18[label=""];
}

Which looks much more correct (also when viewing as a PNG). Although the dev deps are still duplicated. Also when doing both dev deps dotted, and optional deps dashed it creates some confusion because of the duplication. So this is a bug.

Since dev-deps apparently can be optional, do you know of any documentation pointing to order of precedence?

kbknapp commented 8 years ago

Also, you can color code to better see what's going on..

$ cargo graph --optional-line-style dashed --dev-deps true --dev-line-color red | dot -Tpng > out.png
bluss commented 8 years ago

Ok that picture makes more sense, still with duplicated edges.

dev-deps can't be optional at this point, only regular deps can be.

bluss commented 8 years ago

btw, notice that twoway -> memchr should not be red, it's a mandatory regular dependency. I'd expect it to be black ?

kbknapp commented 8 years ago

yeah I noticed that too, digging in now to see what's going on.

kbknapp commented 8 years ago

@bluss #16 fixes this.

bluss commented 8 years ago

Nice! I'll check it out