-
Notifications
You must be signed in to change notification settings - Fork 424
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Bzlmod allow modules to rename their dependencies and use the aliased names in runfiles lookups. | ||
This test defines the following dependency tree: A -> B -> C. The test if whether a binary built in A | ||
that calls code in B that has an `rlocation!` call to lookup a runfile from C is able to correctly use | ||
B's repo_mapping. This is accomplished by having B use a custom `repo_name` for C. |
This file contains 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
bazel-* |
This file contains 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test") | ||
|
||
rust_library( | ||
name = "lib", | ||
srcs = ["lib.rs"], | ||
deps = ["@module_b//:lib_b"], | ||
) | ||
|
||
rust_test( | ||
name = "lib_test", | ||
crate = ":lib", | ||
) |
This file contains 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module(name = "module_a") | ||
|
||
local_path_override(module_name = "module_b", path = "../module_b") | ||
local_path_override(module_name = "module_c", path = "../module_c") | ||
|
||
bazel_dep(name = "module_b", version = "0.0.0") | ||
|
||
bazel_dep(name = "rules_rust", version = "0.0.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") | ||
|
||
register_toolchains("@rust_toolchains//:all") |
This file contains 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#[cfg(test)] | ||
mod test { | ||
#[test] | ||
fn test_repo_remapping() { | ||
let data = lib_b::read_file_from_module_c(); | ||
assert_eq!(data, "module(name = \"module_c\")"); | ||
} | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
load("@rules_rust//rust:defs.bzl", "rust_library") | ||
|
||
rust_library( | ||
name = "lib_b", | ||
srcs = ["lib.rs"], | ||
data = ["@aliased_c//:MODULE.bazel"], | ||
deps = ["@rules_rust//tools/runfiles"], | ||
visibility = ["//visibility:public"], | ||
) |
This file contains 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module(name = "module_b") | ||
|
||
bazel_dep(name = "module_c", version = "0.0.0", repo_name = "aliased_c") | ||
bazel_dep(name = "rules_rust", version = "0.0.0") | ||
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust") | ||
rust.toolchain(edition = "2021") | ||
use_repo(rust, "rust_toolchains") | ||
|
||
register_toolchains("@rust_toolchains//:all") |
This file contains 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use runfiles::Runfiles; | ||
|
||
pub fn read_file_from_module_c() -> String { | ||
let r = Runfiles::create().unwrap(); | ||
std::fs::read_to_string(runfiles::rlocation!(r, "aliased_c/MODULE.bazel")).unwrap() | ||
} |
This file contains 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
exports_files(["MODULE.bazel"]) |
This file contains 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
module(name = "module_c") |