-
Notifications
You must be signed in to change notification settings - Fork 402
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed regression in
load_arbitrary_tool
causing it to require attri…
…butes repository rules that call it. (#554) In #545 I fixed an issue where `load_arbitrary_tool` could not be used in repository rules that did not specify particular attributes. This issue was then reintroduced in #551. This PR fixes the issue again and adds a test to prevent this from happening again in the future.
- Loading branch information
1 parent
8c388e1
commit 8826d30
Showing
5 changed files
with
72 additions
and
4 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
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 @@ | ||
"""A module defining dependencies of the `io_bazel_rules_rust` tests""" | ||
|
||
load("//test/load_arbitrary_tool:load_arbitrary_tool_test.bzl", "load_arbitrary_tool_test") | ||
|
||
def io_bazel_rules_rust_test_deps(): | ||
"""Load dependencies for io_bazel_rules_rust tests""" | ||
|
||
load_arbitrary_tool_test() |
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 @@ | ||
load("@bazel_skylib//rules:build_test.bzl", "build_test") | ||
|
||
filegroup( | ||
name = "load_arbitrary_tool_test_src", | ||
srcs = [ | ||
"@io_bazel_rules_rust_load_arbitrary_tool_test//:bin/cargo", | ||
], | ||
) | ||
|
||
build_test( | ||
name = "load_arbitrary_tool_test", | ||
targets = [ | ||
":load_arbitrary_tool_test_src", | ||
], | ||
) |
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,40 @@ | ||
# buildifier: disable=module-docstring | ||
load("//rust:repositories.bzl", "load_arbitrary_tool") | ||
|
||
def _load_arbitrary_tool_test_impl(repository_ctx): | ||
if "mac" in repository_ctx.os.name: | ||
target_triple = "x86_64-apple-darwin" | ||
elif "windows" in repository_ctx.os.name: | ||
target_triple = "x86_64-pc-windows-msvc" | ||
else: | ||
target_triple = "x86_64-unknown-linux-gnu" | ||
|
||
# Download cargo | ||
load_arbitrary_tool( | ||
ctx = repository_ctx, | ||
tool_name = "cargo", | ||
tool_subdirectories = ["cargo"], | ||
version = "1.49.0", | ||
iso_date = None, | ||
target_triple = target_triple, | ||
) | ||
|
||
repo_path = repository_ctx.path(".") | ||
repository_ctx.file( | ||
"{}/BUILD.bazel".format(repo_path), | ||
content = "exports_files([\"bin/cargo\"])", | ||
) | ||
|
||
_load_arbitrary_tool_test = repository_rule( | ||
implementation = _load_arbitrary_tool_test_impl, | ||
doc = ( | ||
"A test repository rule ensuring `load_arbitrary_tool` functions " + | ||
"without requiring any attributes on a repository rule" | ||
), | ||
) | ||
|
||
def load_arbitrary_tool_test(): | ||
"""Define the a test repository for ensuring `load_arbitrary_tool` has no attribute requirements""" | ||
_load_arbitrary_tool_test( | ||
name = "io_bazel_rules_rust_load_arbitrary_tool_test", | ||
) |