├── .gitignore ├── .travis.yml ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── README.md ├── etc ├── cargo-dot.dot ├── cargo-dot.png ├── servo.dot └── servo.png └── src └── main.rs /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: rust 2 | rust: 3 | - nightly 4 | - beta 5 | - stable 6 | 7 | matrix: 8 | allow_failures: 9 | - rust: nightly 10 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | [root] 2 | name = "cargo-dot" 3 | version = "0.1.0" 4 | dependencies = [ 5 | "cargo 0.4.0 (git+https://github.com/rust-lang/cargo)", 6 | "docopt 0.6.67 (registry+https://github.com/rust-lang/crates.io-index)", 7 | "dot 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", 8 | "rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", 9 | ] 10 | 11 | [[package]] 12 | name = "advapi32-sys" 13 | version = "0.1.2" 14 | source = "registry+https://github.com/rust-lang/crates.io-index" 15 | dependencies = [ 16 | "winapi 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", 17 | "winapi-build 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 18 | ] 19 | 20 | [[package]] 21 | name = "aho-corasick" 22 | version = "0.3.0" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | dependencies = [ 25 | "memchr 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", 26 | ] 27 | 28 | [[package]] 29 | name = "bitflags" 30 | version = "0.1.1" 31 | source = "registry+https://github.com/rust-lang/crates.io-index" 32 | 33 | [[package]] 34 | name = "cargo" 35 | version = "0.4.0" 36 | source = "git+https://github.com/rust-lang/cargo#0faebf2e5493b54fba3da81fb805c6a4989ab586" 37 | dependencies = [ 38 | "advapi32-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", 39 | "curl 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", 40 | "docopt 0.6.67 (registry+https://github.com/rust-lang/crates.io-index)", 41 | "env_logger 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 42 | "filetime 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", 43 | "flate2 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)", 44 | "git2 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", 45 | "git2-curl 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", 46 | "glob 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", 47 | "kernel32-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", 48 | "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", 49 | "libgit2-sys 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", 50 | "log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 51 | "num_cpus 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", 52 | "regex 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", 53 | "registry 0.1.0 (git+https://github.com/rust-lang/cargo)", 54 | "rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", 55 | "semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)", 56 | "tar 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)", 57 | "term 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", 58 | "threadpool 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", 59 | "time 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", 60 | "toml 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", 61 | "url 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", 62 | "winapi 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)", 63 | ] 64 | 65 | [[package]] 66 | name = "curl" 67 | version = "0.2.10" 68 | source = "registry+https://github.com/rust-lang/crates.io-index" 69 | dependencies = [ 70 | "curl-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", 71 | "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", 72 | "log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 73 | "openssl-sys 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", 74 | "url 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", 75 | ] 76 | 77 | [[package]] 78 | name = "curl-sys" 79 | version = "0.1.24" 80 | source = "registry+https://github.com/rust-lang/crates.io-index" 81 | dependencies = [ 82 | "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", 83 | "libz-sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", 84 | "openssl-sys 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", 85 | "pkg-config 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", 86 | ] 87 | 88 | [[package]] 89 | name = "docopt" 90 | version = "0.6.67" 91 | source = "registry+https://github.com/rust-lang/crates.io-index" 92 | dependencies = [ 93 | "regex 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", 94 | "rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", 95 | "strsim 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", 96 | ] 97 | 98 | [[package]] 99 | name = "dot" 100 | version = "0.0.4" 101 | source = "registry+https://github.com/rust-lang/crates.io-index" 102 | 103 | [[package]] 104 | name = "env_logger" 105 | version = "0.3.1" 106 | source = "registry+https://github.com/rust-lang/crates.io-index" 107 | dependencies = [ 108 | "log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 109 | "regex 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)", 110 | ] 111 | 112 | [[package]] 113 | name = "filetime" 114 | version = "0.1.4" 115 | source = "registry+https://github.com/rust-lang/crates.io-index" 116 | 117 | [[package]] 118 | name = "flate2" 119 | version = "0.2.7" 120 | source = "registry+https://github.com/rust-lang/crates.io-index" 121 | dependencies = [ 122 | "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", 123 | "miniz-sys 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", 124 | ] 125 | 126 | [[package]] 127 | name = "gcc" 128 | version = "0.3.9" 129 | source = "registry+https://github.com/rust-lang/crates.io-index" 130 | 131 | [[package]] 132 | name = "git2" 133 | version = "0.2.13" 134 | source = "registry+https://github.com/rust-lang/crates.io-index" 135 | dependencies = [ 136 | "bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", 137 | "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", 138 | "libgit2-sys 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", 139 | "url 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", 140 | ] 141 | 142 | [[package]] 143 | name = "git2-curl" 144 | version = "0.2.4" 145 | source = "registry+https://github.com/rust-lang/crates.io-index" 146 | dependencies = [ 147 | "curl 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", 148 | "git2 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)", 149 | "log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", 150 | "url 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", 151 | ] 152 | 153 | [[package]] 154 | name = "glob" 155 | version = "0.2.10" 156 | source = "registry+https://github.com/rust-lang/crates.io-index" 157 | 158 | [[package]] 159 | name = "kernel32-sys" 160 | version = "0.1.3" 161 | source = "registry+https://github.com/rust-lang/crates.io-index" 162 | dependencies = [ 163 | "winapi 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", 164 | "winapi-build 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", 165 | ] 166 | 167 | [[package]] 168 | name = "libc" 169 | version = "0.1.8" 170 | source = "registry+https://github.com/rust-lang/crates.io-index" 171 | 172 | [[package]] 173 | name = "libgit2-sys" 174 | version = "0.2.19" 175 | source = "registry+https://github.com/rust-lang/crates.io-index" 176 | dependencies = [ 177 | "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", 178 | "libssh2-sys 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)", 179 | "libz-sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", 180 | "openssl-sys 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", 181 | "pkg-config 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", 182 | ] 183 | 184 | [[package]] 185 | name = "libressl-pnacl-sys" 186 | version = "2.1.6" 187 | source = "registry+https://github.com/rust-lang/crates.io-index" 188 | dependencies = [ 189 | "pnacl-build-helper 1.4.6 (registry+https://github.com/rust-lang/crates.io-index)", 190 | ] 191 | 192 | [[package]] 193 | name = "libssh2-sys" 194 | version = "0.1.26" 195 | source = "registry+https://github.com/rust-lang/crates.io-index" 196 | dependencies = [ 197 | "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", 198 | "libz-sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", 199 | "openssl-sys 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", 200 | "pkg-config 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", 201 | ] 202 | 203 | [[package]] 204 | name = "libz-sys" 205 | version = "0.1.6" 206 | source = "registry+https://github.com/rust-lang/crates.io-index" 207 | dependencies = [ 208 | "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", 209 | "pkg-config 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", 210 | ] 211 | 212 | [[package]] 213 | name = "log" 214 | version = "0.3.1" 215 | source = "registry+https://github.com/rust-lang/crates.io-index" 216 | dependencies = [ 217 | "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", 218 | ] 219 | 220 | [[package]] 221 | name = "matches" 222 | version = "0.1.2" 223 | source = "registry+https://github.com/rust-lang/crates.io-index" 224 | 225 | [[package]] 226 | name = "memchr" 227 | version = "0.1.3" 228 | source = "registry+https://github.com/rust-lang/crates.io-index" 229 | dependencies = [ 230 | "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", 231 | ] 232 | 233 | [[package]] 234 | name = "miniz-sys" 235 | version = "0.1.5" 236 | source = "registry+https://github.com/rust-lang/crates.io-index" 237 | dependencies = [ 238 | "gcc 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", 239 | "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", 240 | ] 241 | 242 | [[package]] 243 | name = "num_cpus" 244 | version = "0.2.6" 245 | source = "registry+https://github.com/rust-lang/crates.io-index" 246 | dependencies = [ 247 | "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", 248 | ] 249 | 250 | [[package]] 251 | name = "openssl-sys" 252 | version = "0.6.4" 253 | source = "registry+https://github.com/rust-lang/crates.io-index" 254 | dependencies = [ 255 | "gcc 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", 256 | "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", 257 | "libressl-pnacl-sys 2.1.6 (registry+https://github.com/rust-lang/crates.io-index)", 258 | "pkg-config 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", 259 | ] 260 | 261 | [[package]] 262 | name = "pkg-config" 263 | version = "0.3.5" 264 | source = "registry+https://github.com/rust-lang/crates.io-index" 265 | 266 | [[package]] 267 | name = "pnacl-build-helper" 268 | version = "1.4.6" 269 | source = "registry+https://github.com/rust-lang/crates.io-index" 270 | dependencies = [ 271 | "tempdir 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", 272 | ] 273 | 274 | [[package]] 275 | name = "rand" 276 | version = "0.3.8" 277 | source = "registry+https://github.com/rust-lang/crates.io-index" 278 | dependencies = [ 279 | "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", 280 | ] 281 | 282 | [[package]] 283 | name = "regex" 284 | version = "0.1.41" 285 | source = "registry+https://github.com/rust-lang/crates.io-index" 286 | dependencies = [ 287 | "aho-corasick 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", 288 | "memchr 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", 289 | "regex-syntax 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", 290 | ] 291 | 292 | [[package]] 293 | name = "regex-syntax" 294 | version = "0.2.0" 295 | source = "registry+https://github.com/rust-lang/crates.io-index" 296 | 297 | [[package]] 298 | name = "registry" 299 | version = "0.1.0" 300 | source = "git+https://github.com/rust-lang/cargo#0faebf2e5493b54fba3da81fb805c6a4989ab586" 301 | dependencies = [ 302 | "curl 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", 303 | "rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", 304 | ] 305 | 306 | [[package]] 307 | name = "rustc-serialize" 308 | version = "0.3.15" 309 | source = "registry+https://github.com/rust-lang/crates.io-index" 310 | 311 | [[package]] 312 | name = "semver" 313 | version = "0.1.20" 314 | source = "registry+https://github.com/rust-lang/crates.io-index" 315 | 316 | [[package]] 317 | name = "strsim" 318 | version = "0.3.0" 319 | source = "registry+https://github.com/rust-lang/crates.io-index" 320 | 321 | [[package]] 322 | name = "tar" 323 | version = "0.2.14" 324 | source = "registry+https://github.com/rust-lang/crates.io-index" 325 | dependencies = [ 326 | "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", 327 | ] 328 | 329 | [[package]] 330 | name = "tempdir" 331 | version = "0.3.4" 332 | source = "registry+https://github.com/rust-lang/crates.io-index" 333 | dependencies = [ 334 | "rand 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", 335 | ] 336 | 337 | [[package]] 338 | name = "term" 339 | version = "0.2.11" 340 | source = "registry+https://github.com/rust-lang/crates.io-index" 341 | dependencies = [ 342 | "kernel32-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", 343 | "winapi 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", 344 | ] 345 | 346 | [[package]] 347 | name = "threadpool" 348 | version = "0.1.4" 349 | source = "registry+https://github.com/rust-lang/crates.io-index" 350 | 351 | [[package]] 352 | name = "time" 353 | version = "0.1.31" 354 | source = "registry+https://github.com/rust-lang/crates.io-index" 355 | dependencies = [ 356 | "kernel32-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", 357 | "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", 358 | "winapi 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", 359 | ] 360 | 361 | [[package]] 362 | name = "toml" 363 | version = "0.1.21" 364 | source = "registry+https://github.com/rust-lang/crates.io-index" 365 | dependencies = [ 366 | "rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", 367 | ] 368 | 369 | [[package]] 370 | name = "url" 371 | version = "0.2.36" 372 | source = "registry+https://github.com/rust-lang/crates.io-index" 373 | dependencies = [ 374 | "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", 375 | "rustc-serialize 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", 376 | ] 377 | 378 | [[package]] 379 | name = "winapi" 380 | version = "0.1.23" 381 | source = "registry+https://github.com/rust-lang/crates.io-index" 382 | dependencies = [ 383 | "libc 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", 384 | ] 385 | 386 | [[package]] 387 | name = "winapi" 388 | version = "0.2.1" 389 | source = "registry+https://github.com/rust-lang/crates.io-index" 390 | 391 | [[package]] 392 | name = "winapi-build" 393 | version = "0.1.0" 394 | source = "registry+https://github.com/rust-lang/crates.io-index" 395 | 396 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "cargo-dot" 3 | version = "0.1.0" 4 | authors = ["Max New "] 5 | 6 | [dependencies] 7 | docopt = "*" 8 | rustc-serialize = "*" 9 | dot = "*" 10 | 11 | [dependencies.cargo] 12 | git = "https://github.com/rust-lang/cargo" 13 | 14 | [[bin]] 15 | name = "cargo-dot" 16 | test = false 17 | doc = true 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Max New 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of cargo-dot nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This project is deprecated in favor of [cargo-graph](https://github.com/kbknapp/cargo-graph). 2 | -------------------------------------------------------------------------------- /etc/cargo-dot.dot: -------------------------------------------------------------------------------- 1 | digraph dependencies { 2 | N0[label="cargo-dot"]; 3 | N1[label="aho-corasick"]; 4 | N2[label="memchr"]; 5 | N3[label="libc"]; 6 | N4[label="gcc"]; 7 | N5[label="glob"]; 8 | N6[label="pkg-config"]; 9 | N7[label="semver"]; 10 | N8[label="flate2"]; 11 | N9[label="miniz-sys"]; 12 | N10[label="dot"]; 13 | N11[label="toml"]; 14 | N12[label="rustc-serialize"]; 15 | N13[label="libressl-pnacl-sys"]; 16 | N14[label="pnacl-build-helper"]; 17 | N15[label="tar"]; 18 | N16[label="winapi"]; 19 | N17[label="git2-curl"]; 20 | N18[label="url"]; 21 | N19[label="curl"]; 22 | N20[label="log"]; 23 | N21[label="git2"]; 24 | N22[label="rand"]; 25 | N23[label="bitflags"]; 26 | N24[label="regex"]; 27 | N25[label="regex-syntax"]; 28 | N26[label="matches"]; 29 | N27[label="strsim"]; 30 | N28[label="libssh2-sys"]; 31 | N29[label="libz-sys"]; 32 | N30[label="openssl-sys"]; 33 | N31[label="registry"]; 34 | N32[label="num_cpus"]; 35 | N33[label="tempdir"]; 36 | N34[label="curl-sys"]; 37 | N35[label="kernel32-sys"]; 38 | N36[label="winapi-build"]; 39 | N37[label="winapi"]; 40 | N38[label="libgit2-sys"]; 41 | N39[label="term"]; 42 | N40[label="filetime"]; 43 | N41[label="cargo"]; 44 | N42[label="advapi32-sys"]; 45 | N43[label="env_logger"]; 46 | N44[label="threadpool"]; 47 | N45[label="time"]; 48 | N46[label="docopt"]; 49 | N1 -> N2[label=""]; 50 | N8 -> N3[label=""]; 51 | N8 -> N9[label=""]; 52 | N11 -> N12[label=""]; 53 | N13 -> N14[label=""]; 54 | N15 -> N3[label=""]; 55 | N16 -> N3[label=""]; 56 | N17 -> N18[label=""]; 57 | N17 -> N19[label=""]; 58 | N17 -> N20[label=""]; 59 | N17 -> N21[label=""]; 60 | N22 -> N3[label=""]; 61 | N24 -> N1[label=""]; 62 | N24 -> N25[label=""]; 63 | N24 -> N2[label=""]; 64 | N20 -> N3[label=""]; 65 | N28 -> N29[label=""]; 66 | N28 -> N3[label=""]; 67 | N28 -> N6[label=""]; 68 | N28 -> N30[label=""]; 69 | N31 -> N12[label=""]; 70 | N31 -> N19[label=""]; 71 | N32 -> N3[label=""]; 72 | N14 -> N33[label=""]; 73 | N34 -> N3[label=""]; 74 | N34 -> N6[label=""]; 75 | N34 -> N29[label=""]; 76 | N34 -> N30[label=""]; 77 | N35 -> N36[label=""]; 78 | N35 -> N37[label=""]; 79 | N38 -> N28[label=""]; 80 | N38 -> N3[label=""]; 81 | N38 -> N6[label=""]; 82 | N38 -> N29[label=""]; 83 | N38 -> N30[label=""]; 84 | N30 -> N6[label=""]; 85 | N30 -> N4[label=""]; 86 | N30 -> N13[label=""]; 87 | N30 -> N3[label=""]; 88 | N21 -> N38[label=""]; 89 | N21 -> N18[label=""]; 90 | N21 -> N3[label=""]; 91 | N21 -> N23[label=""]; 92 | N39 -> N37[label=""]; 93 | N39 -> N35[label=""]; 94 | N29 -> N3[label=""]; 95 | N29 -> N6[label=""]; 96 | N2 -> N3[label=""]; 97 | N41 -> N17[label=""]; 98 | N41 -> N20[label=""]; 99 | N41 -> N19[label=""]; 100 | N41 -> N12[label=""]; 101 | N41 -> N24[label=""]; 102 | N41 -> N21[label=""]; 103 | N41 -> N42[label=""]; 104 | N41 -> N43[label=""]; 105 | N41 -> N40[label=""]; 106 | N41 -> N35[label=""]; 107 | N41 -> N31[label=""]; 108 | N41 -> N5[label=""]; 109 | N41 -> N15[label=""]; 110 | N41 -> N11[label=""]; 111 | N41 -> N7[label=""]; 112 | N41 -> N39[label=""]; 113 | N41 -> N8[label=""]; 114 | N41 -> N3[label=""]; 115 | N41 -> N18[label=""]; 116 | N41 -> N16[label=""]; 117 | N41 -> N44[label=""]; 118 | N41 -> N45[label=""]; 119 | N41 -> N46[label=""]; 120 | N41 -> N38[label=""]; 121 | N41 -> N32[label=""]; 122 | N9 -> N3[label=""]; 123 | N9 -> N4[label=""]; 124 | N42 -> N37[label=""]; 125 | N42 -> N36[label=""]; 126 | N33 -> N22[label=""]; 127 | N46 -> N24[label=""]; 128 | N46 -> N27[label=""]; 129 | N46 -> N12[label=""]; 130 | N45 -> N35[label=""]; 131 | N45 -> N3[label=""]; 132 | N45 -> N37[label=""]; 133 | N43 -> N24[label=""]; 134 | N43 -> N20[label=""]; 135 | N19 -> N20[label=""]; 136 | N19 -> N34[label=""]; 137 | N19 -> N30[label=""]; 138 | N19 -> N3[label=""]; 139 | N19 -> N18[label=""]; 140 | N0 -> N41[label=""]; 141 | N0 -> N46[label=""]; 142 | N0 -> N12[label=""]; 143 | N0 -> N10[label=""]; 144 | N18 -> N26[label=""]; 145 | N18 -> N12[label=""]; 146 | } 147 | -------------------------------------------------------------------------------- /etc/cargo-dot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxsnew/cargo-dot/66e411929ac7c33817d838b3e651acac2e6b7690/etc/cargo-dot.png -------------------------------------------------------------------------------- /etc/servo.dot: -------------------------------------------------------------------------------- 1 | digraph example3 { 2 | N0[label="servo"]; 3 | N1[label="js"]; 4 | N2[label="mozjs-sys"]; 5 | N3[label="semver"]; 6 | N4[label="glut"]; 7 | N5[label="opengles"]; 8 | N6[label="task_info"]; 9 | N7[label="openssl"]; 10 | N8[label="encoding"]; 11 | N9[label="script_traits"]; 12 | N10[label="msg"]; 13 | N11[label="geom"]; 14 | N12[label="url"]; 15 | N13[label="net"]; 16 | N14[label="freetype"]; 17 | N15[label="png"]; 18 | N16[label="png-sys"]; 19 | N17[label="expat-sys"]; 20 | N18[label="macros"]; 21 | N19[label="freetype-sys"]; 22 | N20[label="io_surface"]; 23 | N21[label="core_foundation"]; 24 | N22[label="style"]; 25 | N23[label="util"]; 26 | N24[label="cssparser"]; 27 | N25[label="http"]; 28 | N26[label="stb_image"]; 29 | N27[label="compositing"]; 30 | N28[label="layers"]; 31 | N29[label="glfw"]; 32 | N30[label="core_graphics"]; 33 | N31[label="azure"]; 34 | N32[label="core_text"]; 35 | N33[label="layout_traits"]; 36 | N34[label="gfx"]; 37 | N35[label="alert"]; 38 | N36[label="string_cache"]; 39 | N37[label="string_cache_macros"]; 40 | N38[label="phf_mac"]; 41 | N39[label="phf"]; 42 | N40[label="canvas"]; 43 | N41[label="hubbub-sys"]; 44 | N42[label="parserutils-sys"]; 45 | N43[label="harfbuzz"]; 46 | N44[label="link_glfw"]; 47 | N45[label="cocoa"]; 48 | N46[label="layout"]; 49 | N47[label="script"]; 50 | N48[label="skia-sys"]; 51 | N49[label="hubbub"]; 52 | N50[label="fontconfig-sys"]; 53 | N51[label="egl"]; 54 | N52[label="fontconfig"]; 55 | N53[label="xlib"]; 56 | N1 -> N2[label=""]; 57 | N4 -> N5[label=""]; 58 | N9 -> N10[label=""]; 59 | N9 -> N11[label=""]; 60 | N9 -> N12[label=""]; 61 | N9 -> N13[label=""]; 62 | N15 -> N16[label=""]; 63 | N20 -> N11[label=""]; 64 | N20 -> N5[label=""]; 65 | N20 -> N21[label=""]; 66 | N22 -> N18[label=""]; 67 | N22 -> N11[label=""]; 68 | N22 -> N12[label=""]; 69 | N22 -> N23[label=""]; 70 | N22 -> N8[label=""]; 71 | N22 -> N24[label=""]; 72 | N25 -> N7[label=""]; 73 | N25 -> N12[label=""]; 74 | N27 -> N5[label=""]; 75 | N27 -> N13[label=""]; 76 | N27 -> N9[label=""]; 77 | N27 -> N12[label=""]; 78 | N27 -> N28[label=""]; 79 | N27 -> N29[label=""]; 80 | N27 -> N10[label=""]; 81 | N27 -> N30[label=""]; 82 | N27 -> N31[label=""]; 83 | N27 -> N23[label=""]; 84 | N27 -> N32[label=""]; 85 | N27 -> N4[label=""]; 86 | N27 -> N33[label=""]; 87 | N27 -> N34[label=""]; 88 | N27 -> N15[label=""]; 89 | N27 -> N35[label=""]; 90 | N27 -> N11[label=""]; 91 | N36 -> N37[label=""]; 92 | N36 -> N38[label=""]; 93 | N36 -> N39[label=""]; 94 | N40 -> N11[label=""]; 95 | N40 -> N31[label=""]; 96 | N41 -> N42[label=""]; 97 | N10 -> N23[label=""]; 98 | N10 -> N28[label=""]; 99 | N10 -> N11[label=""]; 100 | N10 -> N12[label=""]; 101 | N10 -> N21[label=""]; 102 | N10 -> N31[label=""]; 103 | N10 -> N20[label=""]; 104 | N13 -> N25[label=""]; 105 | N13 -> N12[label=""]; 106 | N13 -> N11[label=""]; 107 | N13 -> N26[label=""]; 108 | N13 -> N15[label=""]; 109 | N13 -> N23[label=""]; 110 | N35 -> N45[label=""]; 111 | N35 -> N21[label=""]; 112 | N29 -> N3[label=""]; 113 | N29 -> N44[label=""]; 114 | N46 -> N22[label=""]; 115 | N46 -> N33[label=""]; 116 | N46 -> N47[label=""]; 117 | N46 -> N13[label=""]; 118 | N46 -> N34[label=""]; 119 | N46 -> N9[label=""]; 120 | N46 -> N11[label=""]; 121 | N46 -> N12[label=""]; 122 | N46 -> N23[label=""]; 123 | N46 -> N18[label=""]; 124 | N48 -> N19[label=""]; 125 | N48 -> N17[label=""]; 126 | N49 -> N41[label=""]; 127 | N12 -> N8[label=""]; 128 | N50 -> N19[label=""]; 129 | N50 -> N17[label=""]; 130 | N0 -> N27[label=""]; 131 | N0 -> N10[label=""]; 132 | N0 -> N23[label=""]; 133 | N0 -> N47[label=""]; 134 | N0 -> N46[label=""]; 135 | N0 -> N15[label=""]; 136 | N0 -> N13[label=""]; 137 | N0 -> N34[label=""]; 138 | N23 -> N11[label=""]; 139 | N23 -> N6[label=""]; 140 | N23 -> N31[label=""]; 141 | N23 -> N36[label=""]; 142 | N24 -> N8[label=""]; 143 | N34 -> N28[label=""]; 144 | N34 -> N32[label=""]; 145 | N34 -> N21[label=""]; 146 | N34 -> N26[label=""]; 147 | N34 -> N30[label=""]; 148 | N34 -> N11[label=""]; 149 | N34 -> N18[label=""]; 150 | N34 -> N31[label=""]; 151 | N34 -> N52[label=""]; 152 | N34 -> N22[label=""]; 153 | N34 -> N14[label=""]; 154 | N34 -> N43[label=""]; 155 | N34 -> N23[label=""]; 156 | N34 -> N10[label=""]; 157 | N34 -> N13[label=""]; 158 | N34 -> N12[label=""]; 159 | N34 -> N15[label=""]; 160 | N52 -> N50[label=""]; 161 | N30 -> N21[label=""]; 162 | N33 -> N23[label=""]; 163 | N33 -> N13[label=""]; 164 | N33 -> N9[label=""]; 165 | N33 -> N34[label=""]; 166 | N33 -> N10[label=""]; 167 | N47 -> N34[label=""]; 168 | N47 -> N1[label=""]; 169 | N47 -> N11[label=""]; 170 | N47 -> N10[label=""]; 171 | N47 -> N40[label=""]; 172 | N47 -> N9[label=""]; 173 | N47 -> N23[label=""]; 174 | N47 -> N8[label=""]; 175 | N47 -> N18[label=""]; 176 | N47 -> N12[label=""]; 177 | N47 -> N49[label=""]; 178 | N47 -> N13[label=""]; 179 | N47 -> N22[label=""]; 180 | N47 -> N24[label=""]; 181 | N47 -> N25[label=""]; 182 | N28 -> N5[label=""]; 183 | N28 -> N51[label=""]; 184 | N28 -> N11[label=""]; 185 | N28 -> N20[label=""]; 186 | N28 -> N21[label=""]; 187 | N28 -> N53[label=""]; 188 | N32 -> N21[label=""]; 189 | N32 -> N30[label=""]; 190 | N31 -> N5[label=""]; 191 | N31 -> N53[label=""]; 192 | N31 -> N11[label=""]; 193 | N31 -> N51[label=""]; 194 | N31 -> N28[label=""]; 195 | N31 -> N48[label=""]; 196 | N31 -> N21[label=""]; 197 | N31 -> N32[label=""]; 198 | N31 -> N30[label=""]; 199 | N31 -> N29[label=""]; 200 | N31 -> N14[label=""]; 201 | } 202 | -------------------------------------------------------------------------------- /etc/servo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maxsnew/cargo-dot/66e411929ac7c33817d838b3e651acac2e6b7690/etc/servo.png -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | extern crate cargo; 2 | extern crate docopt; 3 | extern crate dot; 4 | extern crate rustc_serialize; 5 | 6 | use cargo::core::{Resolve, SourceId, PackageId}; 7 | use docopt::Docopt; 8 | use std::borrow::{Cow}; 9 | use std::convert::Into; 10 | use std::env; 11 | use std::io; 12 | use std::io::Write; 13 | use std::fs::File; 14 | use std::path::{Path, PathBuf}; 15 | 16 | static USAGE: &'static str = " 17 | Generate a graph of package dependencies in graphviz format 18 | 19 | Usage: cargo dot [options] 20 | cargo dot --help 21 | 22 | Options: 23 | -h, --help Show this message 24 | -V, --version Print version info and exit 25 | --lock-file=FILE Specify location of input file, default \"Cargo.lock\" 26 | --dot-file=FILE Output to file, default prints to stdout 27 | --source-labels Use sources for the label instead of package names 28 | "; 29 | 30 | #[derive(RustcDecodable, Debug)] 31 | struct Flags { 32 | flag_help: bool, 33 | flag_version: bool, 34 | flag_lock_file: String, 35 | flag_dot_file: String, 36 | flag_source_labels: bool, 37 | } 38 | 39 | 40 | fn main() { 41 | let mut argv: Vec = env::args().collect(); 42 | if argv.len() > 0 { 43 | argv[0] = "cargo".to_string(); 44 | } 45 | let flags: Flags = Docopt::new(USAGE) 46 | .and_then(|d| d.decode()) 47 | .unwrap_or_else(|e| e.exit()); 48 | 49 | let dot_f_flag = if flags.flag_dot_file.is_empty() { None } else { Some(flags.flag_dot_file) }; 50 | let source_labels = flags.flag_source_labels; 51 | 52 | let lock_path = unless_empty(flags.flag_lock_file, "Cargo.lock"); 53 | let lock_path = Path::new(&lock_path); 54 | let lock_path_buf = absolutize(lock_path.to_path_buf()); 55 | let lock_path = lock_path_buf.as_path(); 56 | 57 | let proj_dir = lock_path.parent().unwrap(); // TODO: check for None 58 | let src_id = SourceId::for_path(&proj_dir).unwrap(); 59 | let resolved = cargo::ops::load_lockfile(&lock_path, &src_id).unwrap() 60 | .expect("Lock file not found."); 61 | 62 | let mut graph = Graph::with_root(resolved.root(), source_labels); 63 | graph.add_dependencies(&resolved); 64 | 65 | match dot_f_flag { 66 | None => graph.render_to(&mut io::stdout()), 67 | Some(dot_file) => graph.render_to(&mut File::create(&Path::new(&dot_file)).unwrap()) 68 | }; 69 | } 70 | 71 | fn absolutize(pb: PathBuf) -> PathBuf { 72 | if pb.as_path().is_absolute() { 73 | pb 74 | } else { 75 | std::env::current_dir().unwrap().join(&pb.as_path()).clone() 76 | } 77 | } 78 | 79 | fn unless_empty(s: String, default: &str) -> String { 80 | if s.is_empty() { 81 | default.to_string() 82 | } else { 83 | s 84 | } 85 | } 86 | 87 | pub type Nd = usize; 88 | pub type Ed = (usize, usize); 89 | pub struct Graph<'a> { 90 | nodes: Vec<&'a PackageId>, 91 | edges: Vec, 92 | source_labels: bool 93 | } 94 | 95 | impl<'a> Graph<'a> { 96 | pub fn with_root(root: &PackageId, source_labels: bool) -> Graph { 97 | Graph { nodes: vec![root], edges: vec![], source_labels: source_labels } 98 | } 99 | 100 | pub fn add_dependencies(&mut self, resolved: &'a Resolve) { 101 | for crat in resolved.iter() { 102 | match resolved.deps(crat) { 103 | Some(crate_deps) => { 104 | let idl = self.find_or_add(crat); 105 | for dep in crate_deps { 106 | let idr = self.find_or_add(dep); 107 | self.edges.push((idl, idr)); 108 | }; 109 | }, 110 | None => { } 111 | } 112 | } 113 | } 114 | 115 | fn find_or_add(&mut self, new: &'a PackageId) -> usize { 116 | for (i, id) in self.nodes.iter().enumerate() { 117 | if *id == new { 118 | return i 119 | } 120 | } 121 | self.nodes.push(new); 122 | self.nodes.len() - 1 123 | } 124 | 125 | pub fn render_to(&'a self, output: &mut W) { 126 | match dot::render(self, output) { 127 | Ok(_) => {}, 128 | Err(e) => panic!("error rendering graph: {}", e) 129 | } 130 | } 131 | } 132 | 133 | impl<'a> dot::Labeller<'a, Nd, Ed> for Graph<'a> { 134 | fn graph_id(&self) -> dot::Id<'a> { 135 | dot::Id::new(self.nodes[0].name()).unwrap_or(dot::Id::new("dependencies").unwrap()) 136 | } 137 | fn node_id(&self, n: &Nd) -> dot::Id { 138 | // unwrap is safe because N######## is a valid graphviz id 139 | dot::Id::new(format!("N{}", *n)).unwrap() 140 | } 141 | fn node_label(&'a self, i: &Nd) -> dot::LabelText<'a> { 142 | if !self.source_labels { 143 | dot::LabelText::LabelStr(self.nodes[*i].name().into()) 144 | } else { 145 | dot::LabelText::LabelStr(self.nodes[*i].source_id().url().to_string().into()) 146 | } 147 | } 148 | } 149 | 150 | impl<'a> dot::GraphWalk<'a, Nd, Ed> for Graph<'a> { 151 | fn nodes(&self) -> dot::Nodes<'a,Nd> { 152 | (0..self.nodes.len()).collect() 153 | } 154 | fn edges(&self) -> dot::Edges { 155 | Cow::Borrowed(&self.edges[..]) 156 | } 157 | fn source(&self, &(s, _): &Ed) -> Nd { s } 158 | fn target(&self, &(_, t): &Ed) -> Nd { t } 159 | } 160 | --------------------------------------------------------------------------------