Skip to content

Commit 85968e3

Browse files
authored
Merge pull request github#16178 from github/redsun82/swift-deps-extension-all
Bazel: `swift/third_party/load.bzl` cleanup and `bazel mod tidy` enablement
2 parents 33f6b6a + 05f5879 commit 85968e3

File tree

2 files changed

+14
-32
lines changed

2 files changed

+14
-32
lines changed

MODULE.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ pip.parse(
3131
use_repo(pip, "codegen_deps")
3232

3333
swift_deps = use_extension("//swift/third_party:load.bzl", "swift_deps")
34+
35+
# following list can be kept in sync with `bazel mod tidy`
3436
use_repo(
3537
swift_deps,
3638
"binlog",

swift/third_party/load.bzl

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def _get_toolchain_url(info):
4040
info.extension,
4141
)
4242

43-
def _toolchains(repository_name):
43+
def _toolchains():
4444
rules = {
4545
"tar.gz": http_archive,
4646
"pkg": _pkg_archive,
@@ -51,7 +51,7 @@ def _toolchains(repository_name):
5151
name = "swift_toolchain_%s" % arch,
5252
url = _get_toolchain_url(info),
5353
sha256 = info.sha,
54-
build_file = _build(repository_name, "swift-toolchain-%s" % arch),
54+
build_file = _build % "swift-toolchain-%s" % arch,
5555
strip_prefix = "%s-%s" % (_swift_version, info.suffix),
5656
)
5757

@@ -109,10 +109,9 @@ def _github_archive(*, name, repository, commit, build_file = None, sha256 = Non
109109
sha256 = sha256,
110110
)
111111

112-
def _build(repository_name, package):
113-
return "@%s//swift/third_party:BUILD.%s.bazel" % (repository_name, package)
112+
_build = "//swift/third_party:BUILD.%s.bazel"
114113

115-
def load_dependencies(module_ctx = None, repository_name = "codeql"):
114+
def load_dependencies(module_ctx):
116115
for repo_arch, arch in _swift_arch_map.items():
117116
sha256 = _swift_sha_map[repo_arch]
118117

@@ -122,50 +121,31 @@ def load_dependencies(module_ctx = None, repository_name = "codeql"):
122121
_swift_prebuilt_version,
123122
repo_arch,
124123
),
125-
build_file = _build(repository_name, "swift-llvm-support"),
124+
build_file = _build % "swift-llvm-support",
126125
sha256 = sha256,
127126
)
128127

129-
_toolchains(repository_name)
128+
_toolchains()
130129

131130
_github_archive(
132131
name = "picosha2",
133-
build_file = _build(repository_name, "picosha2"),
132+
build_file = _build % "picosha2",
134133
repository = "okdshin/PicoSHA2",
135134
commit = "27fcf6979298949e8a462e16d09a0351c18fcaf2",
136135
sha256 = "d6647ca45a8b7bdaf027ecb68d041b22a899a0218b7206dee755c558a2725abb",
137136
)
138137

139138
_github_archive(
140139
name = "binlog",
141-
build_file = _build(repository_name, "binlog"),
140+
build_file = _build % "binlog",
142141
repository = "morganstanley/binlog",
143142
commit = "3fef8846f5ef98e64211e7982c2ead67e0b185a6",
144143
sha256 = "f5c61d90a6eff341bf91771f2f465be391fd85397023e1b391c17214f9cbd045",
145144
)
146145

147-
if module_ctx == None:
148-
# legacy workspace loading, remove when transition is complete
149-
_github_archive(
150-
name = "absl",
151-
repository = "abseil/abseil-cpp",
152-
commit = "d2c5297a3c3948de765100cb7e5cccca1210d23c",
153-
sha256 = "735a9efc673f30b3212bfd57f38d5deb152b543e35cd58b412d1363b15242049",
154-
)
155-
156-
_github_archive(
157-
name = "json",
158-
repository = "nlohmann/json",
159-
commit = "6af826d0bdb55e4b69e3ad817576745335f243ca",
160-
sha256 = "702bb0231a5e21c0374230fed86c8ae3d07ee50f34ffd420e7f8249854b7d85b",
161-
)
162-
163-
_github_archive(
164-
name = "fmt",
165-
repository = "fmtlib/fmt",
166-
build_file = _build(repository_name, "fmt"),
167-
commit = "a0b8a92e3d1532361c2f7feb63babc5c18d00ef2",
168-
sha256 = "ccf872fd4aa9ab3d030d62cffcb258ca27f021b2023a0244b2cf476f984be955",
169-
)
146+
return module_ctx.extension_metadata(
147+
root_module_direct_deps = "all",
148+
root_module_direct_dev_deps = [],
149+
)
170150

171151
swift_deps = module_extension(load_dependencies)

0 commit comments

Comments
 (0)