Swift: add json and date dependencies

This commit is contained in:
Paolo Tranquilli
2023-05-02 17:54:07 +02:00
parent b56b843d13
commit c7c12a7108
9 changed files with 43 additions and 31 deletions

View File

@@ -43,13 +43,3 @@ def codeql_workspace(repository_name = "codeql"):
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.1/bazel-skylib-1.4.1.tar.gz",
],
)
maybe(
repo_rule = http_archive,
name = "absl",
sha256 = "cec2e5bf780532bd0ac672eb8d43c0f8bbe84ca5df8718320184034b7f59a398",
urls = [
"https://github.com/abseil/abseil-cpp/archive/d2c5297a3c3948de765100cb7e5cccca1210d23c.tar.gz",
],
strip_prefix = "abseil-cpp-d2c5297a3c3948de765100cb7e5cccca1210d23c",
)

View File

@@ -3,5 +3,8 @@ cc_library(
srcs = glob(["*.cpp"]),
hdrs = glob(["*.h"]),
visibility = ["//visibility:public"],
deps = ["@binlog"],
deps = [
"@binlog",
"@json",
],
)

6
swift/third_party/BUILD.date.bazel vendored Normal file
View File

@@ -0,0 +1,6 @@
cc_library(
name = "date",
hdrs = glob(["include/date/*.h"]),
includes = ["include"],
visibility = ["//visibility:public"],
)

View File

View File

@@ -1,4 +1,5 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
_swift_prebuilt_version = "swift-5.7.3-RELEASE.142"
_swift_sha_map = {
@@ -12,28 +13,20 @@ _swift_arch_map = {
"macOS-X64": "darwin_x86_64",
}
def _get_label(workspace_name, package, target):
return "@%s//swift/third_party/%s:%s" % (workspace_name, package, target)
def _get_build(workspace_name, package):
return _get_label(workspace_name, package, "BUILD.%s.bazel" % package)
def _get_patch(workspace_name, package, patch):
return _get_label(workspace_name, package, "patches/%s.patch" % patch)
def _github_archive(*, name, workspace_name, repository, commit, sha256 = None, patches = None):
def _github_archive(*, name, repository, commit, build_file = None, sha256 = None):
github_name = repository[repository.index("/") + 1:]
patches = [_get_patch(workspace_name, name, p) for p in patches or []]
http_archive(
maybe(
repo_rule = http_archive,
name = name,
url = "https://github.com/%s/archive/%s.zip" % (repository, commit),
strip_prefix = "%s-%s" % (github_name, commit),
build_file = _get_build(workspace_name, name),
build_file = build_file,
sha256 = sha256,
patch_args = ["-p1"],
patches = patches,
)
def _build(workspace_name, package):
return "@%s//swift/third_party:BUILD.%s.bazel" % (workspace_name, package)
def load_dependencies(workspace_name):
for repo_arch, arch in _swift_arch_map.items():
sha256 = _swift_sha_map[repo_arch]
@@ -44,15 +37,13 @@ def load_dependencies(workspace_name):
_swift_prebuilt_version,
repo_arch,
),
build_file = _get_build(workspace_name, "swift-llvm-support"),
build_file = _build(workspace_name, "swift-llvm-support"),
sha256 = sha256,
patch_args = ["-p1"],
patches = [],
)
_github_archive(
name = "picosha2",
workspace_name = workspace_name,
build_file = _build(workspace_name, "picosha2"),
repository = "okdshin/PicoSHA2",
commit = "27fcf6979298949e8a462e16d09a0351c18fcaf2",
sha256 = "d6647ca45a8b7bdaf027ecb68d041b22a899a0218b7206dee755c558a2725abb",
@@ -60,8 +51,30 @@ def load_dependencies(workspace_name):
_github_archive(
name = "binlog",
workspace_name = workspace_name,
build_file = _build(workspace_name, "binlog"),
repository = "morganstanley/binlog",
commit = "3fef8846f5ef98e64211e7982c2ead67e0b185a6",
sha256 = "f5c61d90a6eff341bf91771f2f465be391fd85397023e1b391c17214f9cbd045",
)
_github_archive(
name = "absl",
repository = "abseil/abseil-cpp",
commit = "d2c5297a3c3948de765100cb7e5cccca1210d23c",
sha256 = "735a9efc673f30b3212bfd57f38d5deb152b543e35cd58b412d1363b15242049",
)
_github_archive(
name = "json",
repository = "nlohmann/json",
commit = "6af826d0bdb55e4b69e3ad817576745335f243ca",
sha256 = "702bb0231a5e21c0374230fed86c8ae3d07ee50f34ffd420e7f8249854b7d85b",
)
_github_archive(
name = "date",
build_file = _build(workspace_name, "date"),
repository = "HowardHinnant/date",
commit = "6e921e1b1d21e84a5c82416ba7ecd98e33a436d0",
sha256 = "484c450ea1cec479716f7cfce9a54da1867dd4043dde08e7c262b812561fe3bc",
)