Cargo命令打印目标文件列表?

时间:2016-07-12 16:41:50

标签: rust rust-cargo

在运行cargo后,cargo build打印要输出的文件列表的命令是什么?

1 个答案:

答案 0 :(得分:2)

cargo read-manifest将打印一个包含您可以使用的targets密钥的JSON对象。使用jq过滤和漂亮打印,这是rustfmt包装箱结帐时的输出:

➜ cargo read-manifest | jq '.targets'
[
  {
    "kind": [
      "lib"
    ],
    "name": "rustfmt",
    "src_path": "/Users/.../rustfmt/src/lib.rs"
  },
  {
    "kind": [
      "bin"
    ],
    "name": "cargo-fmt",
    "src_path": "/Users/.../rustfmt/src/bin/cargo-fmt.rs"
  },
  {
    "kind": [
      "bin"
    ],
    "name": "rustfmt",
    "src_path": "/Users/.../rustfmt/src/bin/rustfmt.rs"
  },
  {
    "kind": [
      "custom-build"
    ],
    "name": "build-script-build",
    "src_path": "build.rs"
  },
  {
    "kind": [
      "test"
    ],
    "name": "system",
    "src_path": "/Users/.../rustfmt/tests/system.rs"
  }
]