-
Notifications
You must be signed in to change notification settings - Fork 442
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 bzlmod #1528
Support bzlmod #1528
Conversation
@scentini do you or anyone you have contact with at Google know anything about bzlmod? |
I'm not familiar with bzlmod, in case we're doing something silly here it's not obvious to me. @Wyverald could you PTAL? |
Bzlmod may have some bugs in Bazel 5.3.0, it's recommended to test with Bazel@HEAD, you can use Bazelisk:
I got the following toolchain error instead of the visibility error:
|
1e4150e
to
c0fad5e
Compare
I've updated the PR with a rough proof of concept that can compile and run a rust binary. |
c0fad5e
to
c0aad03
Compare
Nice, can you also fix the buildifier errors? |
d139a0c
to
d92bb88
Compare
Is there any work I can take on here to help this get landed? |
@cameron-martin hey, any updates? 😄 |
Sorry I've been busy with other things. I may be able to get back to this in the next week or so. |
hello @cameron-martin, do you have any update ? |
I've got a prototype working for a module extension for bzlmod (changes stacked on top of this PR). It's still very much a WIP, and needs a lot of cleaning up, but you can at least build examples/bzlmod/crates_repository. https://github.com/matts1/rules_rust/tree/module_extension_prototype TLDR on how to use:
|
3bb4847
to
a3d7796
Compare
I've rebased this PR. Here are the main things that need finishing:
|
8f6d25d
to
27f16ee
Compare
We also have to consider the API for the module extensions. How many module extensions do we want? Just a single one, called "rust" for everything including crates_universe, etc? One per top-level package, e.g. rust, crates_universe, cargo? |
d8a1fff
to
d4645d8
Compare
d358c9b
to
dc2cf33
Compare
This should now be ready to review. |
dc2cf33
to
2eeddf8
Compare
cc @scentini @krasimirgg Hoping one of you two know anything about |
I read up a bit on |
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.
had a brief pass, mostly looks good! I didn't read the actual implementation very deeply.
This makes rules_rust load dependencies via bzlmod. Currently only basic functionality is completed, such as registering rustc toolchains and compiling crates. Note that it cannot interact with cargo, wasm or load any other rust toolchains such as rustfmt. There is one new module, `examples/bzlmod/hello_world`, that depends on the root `rules_rust` module. This example can be built and run using: ``` cd examples/bzlmod/hello_world bazel run //:hello_world ```
Thank you @Wyverald ! |
Nice! Will there be the next step to integrate with cargo to actually fetch rust dependencies? |
path = "../../..", | ||
) | ||
|
||
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust") |
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.
Sorry for being late here. Do we want rules_rust to register a default toolchain so that users don't have to do toolchain registration in their MODULE.bazel file at all? (of course, they can still do it to use their desired toolchain version).
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.
Currently only the toolchains declared in the top level module are registered. There was an unresolved discussion on whether this was the correct thing to do here, but currently the toolchain that rules_rust defines would not get registered.
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.
Got it, thanks!
It looks like we register these as _tools not as _srcs, this looks like it was maybe a typo in bazelbuild#1528
This makes rules_rust load dependencies via bzlmod. Currently only basic functionality is completed, such as registering rustc toolchains and compiling crates. Note that it cannot interact with cargo, wasm or load any other rust toolchains such as rustfmt.
There is one new module,
examples/bzlmod/hello_world
, that depends on the rootrules_rust
module. This example can be built and run using:To register toolchains in an ergonomic way, it defines a new "hub" repository that contains all the toolchain proxies, so they can all be registered like so:
closes #1493