Skip to content

Commit 219ed64

Browse files
committed
Swift: reorganize bazel third party dependencies
1 parent 6fa2fe6 commit 219ed64

File tree

4 files changed

+54
-40
lines changed

4 files changed

+54
-40
lines changed

misc/bazel/workspace.bzl

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,9 @@
11
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
22
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
3-
4-
_swift_prebuilt_version = "swift-5.7.1-RELEASE.44428.89"
5-
_swift_sha_map = {
6-
"Linux-X64": "1fa0b62b3a87c6528bd21b3f3fa1b32ad00e2b6ff04c20652c93c7d00c4cf517",
7-
"macOS-X64": "6e1239335874cbde635ae9ca9eeb215efee4988888a75f4eda1abbcf97e4d038",
8-
}
9-
10-
_swift_arch_map = {
11-
"Linux-X64": "linux",
12-
"macOS-X64": "darwin_x86_64",
13-
}
3+
load("//swift/third_party:load.bzl", load_swift_dependencies = "load_dependencies")
144

155
def codeql_workspace(repository_name = "codeql"):
16-
for repo_arch, arch in _swift_arch_map.items():
17-
sha256 = _swift_sha_map[repo_arch]
18-
19-
http_archive(
20-
name = "swift_prebuilt_%s" % arch,
21-
url = "https://github.com/dsp-testing/codeql-swift-artifacts/releases/download/%s/swift-prebuilt-%s.zip" % (
22-
_swift_prebuilt_version,
23-
repo_arch,
24-
),
25-
build_file = "@%s//swift/third_party/swift-llvm-support:BUILD.swift-prebuilt.bazel" % repository_name,
26-
sha256 = sha256,
27-
)
28-
29-
http_archive(
30-
name = "fishhook",
31-
url = "https://github.com/facebook/fishhook/archive/aadc161ac3b80db07a9908851839a17ba63a9eb1.zip",
32-
build_file = "@%s//swift/third_party/fishhook:BUILD.fishhook.bazel" % repository_name,
33-
strip_prefix = "fishhook-aadc161ac3b80db07a9908851839a17ba63a9eb1",
34-
sha256 = "9f2cdee6dcc2039d4c47d25ab5141fe0678ce6ed27ef482cab17fe9fa38a30ce",
35-
)
36-
37-
http_archive(
38-
name = "picosha2",
39-
url = "https://github.com/okdshin/PicoSHA2/archive/27fcf6979298949e8a462e16d09a0351c18fcaf2.zip",
40-
strip_prefix = "PicoSHA2-27fcf6979298949e8a462e16d09a0351c18fcaf2",
41-
build_file = "@%s//swift/third_party/picosha2:BUILD.picosha2.bazel" % repository_name,
42-
sha256 = "d6647ca45a8b7bdaf027ecb68d041b22a899a0218b7206dee755c558a2725abb",
43-
)
44-
6+
load_swift_dependencies(repository_name)
457
maybe(
468
repo_rule = http_archive,
479
name = "rules_pkg",

swift/third_party/BUILD.bazel

Whitespace-only changes.

swift/third_party/load.bzl

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
2+
3+
_swift_prebuilt_version = "swift-5.7.1-RELEASE.44428.89"
4+
_swift_sha_map = {
5+
"Linux-X64": "1fa0b62b3a87c6528bd21b3f3fa1b32ad00e2b6ff04c20652c93c7d00c4cf517",
6+
"macOS-X64": "6e1239335874cbde635ae9ca9eeb215efee4988888a75f4eda1abbcf97e4d038",
7+
}
8+
9+
_swift_arch_map = {
10+
"Linux-X64": "linux",
11+
"macOS-X64": "darwin_x86_64",
12+
}
13+
14+
def _get_label(repository_name, package, target):
15+
return "@%s//swift/third_party/%s:%s" % (repository_name, package, target)
16+
17+
def _get_build(repository_name, package):
18+
return _get_label(repository_name, package, "BUILD.%s.bazel" % package)
19+
20+
def _get_patch(repository_name, package, patch):
21+
return _get_label(repository_name, package, "patches/%s.patch" % patch)
22+
23+
def load_dependencies(repository_name):
24+
for repo_arch, arch in _swift_arch_map.items():
25+
sha256 = _swift_sha_map[repo_arch]
26+
27+
http_archive(
28+
name = "swift_prebuilt_%s" % arch,
29+
url = "https://github.com/dsp-testing/codeql-swift-artifacts/releases/download/%s/swift-prebuilt-%s.zip" % (
30+
_swift_prebuilt_version,
31+
repo_arch,
32+
),
33+
build_file = _get_build(repository_name, "swift-llvm-support"),
34+
sha256 = sha256,
35+
patch_args = ["-p1"],
36+
)
37+
38+
http_archive(
39+
name = "fishhook",
40+
url = "https://github.com/facebook/fishhook/archive/aadc161ac3b80db07a9908851839a17ba63a9eb1.zip",
41+
build_file = "@%s//swift/third_party/fishhook:BUILD.fishhook.bazel" % repository_name,
42+
strip_prefix = "fishhook-aadc161ac3b80db07a9908851839a17ba63a9eb1",
43+
sha256 = "9f2cdee6dcc2039d4c47d25ab5141fe0678ce6ed27ef482cab17fe9fa38a30ce",
44+
)
45+
46+
http_archive(
47+
name = "picosha2",
48+
url = "https://github.com/okdshin/PicoSHA2/archive/27fcf6979298949e8a462e16d09a0351c18fcaf2.zip",
49+
strip_prefix = "PicoSHA2-27fcf6979298949e8a462e16d09a0351c18fcaf2",
50+
build_file = _get_build(repository_name, "picosha2"),
51+
sha256 = "d6647ca45a8b7bdaf027ecb68d041b22a899a0218b7206dee755c558a2725abb",
52+
)

0 commit comments

Comments
 (0)