cargo: `cargo package` doesn't include build script if this has a custom path
Problem
One package can have an entry on the manifest indicating a custom path for the build script, for example:
[package]
build = "../folder/build.rs"
Steps
Create a multiple packages that share a single build script and for programmability reasons keep just a single build script
Possible Solution(s)
The expected behaviour in this case would be to ship that build script on the root, and a naive solution would be to modify the behavior of the build attribute to be optional, so in case that the path is not found, default to the root.
The perfect solution would be to modify that entry also on the package, but I don’t know if modification of the manifest is on the philosophy of cargo package
I put the example of ../folder/build.rs because is the worst-case scenario in which the naive solution is clearly naive, since that dir might exist with another context.
Notes
No response
Version
cargo 1.65.0 (4bc8f24d3 2022-10-20)
release: 1.65.0
commit-hash: 4bc8f24d3e899462e43621aab981f6383a370365
commit-date: 2022-10-20
host: x86_64-pc-windows-msvc
libgit2: 1.5.0 (sys:0.15.0 vendored)
libcurl: 7.83.1-DEV (sys:0.4.55+curl-7.83.1 vendored ssl:Schannel)
os: Windows 10.0.19044 (Windows 10 Enterprise LTSC 2021) [64-bit]
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (11 by maintainers)
Commits related to this issue
- Fix #11383 (cargo package doesn't include external build script) + more tests to cargo-util — committed to cdecompilador/cargo by cdecompilador 2 years ago
- Auto merge of #12995 - linyihai:issue_11383, r=weihanglo Exited with hard error when custom build file no existence or not in package ## What does this PR try to resolve? Fixed https://github.com/ru... — committed to rust-lang/cargo by bors 7 months ago
I don’t think this is feasible to fix in the same way as readme or license-file. Although it can possibly copy the root file, cargo wouldn’t be able to know about modules (or any other resources included via macros), thus not copying the entire crate. This issue also applies to the
pathkey of target configurations. I think it would be reasonable to detect this situation and present an error when packaging.@rustbot claim
Having understood the context of the problem, I intend to look at the problem. Some of the work has already been done , and I intend to build on it.
@linyihai if you weren’t aware, we have office hours for contributors to talk over their work synchronously with members of the cargo ream.
I don’t know why but the commit from where I started didn’t pass half the tests, even some unrelated to my project, I will reset and try again so don’t worry, also the code was almost done so it shouldn’t be much work