[英]Why is cargo build cache invalidating?
I have a barebones workspace project:我有一个准系统工作区项目:
.
├── build-debug.sh
├── Cargo.lock
├── Cargo.toml
├── common
│ ├── Cargo.toml
│ └── src
│ └── lib.rs
├── rs-test.iml
├── server
│ ├── Cargo.toml
│ └── src
│ └── main.rs
└── wui
├── Cargo.toml
└── src
└── lib.rs
The rs files either empty or just an empty main function. rs 文件要么是空的,要么只是一个空的主函数。
The server and the wui depends on common: common = { path = "../common" }
.服务器和 wui 依赖于 common:
common = { path = "../common" }
。
The common project has one crates.io dependency with I suppose build script or proc macro dependency.通用项目有一个 crates.io 依赖项,我想是构建脚本或 proc 宏依赖项。
The build script:构建脚本:
cargo build -p wui --target wasm32-unknown-unknown
cargo build -p server
The problem:问题:
When I rebuild the unchanged project, some wui dependencies are getting invalidated/rebuilt, then the same for server.当我重建未更改的项目时,一些 wui 依赖项变得无效/重建,服务器也是如此。
Either:任何一个:
It does not rebuild the subprojects anymore.它不再重建子项目。
Is this a cargo bug?这是货物错误吗? What can I do?
我能做什么?
It's probably not a cargo bug.这可能不是货物错误。 What is likely happening here is that your crates.io dependency (you don't mention what it is, which might have been useful) has different dependencies or features depending on the target architecture.
这里可能发生的情况是您的 crates.io 依赖项(您没有提及它是什么,这可能很有用)根据目标架构具有不同的依赖项或功能。 Thus, as you alternate between building the WASM target and your host target, stuff is being rebuilt.
因此,当您在构建 WASM 目标和主机目标之间交替时,正在重建内容。
Perhaps it would be better in this case to stop using the Cargo workspace and build the server and wui separately;也许在这种情况下停止使用 Cargo 工作区并分别构建服务器和 wui 会更好; this way you'll have separate
target
directories for the server and wui, which takes some extra disk space and takes longer for non-incremental compilation, but will prevent you from having to rebuild that stuff all the time as you build both.通过这种方式,您将为服务器和 wui 拥有单独的
target
目录,这会占用一些额外的磁盘空间,并且非增量编译需要更长的时间,但会阻止您在构建两者时一直重建这些东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.