How to properly modify/patch source of a Cargo Crate dependency
When creating recipes for Rust projects, all of the required crates are included in SRC_URI. I need to patch the source of several crates. I've tried creating individual recipes, but that does not really help.
I've managed to get a hacky fix to work, however it involves having recipes copy source from the tmp/work directory, which is not ideal. It patches the Cargo.toml to replace the version of the dependency with a local path to expect the sources in.
Is there a good way to do the patches necessary within bitbake, or should I be creating my own forks of all these packages?
Quoted 3 lines · Jerry Kefas via lists.yoctoproject.org
When creating recipes for Rust projects, all of the required crates are included in
SRC_URI. I need to patch the source of several crates. I've tried creating individual recipes, but that does not really help.
If you're just patching in later versions of the crates, this should work:
SRC_URI += "crate://crates.io/<target>/<version>" EXTRA_OECARGO_PATHS = "${CARGO_VENDORING_DIRECTORY}/<target>-<version>"
or if you have them patched in a git repo:
SRC_URI += "git://.../<target>"EXTRA_OECARGO_PATHS = "${WORKDIR}/<target>"
Only works if they're already in crates.io though
(https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html)
and you'll probably run into
https://github.com/rust-lang/rust/issues/98185
Quoted 2 lines
I've managed to get a hacky fix to work, however it involves having recipes copy source from the tmp/work directory, which is not ideal. It patches the Cargo.toml to replace the version of the dependency with a local path to expect the sources in.
I suspect we really need some standard machinery here.
--
Alex Kiernan