mbox series

[RFC,0/1] recipetool: add plugin to create recipe for rust based application

Message ID 20231127171742.416913-1-jstephan@baylibre.com
Headers show
Series recipetool: add plugin to create recipe for rust based application | expand

Message

Julien Stephan Nov. 27, 2023, 5:17 p.m. UTC
Hi all,

This is an RFC to add support of rust recipes in recipetool.

This first version is able to create a minimal working recipe for crates
HAVING a Cargo.lock file (needed for reproducibility issues, see [1])
and using the following commands (using simple_genetic as example):

  - devtool add https://github.com/ValpsZ/simple_genetic
  - bitbake -c update_crates  simple-genetic
  - devtool finish simple-genetic <layer>

Limitations:
  - maybe we should factorise the code inside update_crates to avoid
    calling it after devtool add
  - for now the created recipe contains "include ${BPN}-crate.inc"
    instead of "require ${BPN}-crate.inc" because when the recipe is
    created, devtool tries to build the recipe itself and with "require"
    the parsing fails and the recipe is discarded. Maybe first point can
    help here. Another solution may be to write an empty ${BPN}-crate.inc
    next to the created recipe BUT right now I don't think it is possible
    because the process callback does not know neither the output dir nor
    ${BPN}. Maybe adding an optionnal post_process callback can help here? 

Unfortunately, most of the crates I tried, do NOT version the Cargo.lock
file, so we need a solution for that. Maybe the "update_crates" function
should do that? If no Cargo.lock file is found, just create one, and
create a patch for it. When a recipe is updated, the user upgrading SRCREV
(or the version) must be resposible to also run bitbake -c update_crates
to update the Cargo.lock and the ${BP}-crate.inc files. I think that
should be ok for reproducible builds? What do you think?

What's next:
  - add support for "devtool add https://crates.io/crates/simple_genetic/0.1.1" 
  - add oeqa selftest
  - handle the no Cargo.lock case... 

NOTE: created recipes are built tested but not tested at runtime for
now.

Dev branch on poky-contrib: [2] 

[1]: https://git.yoctoproject.org/poky/tree/meta/classes-recipe/cargo.bbclass#n45
[2]: https://git.yoctoproject.org/poky-contrib/log/?h=jstephan/devtool-add-rust-support

Julien Stephan (1):
  recipetool: create: add support for crates

 scripts/lib/recipetool/create_cargo.py | 122 +++++++++++++++++++++++++
 1 file changed, 122 insertions(+)
 create mode 100644 scripts/lib/recipetool/create_cargo.py