-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Migrate Rust crate dependencies to rules_rs #24810
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
Merged
jwnimmer-tri
merged 5 commits into
RobotLocomotion:master
from
dzbarsky:codex/rules-rs-llvm-toolchains
Aug 7, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4e58c1d
Migrate Rust crate dependencies to rules_rs and LLVM toolchains
dzbarsky c71f6a4
placate the shebang linter differently
jwnimmer-tri 6761d8d
drop unnecessary crate__ back-and-forth
jwnimmer-tri d48031e
Reuse Clarabel Cargo.toml and simplify crate licenses
dzbarsky 0a41982
add upgrade comment
jwnimmer-tri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,41 +1,29 @@ | ||
| load( | ||
| "@rules_rust//crate_universe:defs.bzl", | ||
| "crate", | ||
| "crates_vendor", | ||
| "render_config", | ||
| ) | ||
| load("//tools/install:install.bzl", "install") | ||
| load("//tools/lint:lint.bzl", "add_lint_tests") | ||
| load("//tools/skylark:drake_py.bzl", "drake_py_binary") | ||
|
|
||
| exports_files(glob(["lock/**"])) | ||
|
|
||
| # This is a maintainer-only tool for Drake Developers to manage our Rust | ||
| # dependencies. See README.md for instructions on how to run `upgrade.sh`. | ||
| crates_vendor( | ||
| name = "crate", | ||
| annotations = { | ||
| "clarabel": [crate.annotation( | ||
| patches = [ | ||
| "@drake//tools/workspace/crate_universe:patches/clarabel_blas.patch", # noqa | ||
| ], | ||
| )], | ||
| }, | ||
| cargo_lockfile = ":lock/Cargo.toml.lock", | ||
| manifests = [ | ||
| "@clarabel_cpp_internal//:rust_wrapper/Cargo.toml", | ||
| ], | ||
| mode = "remote", | ||
| render_config = render_config( | ||
| generate_rules_license_metadata = True, | ||
| ), | ||
| tags = ["manual"], | ||
| vendor_path = "lock/details", | ||
| ) | ||
|
|
||
| install( | ||
| name = "install", | ||
| visibility = ["//visibility:public"], | ||
| deps = ["@crate_licenses//:install"], | ||
| ) | ||
|
|
||
| drake_py_binary( | ||
| name = "upgrade", | ||
| srcs = ["upgrade.py"], | ||
| data = [ | ||
| "@crate_licenses//:Cargo.lock", | ||
| "@crate_licenses//:Cargo.toml", | ||
| "@crate_licenses//:src/lib.rs", | ||
| "@rules_rust//tools/upstream_wrapper:cargo", | ||
| ], | ||
| env = { | ||
| "DRAKE_CARGO_MANIFEST_RLOCATIONPATH": "$(rlocationpath @crate_licenses//:Cargo.toml)", | ||
| "DRAKE_CARGO_RLOCATIONPATH": "$(rlocationpath @rules_rust//tools/upstream_wrapper:cargo)", | ||
| }, | ||
| deps = ["@rules_python//python/runfiles"], | ||
| ) | ||
|
|
||
| add_lint_tests() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,38 @@ | ||
| load( | ||
| "//tools/workspace/crate_universe/lock/details:crates.bzl", | ||
| _all_crate_deps = "all_crate_deps", | ||
| ) | ||
| load("@crates//:defs.bzl", _all_crate_deps = "all_crate_deps") | ||
| load("@rules_rust//rust/private:providers.bzl", "CrateInfo") | ||
| load("//tools/install:install.bzl", "InstallInfo") | ||
|
|
||
| def all_crate_deps(**kwargs): | ||
| def all_crate_deps(): | ||
| """Returns the fully qualified labels of all crate_universe crates.""" | ||
| return _all_crate_deps(package_name = "", **kwargs) | ||
| return _all_crate_deps() | ||
|
|
||
| def _install_crate_license_impl(ctx): | ||
| package_directory = ctx.attr.crate.label.workspace_root | ||
| if ctx.attr.crate.label.package: | ||
| package_directory += "/" + ctx.attr.crate.label.package | ||
| license_files = [ | ||
| file | ||
| for file in ctx.attr.crate[CrateInfo].compile_data.to_list() | ||
| if file.dirname == package_directory and | ||
| file.basename.upper().startswith("LICENSE") | ||
| ] | ||
| if not license_files: | ||
| fail("{} has no recognized license file".format(ctx.attr.crate.label)) | ||
| license_file = license_files[0] | ||
|
|
||
| return [InstallInfo( | ||
| install_actions = [struct( | ||
| src = license_file, | ||
| dst = ctx.attr.doc_dest + "/" + license_file.basename, | ||
| )], | ||
| rename = {}, | ||
| installed_files = {}, | ||
| )] | ||
|
|
||
| install_crate_license = rule( | ||
| implementation = _install_crate_license_impl, | ||
| attrs = { | ||
| "crate": attr.label(mandatory = True, providers = [CrateInfo]), | ||
| "doc_dest": attr.string(mandatory = True), | ||
| }, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
134 changes: 0 additions & 134 deletions
134
tools/workspace/crate_universe/lock/details/BUILD.amd-0.2.2.bazel
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.