如何货物仅建立目标但不建立依赖性

发布于 2025-02-08 07:50:07 字数 898 浏览 2 评论 0原文

我从事一个生锈项目,该项目具有大量的显式或隐式依赖项(〜420)。更改.env文件后,我想重建目标(将IP之类的内容配置为从中下载文件)时,我只想重建我撰写的软件包,而不是所有依赖项。

我如何告诉货物构建使用先前编译的依赖项,但不能使用先前编译的软件包,该软件包使用.env文件作为输入?

Ideally, cargo build would realize that the .env file has changed and automatically decide to rebuild only the parts that use the .env file, but不幸的是,情况似乎并非如此。

因此,第二好的解决方案是手动告诉货物构建在构建图中的哪个点以重新开始。

We're using the dotenv crate https://crates.io/crates/dotenv crate to read the .env文件。

我尝试了货物清洁-P NextClade告诉它仅清洁我正在处理的相关软件包 - 但这仍然清理所有依赖项,这会导致我的构建需要5分钟,而不是2分钟分钟(如果使用编译依赖项)。

一个问题似乎提出了一个类似的问题,但是这个问题实际上是一个不同的用例/设置,因此这不是重复:货物如何决定是否重建DEPS?

I work on a Rust project that has a lot of packages as explicit or implicit dependencies (~420). When I want to rebuild the target after changing the .env file (that configures things like IP to download files from), I would like to rebuild only the packages that I authored, not all the dependencies.

How can I tell cargo build to use the previously compiled dependencies, but not use the previously compiled package that uses the .env file as input?

Ideally, cargo build would realize that the .env file has changed and automatically decide to rebuild only the parts that use the .env file, but unfortunately this doesn't seem to be the case.

So the second best solution is to manually tell cargo build at which point in the build graph to start off again.

We're using the dotenv crate https://crates.io/crates/dotenv crate to read the .env file.

I tried cargo clean -p nextclade to tell it to clean only the package in question that I'm working on - but that still cleans up all the dependencies which cause my build to take 5 minutes rather than 2 minutes (if using compiled dependencies).

There's a question that seems to ask a similar question, but that question is actually a different use case/set up, so it's not a duplicate: How does cargo decide whether to rebuild the deps or not?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文