forked from bazelbuild/bazel-skylib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use
apparent_repo_name
only for repository_ctx
Repurposed `apparent_repo_name` to only work with `repository_ctx` objects after finding solutions to other repository name related problems in bazelbuild/rules_scala#1621. The one problem I couldn't solve (elegantly) without this function was setting a default target name for a generated repo. Technically, such repos could require an attribute to mirror `name`, but that seems like a terrible user experience.
- Loading branch information
Showing
6 changed files
with
84 additions
and
105 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
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,22 @@ | ||
"""Repo rule and module extension used to test modules.apparent_repo_name""" | ||
|
||
load("//lib:modules.bzl", "modules") | ||
|
||
def _apparent_repo_name_test_repo_impl(repository_ctx): | ||
repo_name = modules.apparent_repo_name(repository_ctx) | ||
test_file = "repo-name.bzl" | ||
repository_ctx.file("WORKSPACE") | ||
repository_ctx.file("BUILD", """exports_files(["%s"])""" % test_file) | ||
repository_ctx.file(test_file, "REPO_NAME = \"%s\"" % repo_name) | ||
|
||
apparent_repo_name_test_repo = repository_rule( | ||
_apparent_repo_name_test_repo_impl, | ||
) | ||
|
||
def apparent_repo_name_test_macro(*args): | ||
apparent_repo_name_test_repo(name = "apparent-repo-name-test") | ||
|
||
apparent_repo_name_test_ext = module_extension( | ||
lambda _: apparent_repo_name_test_macro(), | ||
doc = "Only used for testing modules.apparent_repo_name()", | ||
) |
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