-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Specify a build script for only binaries #1430
Comments
If I'm reading this correctly, there's a nasty side effect of "and to a binary if there is no library available" - if you have a build script being used for a binary, then |
https://github.com/rust-lang/cargo/blob/8a8ea1e89ee8bc/src/cargo/ops/cargo_rustc/mod.rs#L360 Fortunately, using other files with |
That conditional is required to prevent linkage errors in the common case due to duplicate symbols. Cargo assumes that binaries link to the library and as a result if the library already pulls in the native dependencies then the binaries shouldn't as it'd just cause more errors. |
Ah. You are right and I was doing it wrong. |
I ran into this issue today and it threw me for a loop (especially given the difficulty with debugging build scripts to start with). Here's what I attempted (guessing at what might be supported). Obviously, this did not work. # ...
[[bin]]
name = "foo"
path = "src/foo.rs"
build = "build_foo.rs"
[[test]]
name = "test_baz"
path = "test/test_baz.rs"
build = "test/build_test_baz.rs" One nice thing with this approach would be that it would be possible to eliminate things like the |
This would be a really nice feature. Currently my solution is to split library and binary into different workspaces manually. However it makes the directory structure more complex and dependency management becomes harder. I need to carefully sync these dependency versions specified in |
Furthermore, different binaries might need different build scripts. |
Right now a build script's output is always linked to a library if it's available (and to a binary if there is no library available). There is a use case, however, where a library doesn't actually use the output but only the binary does. This may be a nice option to have.
The text was updated successfully, but these errors were encountered: