Skip to content

Module for vendored external Rust dependent code #76012

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

Closed
d3zd3z opened this issue Jul 17, 2024 · 3 comments
Closed

Module for vendored external Rust dependent code #76012

d3zd3z opened this issue Jul 17, 2024 · 3 comments
Labels
Stale TSC Topics that need TSC discussion

Comments

@d3zd3z
Copy link
Collaborator

d3zd3z commented Jul 17, 2024

Origin

Purpose

These are external modules needed to build the Rust support being integrated by #75904.

Mode of integration

These should be brought in as a module, perhaps rust-vendored. Maybe brought in as modules/lang/rust-vendored.

Maintainership

  • d3zd3z

Pull Request

https://github.com/d3zd3z/zephyr-rust-vendored

Description

When writing Rust applications for Zephyr, the cargo build tool is able to bring external code in to resolve dependencies. Currently, the rust support as proposed in #75904 makes use of a few dependencies at build time. None of these dependencies are linked into the target image. It is likely for there to be a small number of additional modules needed, as the rust support is developed, but this will not grow unbounded. Dependencies added to a given application by the user will be automatically fetched by the cargo tool, and the user can decide for themselves whether or not to use the Rust/Cargo vendoring tools.

As there are a small number of these modules, covered by similar licenses, I have brought them into the same repository.

Dependencies

This code is used by the Zephyr code in lib/rust when Rust support is configured in and used. Having it in this tree prevents the rust build tools from fetching the code at build time.

Revision

2a677e6ab00b12a0d2d8308e04be109ee6868b8d

License

The external modules specify two license variants:

  • MIT or Unlicense
  • MIT or Apache 2.0
@d3zd3z d3zd3z added the TSC Topics that need TSC discussion label Jul 17, 2024
@d3zd3z
Copy link
Collaborator Author

d3zd3z commented Jul 17, 2024

I would like to propose an alternative to the vendoring of these modules, and instead argue that build-time Rust dependencies should be treated the same way that we treat python modules, using the language's provided tool for managing those dependencies. In the case of rust, that is the cargo tool.

If we have a requirement that the dependencies be downloaded as part of an initialization stage, the cargo fetch command can be used, although a small script would be needed in order to set up some paths. Cargo can be invoked to fail upon error instead of fetching dependencies.

Another approach is to use the cargo vendor command, which will fetch all of the dependencies, at once, and give some config file fragments that would use those instead of the online repository.

One important distinction is that it might also be necessary to add a script that verifies that there are no dependencies brought in through cargo that are being linked. In the case of Rust+Zephyr, the zephyr crate lib/rust/zephyr should only depend on local crates through its dependencies entry, although it, and those local crates are permitted to have build-dependencies that reference cargo provided crates.

@MaureenHelm MaureenHelm moved this from Todo to In Progress in TSC Attention Needed Jul 30, 2024
Copy link

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.

Copy link

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.

@github-actions github-actions bot added the Stale label Nov 17, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 1, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in TSC Attention Needed Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stale TSC Topics that need TSC discussion
Projects
Status: Done
Development

No branches or pull requests

2 participants