-
Notifications
You must be signed in to change notification settings - Fork 435
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
Support cargo_bazel_bootstrap for bzlmod #2021
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! I'll test it against an internal codebase but this looks like it will just work.
Not sure how to handle documentation in this case. AFAIK stardoc doesn't support doc generation for extensions yet, but a short description or just links to the WORKSPACE equivalents in the extension doc fields would probably be helpful.
crate_universe/private/module_extensions/cargo_bazel_bootstrap.bzl
Outdated
Show resolved
Hide resolved
17074ce
to
f4804b4
Compare
Added a doc tag to the module_extension call |
FYI, the command to test it should be: |
Just tested this from the bzlmod example with the following MODULE.bazel: module(
name = "hello_world",
version = "1.0",
)
bazel_dep(name = "rules_rust", version = "0.9.0")
local_path_override(
module_name = "rules_rust",
path = "../../..",
)
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
rust.toolchain(edition = "2021")
use_repo(
rust,
"rust_toolchains",
"rust_host_tools",
)
cargo_bazel_bootstrap = use_extension(
"@rules_rust//crate_universe/private/module_extensions:cargo_bazel_bootstrap.bzl",
"cargo_bazel_bootstrap",
)
use_repo(cargo_bazel_bootstrap, "cargo_bazel_bootstrap")
register_toolchains("@rust_toolchains//:all") bazelisk run --enable_bzlmod @cargo_bazel_bootstrap//:binary -- --help and seems to work fine :) Thanks a lot for this it really simplifies using the rust dependency autogeneration ❤️ BTW @matts1 did you ever encounter issues with the |
This PR shouldn't touch the "rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools" repo - instead, it should generate another repo rust_host_tools with the exact same contents. The repo you mentioned should only be used when attempting to compile a |
Hello guys, Very big thanks for this change, i was trying to do it for few days ago already and i was dealing with the famous issue "rust_linux_x86_64__x86_64-unknown-linux-gnu__stable_tools".. So I think we can go further :)
To make this happens, some changes needs to be made in rules_rust : This is not usable with bzlmod, due to the canonical name of the repo To fix: And then list all my dependencies in the use_repo, add also another extension to load the generated defs.bzl file.. Thanks! |
@opicaud I've already implemented that. This is just a small part of that PR that I pulled into another PR because the other one was quite big. See #1910. More specifically, if you look at e199b6a#diff-fe7a82b8bc01fb5cb63b2644f2f11f1fffc9221a622dbfa9af48b20018975486, you'll see:
|
Anything I can do to help push this along? I'd love to get to decent bzlmod support in rules_rust. |
I've mostly just been stuck on reviews - I've been waiting for a reviewer to merge this for over a month now. If you know of any process I can go through to expedite the process, then that'd be great, but other than that, I probably don't need anything for now. |
Maybe @UebelAndre can help with that? |
Hey guys, I think it makes sense to make the effort to merge this : I mean, as for today, this feature is unfortunately not usable : if So, to be used by I've tried already to rebase the main branch, but with conflict.. i can give it again a try and point out issues |
@opicaud While I do want it reviewed, in the meantime, you can use the feature, with the following added to your bazelrc.
Just add the following entry to your MODULE.bazel and it's fine
|
Here's how we use it in ChromeOS if you're interested: |
@matts1 Following your example code, I'm getting:
If I delete Cargo.lock, I get What am I doing wrong? (I don't know much Rust, alas.) [Update] Ok, I got it working. But I had to
This may come from the
[UPDATE] The error message may come from here:
I don't think that regex handles the tilde? |
Cargo update is still required. Cargo update tells rust to update the lockfile. Your error basically says that the Cargo.lock and Cargo.toml files are incompatible with each other (eg. you update crate foo to 2.0.0 but the lockfile still says foo 1.0.0). The tilde could be the problem, but I would have thought we'd see the problem pop up earlier for all crates, since every repo should have a tilde in it. |
First, I neglected to say thank you for making this available. I'm bazelizing tree-sitter and was gearing up to finish bazel module support for rules_rust when I found this issue. Whew! So: many thanks.
No, repo strings only have tildes when they are used as external repos. If you build a target like
But when I use my tree-sitter repo (module name: stylites) as an external dep (i.e.
And since the error message is thrown by the regex application, it seems pretty clear that the regex is wrong. |
Thanks for this. Are there any plans to follow up with support for directly declaring the packages used (as in |
It's referred to in the code as build_bazel_apple_support.
This is the same as the @toolchain_<host>_<host> repository. However, we need to define it seperately because otherwise we'd need to use_extension on every single toolchain.
c707868
to
6e3ed93
Compare
@katre Not for now. For now I'm focusing on generating rust packages from |
6e3ed93
to
4528f3f
Compare
I've pulled out some of the code from #1910 into a seperate PR, to simplify the review process.