为打包目的安装 Cargo 构建的二进制文件的推荐方法是什么?

What is the recommended way to install the binaries built by Cargo for packaging purposes?

当我的 Cargo.toml 中有生成的 foo 二进制文件时,如何访问它?

[[bin]]
name = "foo"
path = "src/foo.rs"

理想情况下,我想要一些像

这样工作的东西
make install DESTDIR=$(pwd)/i

我试过了:

我可以深入到目标目录,但是有很多不需要的文件,所以 globs 将无法工作,我将不得不确切地知道工件名称,包括像 .a、[=19 这样的自动后缀=]、.so.1.2.3、等等

How to access binaries built by cargo?

cargo install --path . --root $(pwd)/i 是指定目标安装目录的正确方法。

but it seems to be impossible to set flags like --release or its opposite variant (yes: I want the debug binary!)

使用 --debug 标志是可能的。

cargo install --debug --path . --root $(pwd)/i

cargo install manual