Skip to content

Commit ecfcb1f

Browse files
authored
Expose extension for Git toolchain (#967)
This move all toolchains into the rules_pkg_git repo. * Expose extension * Use extension in MODULE.bazel
1 parent 5a77a59 commit ecfcb1f

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

MODULE.bazel

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ register_toolchains(
2525
dev_dependency = True,
2626
)
2727

28+
# Find the system Git if one is available.
29+
find_git = use_extension("//toolchains/git:git_configure.bzl", "experimental_find_system_git_extension", dev_dependency = True)
30+
use_repo(find_git, "rules_pkg_git")
31+
32+
register_toolchains(
33+
"@rules_pkg_git//:all",
34+
dev_dependency = True,
35+
)
36+
2837
local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository")
2938

3039
local_repository(

WORKSPACE.bzlmod

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,3 @@ local_repository(
1313
# name = "rules_pkg_rpmbuild",
1414
# verbose = False,
1515
#)
16-
17-
# Needed for making our release notes
18-
load("//toolchains/git:git_configure.bzl", "experimental_find_system_git_bzlmod")
19-
20-
experimental_find_system_git_bzlmod(
21-
name = "rules_pkg_git",
22-
verbose = False,
23-
)
24-
25-
register_toolchains(
26-
"@rules_pkg_git//:git_auto_toolchain",
27-
"//toolchains/git:git_missing_toolchain",
28-
)

toolchains/git/BUILD

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,3 @@ toolchain_type(
6767
git_toolchain(
6868
name = "no_git",
6969
)
70-
71-
toolchain(
72-
name = "git_missing_toolchain",
73-
toolchain = ":no_git",
74-
toolchain_type = ":git_toolchain_type",
75-
)

toolchains/git/BUILD.tpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,9 @@ toolchain(
1414
toolchain = ":git_auto",
1515
toolchain_type = "@rules_pkg//toolchains/git:git_toolchain_type",
1616
)
17+
18+
toolchain(
19+
name = "zzz_git_missing_toolchain", # keep name lexicographically last
20+
toolchain = "@rules_pkg//toolchains/git:no_git",
21+
toolchain_type = "@rules_pkg//toolchains/git:git_toolchain_type",
22+
)

toolchains/git/git_configure.bzl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ def experimental_find_system_git(name, workspace_file = None, verbose = False):
7474
workspace_file = Label("//:WORKSPACE")
7575
_find_system_git(name = name, workspace_file = workspace_file, verbose = verbose)
7676
native.register_toolchains(
77-
"@%s//:git_auto_toolchain" % name,
78-
"@rules_pkg//toolchains/git:git_missing_toolchain",
77+
"@%s//:all" % name,
7978
)
8079

8180
# buildifier: disable=function-docstring-args
@@ -93,3 +92,8 @@ def experimental_find_system_git_bzlmod(name, workspace_file = None, verbose = F
9392
if not workspace_file:
9493
workspace_file = Label("//:MODULE.bazel")
9594
_find_system_git(name = name, workspace_file = workspace_file, verbose = verbose)
95+
96+
# For use from MODULE.bzl
97+
experimental_find_system_git_extension = module_extension(
98+
implementation = lambda ctx: _find_system_git(name = "rules_pkg_git", workspace_file = Label("//:MODULE.bazel")),
99+
)

0 commit comments

Comments
 (0)