Allow patching dependencies with patch files
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 15.5k
- Forks
- 3k
- Avg merge
- 23h 30m
- Merged PRs (30d)
- 51
Description
Summary
This proposes to add an ability for Cargo to patch dependencies with patch files.
Problem description
The addition of the [patch] manifest section has made making localised changes to crates used by an individual project much easier. However, this still requires checking out the source code for the entire crate even if only a few lines of the source actually need to be modified.
This approach is fairly reasonable for individual Rust projects, however when embedded in a much larger build system that pulls hundreds of various projects together this can quickly become unwieldy (e.g. Buildroot, OpenWrt build system, etc). Rather than storing the entire source for any packages requiring modification, these build system instead store a set of patch files against a specific release version for the package in question.
Possible solution
This proposes adding an ability to let Cargo apply a set of patch files to a create after it is retrieved and extracted and before it is compiled. It would probably make sense to use the unified diff format given its popularity with tools like Git etc.
A previous proposal #3830 similar to this one, suggested the following syntax:
[dependencies.foobar]
version = "1.42"
patches = [
"path/to/patch-1.patch",
"path/to/patch-2/foobarize-a-bit-less.patch"
]
That syntax seems like a good starting point although someone with more Cargo experience might have a better idea.
Final remarks
One of the stated 2017 roadmap goals was for better integration with large build systems and I believe this would help further that goal.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading this proposal, Cargo's existing [patch] manifest behavior, and the related issue #3830; the payload does not name implementation files or tests. Clarify the manifest syntax and design before implementation, then verify that unified-diff patch files are applied after a crate is retrieved and extracted but before compilation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100