Skip to content

Commit

Permalink
[workspace] Upgrade rust repositories to latest (#21083)
Browse files Browse the repository at this point in the history
- Upgrade rules_rust to latest release 0.40.0
- Upgrade rust_toolchain to latest
- Upgrade crate_universe to latest
- Install crate_universe license docs using their rules_license badges
  • Loading branch information
jwnimmer-tri authored Mar 5, 2024
1 parent 9e8c3ae commit bbafc14
Show file tree
Hide file tree
Showing 41 changed files with 1,055 additions and 478 deletions.
36 changes: 36 additions & 0 deletions tools/install/install.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ load(
"output_path",
)
load("@python//:version.bzl", "PYTHON_SITE_PACKAGES_RELPATH", "PYTHON_VERSION")
load("@rules_license//rules:providers.bzl", "LicenseInfo")

InstallInfo = provider()

Expand Down Expand Up @@ -391,6 +392,41 @@ def _java_launcher_code(action):
#==============================================================================
#BEGIN rules

def install_license(*, doc_dest, licenses, tags = None, **kwargs):
"""Installs the license file texts for the `licenses` that have been
declared using rules_license.
"""
_install_license_rule(
doc_dest = doc_dest,
licenses = licenses,
tags = (tags or []) + ["install"],
**kwargs
)

def _install_license_impl(ctx):
install_actions = []
for license in ctx.attr.licenses:
file = license[LicenseInfo].license_text
install_actions.append(struct(
src = file,
dst = ctx.attr.doc_dest + "/" + file.basename,
))
return [
InstallInfo(
install_actions = install_actions,
rename = {},
installed_files = {},
),
]

_install_license_rule = rule(
implementation = _install_license_impl,
attrs = {
"doc_dest": attr.string(mandatory = True),
"licenses": attr.label_list(providers = [LicenseInfo]),
},
)

#------------------------------------------------------------------------------
# Generate information to install "stuff". "Stuff" can be library or binary
# targets, headers, or documentation files.
Expand Down
21 changes: 13 additions & 8 deletions tools/workspace/crate_universe/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
load("//tools/install:install.bzl", "install")
load("//tools/install:install.bzl", "install", "install_license")
load("//tools/workspace/crate_universe:lock/archives.bzl", "ARCHIVES")
load("//tools/lint:lint.bzl", "add_lint_tests")
load("@rules_rust//crate_universe:defs.bzl", "crate", "crates_vendor")
load(
"@rules_rust//crate_universe:defs.bzl",
"crate",
"crates_vendor",
"render_config",
)

exports_files(glob(["lock/**"]))

Expand All @@ -21,6 +26,9 @@ crates_vendor(
"@clarabel_cpp_internal//:rust_wrapper/Cargo.toml",
],
mode = "remote",
render_config = render_config(
generate_rules_license_metadata = True,
),
tags = ["manual"],
vendor_path = "lock/details",
)
Expand All @@ -29,14 +37,11 @@ crates_vendor(
ARCHIVE_NAMES = [archive["name"] for archive in ARCHIVES]

[
install(
install_license(
name = "install_{}".format(name),
docs = [
"@{}//:license_glob".format(name),
],
doc_dest = "share/doc/{}".format(name),
allowed_externals = [
"@{}//:license_glob".format(name),
licenses = [
"@{}//:license".format(name),
],
)
for name in ARCHIVE_NAMES
Expand Down
8 changes: 4 additions & 4 deletions tools/workspace/crate_universe/lock/Cargo.toml.lock
Original file line number Diff line number Diff line change
Expand Up @@ -823,9 +823,9 @@ dependencies = [

[[package]]
name = "rustls-pemfile"
version = "2.1.0"
version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c333bb734fcdedcea57de1602543590f545f127dc8b533324318fd492c5c70b"
checksum = "f48172685e6ff52a556baa527774f61fcaa884f59daf3375c62a3f1cd2549dab"
dependencies = [
"base64",
"rustls-pki-types",
Expand Down Expand Up @@ -1047,9 +1047,9 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"

[[package]]
name = "walkdir"
version = "2.4.0"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee"
checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"
dependencies = [
"same-file",
"winapi-util",
Expand Down
36 changes: 25 additions & 11 deletions tools/workspace/crate_universe/lock/details/BUILD.amd-0.2.2.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,39 @@
###############################################################################

load("@rules_rust//rust:defs.bzl", "rust_library")
load("@rules_license//rules:license.bzl", "license")
load("@rules_license//rules:package_info.bzl", "package_info")

package(default_visibility = ["//visibility:public"])
package(
default_package_metadata = [
":license",
":package_info",
],
default_visibility = ["//visibility:public"],
)

# licenses([
# "TODO", # BSD-3-Clause
# ])
filegroup(
name = "license_glob",
srcs = glob(
["LICENSE*"],
allow_empty = False,
),
package_info(
name = "package_info",
package_name = "amd",
package_url = "https://github.com/rwl/amd_order/",
package_version = "0.2.2",
)

license(
name = "license",
license_kinds = ["@rules_license//licenses/spdx:BSD-3-Clause"],
license_text = "LICENSE",
)

rust_library(
name = "amd",
srcs = glob(["**/*.rs"]),
srcs = glob(
include = ["**/*.rs"],
allow_empty = False,
),
compile_data = glob(
include = ["**"],
allow_empty = True,
exclude = [
"**/* *",
".tmp_git_root/**/*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,42 @@
###############################################################################

load("@rules_rust//rust:defs.bzl", "rust_library")
load("@rules_license//rules:license.bzl", "license")
load("@rules_license//rules:package_info.bzl", "package_info")

package(default_visibility = ["//visibility:public"])
package(
default_package_metadata = [
":license",
":package_info",
],
default_visibility = ["//visibility:public"],
)

# licenses([
# "TODO", # Apache-2.0 OR MIT
# ])
filegroup(
name = "license_glob",
srcs = glob(
["LICENSE*"],
allow_empty = False,
),
package_info(
name = "package_info",
package_name = "autocfg",
package_url = "https://github.com/cuviper/autocfg",
package_version = "1.1.0",
)

license(
name = "license",
license_kinds = [
"@rules_license//licenses/spdx:Apache-2.0",
"@rules_license//licenses/spdx:MIT",
],
license_text = "LICENSE-APACHE",
)

rust_library(
name = "autocfg",
srcs = glob(["**/*.rs"]),
srcs = glob(
include = ["**/*.rs"],
allow_empty = False,
),
compile_data = glob(
include = ["**"],
allow_empty = True,
exclude = [
"**/* *",
".tmp_git_root/**/*",
Expand Down
16 changes: 11 additions & 5 deletions tools/workspace/crate_universe/lock/details/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,21 @@ exports_files(
"cargo-bazel.json",
"crates.bzl",
"defs.bzl",
] + glob(["*.bazel"]),
] + glob(
include = ["*.bazel"],
allow_empty = True,
),
)

filegroup(
name = "srcs",
srcs = glob([
"*.bazel",
"*.bzl",
]),
srcs = glob(
include = [
"*.bazel",
"*.bzl",
],
allow_empty = True,
),
)

# Workspace Member Dependencies
Expand Down
39 changes: 28 additions & 11 deletions tools/workspace/crate_universe/lock/details/BUILD.blas-0.22.0.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,42 @@
###############################################################################

load("@rules_rust//rust:defs.bzl", "rust_library")
load("@rules_license//rules:license.bzl", "license")
load("@rules_license//rules:package_info.bzl", "package_info")

package(default_visibility = ["//visibility:public"])
package(
default_package_metadata = [
":license",
":package_info",
],
default_visibility = ["//visibility:public"],
)

# licenses([
# "TODO", # Apache-2.0/MIT
# ])
filegroup(
name = "license_glob",
srcs = glob(
["LICENSE*"],
allow_empty = False,
),
package_info(
name = "package_info",
package_name = "blas",
package_url = "https://github.com/blas-lapack-rs/blas",
package_version = "0.22.0",
)

license(
name = "license",
license_kinds = [
"@rules_license//licenses/spdx:Apache-2.0",
"@rules_license//licenses/spdx:MIT",
],
license_text = "LICENSE.md",
)

rust_library(
name = "blas",
srcs = glob(["**/*.rs"]),
srcs = glob(
include = ["**/*.rs"],
allow_empty = False,
),
compile_data = glob(
include = ["**"],
allow_empty = True,
exclude = [
"**/* *",
".tmp_git_root/**/*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,42 @@
###############################################################################

load("@rules_rust//rust:defs.bzl", "rust_library")
load("@rules_license//rules:license.bzl", "license")
load("@rules_license//rules:package_info.bzl", "package_info")

package(default_visibility = ["//visibility:public"])
package(
default_package_metadata = [
":license",
":package_info",
],
default_visibility = ["//visibility:public"],
)

# licenses([
# "TODO", # Apache-2.0/MIT
# ])
filegroup(
name = "license_glob",
srcs = glob(
["LICENSE*"],
allow_empty = False,
),
package_info(
name = "package_info",
package_name = "blas-sys",
package_url = "https://github.com/blas-lapack-rs/blas-sys",
package_version = "0.7.1",
)

license(
name = "license",
license_kinds = [
"@rules_license//licenses/spdx:Apache-2.0",
"@rules_license//licenses/spdx:MIT",
],
license_text = "LICENSE.md",
)

rust_library(
name = "blas_sys",
srcs = glob(["**/*.rs"]),
srcs = glob(
include = ["**/*.rs"],
allow_empty = False,
),
compile_data = glob(
include = ["**"],
allow_empty = True,
exclude = [
"**/* *",
".tmp_git_root/**/*",
Expand Down
Loading

0 comments on commit bbafc14

Please sign in to comment.