我正在学习货物工作空间,并设置了以下结构:
顶层:
[package]
name = "workspacer"
version = "0.1.0"
authors = ["ustulation <zzzzzz@gmail.com>"]
[workspace]
members = ["safe_core", "safe_authenticator", "safe_app"]
# If this is removed then each of the sub-projects will have thier own Cargo.lock file
# will build binaries/objects in their own target/ directories. With this present, it's
# always the parent-projects Cargo.lock and target/ directory used. Need to check if this
# is standard behaviour or some bug about to be fixed.
[lib]
crate_type = ["rlib", "cdylib", "staticlib"]
名为 safe_core 的lib,只需生成.rlib
[package]
authors = ["ustulation <zzzzzz@gmail.com>"]
name = "safe_core"
version = "0.1.0"
[dependencies]
maidsafe_utilities = "~0.10.0"
一个名为 safe_app 的lib,它依赖于 safe_core ,需要生成所有3个.rlib
,.a
和.so
:< / p>
[package]
name = "safe_app"
version = "0.1.0"
authors = ["ustulation <zzzzzz@gmail.com>"]
[dependencies]
maidsafe_utilities = "~0.10.0"
safe_core = { path = "../safe_core" }
[lib]
crate_type = ["rlib", "cdylib", "staticlib"]
一个名为 safe_authenticator 的lib,它依赖于 safe_core ,需要生成所有3个.rlib
,.a
和.so
:< / p>
[package]
name = "safe_authenticator"
version = "0.1.0"
authors = ["ustulation <zzzzzz@gmail.com>"]
[dependencies]
safe_core = { path = "../safe_core" }
[lib]
crate_type = ["rlib", "cdylib", "staticlib"]
树看起来像:
workspacer
├── Cargo.toml
├── safe_app
│ ├── Cargo.toml
│ └── src
│ └── lib.rs
├── safe_authenticator
│ ├── Cargo.toml
│ └── src
│ └── lib.rs
└── safe_core
├── Cargo.toml
└── src
└── lib.rs
如果我转到safe_core
并进行构建,则会在顶级target/
内创建Cargo.lock
个文件夹和workspacer/
个文件,这很好。
如果我转到safe_authenticator
文件夹并构建它,它也使用相同的target/
和Cargo.lock
文件,因此不会重新编译safe_core
这也是我想要的。与safe_app
相同。
但是,如果我从顶级[lib]
中删除workspacer/Cargo.toml
部分,则每个子项目都会开始创建自己的Cargo.lock
文件及其自己的/target
目录在他们各自的子目录中。我在上面Cargo.toml
workspacer
的内联评论(上面的第一个代码段)中提到了这一点。
这是预期的行为还是错误,还是我做错了什么?
~$ rustc --version && cargo --version
rustc 1.15.0-nightly (ba872f270 2016-11-17)
cargo 0.15.0-nightly (1877f59 2016-11-16)
答案 0 :(得分:1)
在最新稳定版上确认之后:
~$ rustc --version && cargo --version
rustc 1.13.0 (2c6933acc 2016-11-07)
cargo 0.13.0-nightly (eca9e15 2016-11-01)
工作区的所有成员应共享相同的目标目录号 无所谓!
A bug report was submitted,现在就解决了。