如何在Rust的.cargo/config.toml文件中指定多个目录来源?

huangapple go评论74阅读模式
英文:

How to specify multiple Directory Sources in the .cargo/config.toml file in Rust?

问题

通常情况下,如果您希望`cargo`使用供应商提供的外部依赖代码(而不是访问[crates.io](https://crates.io/)或`$CARGO_HOME/registry/cache`),您可以将以下内容添加到您的`.cargo/config.toml`文件中:

```toml
[source.crates-io]
replace-with = "vendored-sources"

[source.vendored-sources]
directory = "relative/path/to/director/source" # 相对于.cargo目录的父目录

relative/path/to/directory/source包含供应商提供的软件包(以及它们自己的依赖项),作为包含未打包的.crate文件内容的子目录。

我的目标是在上面的[source.vendored-sources]中指定多个directory。或者更一般地说,在构建包时指定cargo检查供应商代码的多个目录源。

这是否可行?


<details>
<summary>英文:</summary>

Normally, if you wish `cargo` to use vendored code for external dependencies (instead of reaching into [crates.io](https://crates.io/) or `$CARGO_HOME/registry/cache`), you add the following into your `.cargo/config.toml` file :

```toml
[source.crates-io]
replace-with = &quot;vendored-sources&quot;

[source.vendored-sources]
directory = &quot;relative/path/to/director/source&quot; # relative to parent of .cargo directory

With relative/path/to/directory/source containing the vendored packages (along with their own dependencies), as sub-directories containing the contents of unpacked .crate files.

My objective is to specify more than one directory for [source.vendored-sources] above. Or just in general, specify multiple Directory Sources for cargo to check for vendored code, when building a package.

Is it possible?

答案1

得分: 1

很抱歉,截止到此刻,用户无法控制目录源如何发现包。

来自《Cargo API 文档》

> DirectorySource 目前只是一个包含其他目录的根目录,这些目录包含了包的源文件。

英文:

Unfortunately, as of this writing, users have no control over how a directory source discovers packages.

From the Cargo API documentation:

> DirectorySource at this moment is just a root directory containing
> other directories, which contain the source files of packages.

huangapple
  • 本文由 发表于 2023年6月5日 16:02:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/76404530.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定