Skip to content

Commit 523fa03

Browse files
committed
Skip hub alias for workspace-root members
1 parent d85c4b6 commit 523fa03

6 files changed

Lines changed: 40 additions & 0 deletions

File tree

rs/extensions.bzl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,12 @@ alias(
484484
for package in cargo_metadata["packages"]:
485485
package_dir = _manifest_package_dir(package["manifest_path"], repo_root)
486486
bazel_package = paths.join(workspace_package, package_dir).removesuffix("/")
487+
if not bazel_package:
488+
# The alias relies on Bazel's `//foo/bar` -> `//foo/bar:bar`
489+
# shorthand to pick a target name. When the workspace member is
490+
# at the bazel workspace root, there's no path component to
491+
# derive a name from.
492+
continue
487493
hub_contents.append("""
488494
alias(
489495
name = "{name}-{version}",

test/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ filegroup(
333333
"@binaries//:protoc-gen-prost-extra",
334334
"@binaries//:protoc-gen-prost__protoc-gen-prost",
335335
"@binary_only//:b3sum__b3sum",
336+
"@root_package//:_workspace_deps",
336337
] + select({
337338
"@platforms//os:windows": [],
338339
"//conditions:default": [

test/Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "root_pkg"
3+
version = "0.1.0"
4+
edition = "2021"
5+
publish = false
6+
7+
[lib]
8+
path = "lib.rs"

test/MODULE.bazel

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,24 @@ TESTS = [
184184

185185
[use_repo(crate, test) for test in TESTS]
186186

187+
# Workspace member whose Cargo.toml lives at the bazel workspace root.
188+
crate.from_cargo(
189+
name = "root_package",
190+
cargo_lock = "//:Cargo.lock",
191+
cargo_toml = "//:Cargo.toml",
192+
debug = True,
193+
platform_triples = [
194+
"aarch64-unknown-linux-gnu",
195+
"aarch64-apple-darwin",
196+
"aarch64-pc-windows-gnullvm",
197+
"x86_64-unknown-linux-gnu",
198+
"x86_64-apple-darwin",
199+
"x86_64-pc-windows-gnullvm",
200+
],
201+
)
202+
203+
use_repo(crate, "root_package")
204+
187205
crate.annotation(
188206
crate = "rustls",
189207
# Test for https://github.com/bazelbuild/rules_rust/issues/3626

test/lib.rs

Whitespace-only changes.

0 commit comments

Comments
 (0)