|
14 | 14 | #
|
15 | 15 | # SPDX-License-Identifier: Apache-2.0
|
16 | 16 |
|
| 17 | +load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository") |
17 | 18 | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
18 |
| -load(":repository_locations.bzl", "REPOSITORY_LOCATIONS") |
| 19 | +load(":repository_locations.bzl", "GIT_REPOSITORY_LOCATIONS", "REPOSITORY_LOCATIONS") |
19 | 20 |
|
20 | 21 | # Make all contents of an external repository accessible under a filegroup.
|
21 | 22 | # Used for external HTTP archives, e.g. cares.
|
@@ -43,6 +44,30 @@ def _repo_impl(name, **kwargs):
|
43 | 44 | **kwargs
|
44 | 45 | )
|
45 | 46 |
|
| 47 | +def _git_repo_impl(name, **kwargs): |
| 48 | + # `existing_rule_keys` contains the names of repositories that have already |
| 49 | + # been defined in the Bazel workspace. By skipping repos with existing keys, |
| 50 | + # users can override dependency versions by using standard Bazel repository |
| 51 | + # rules in their WORKSPACE files. |
| 52 | + existing_rule_keys = native.existing_rules().keys() |
| 53 | + if name in existing_rule_keys: |
| 54 | + # This repository has already been defined, probably because the user |
| 55 | + # wants to override the version. Do nothing. |
| 56 | + return |
| 57 | + |
| 58 | + location = GIT_REPOSITORY_LOCATIONS[name] |
| 59 | + |
| 60 | + # HTTP tarball at a given URL. Add a BUILD file if requested. |
| 61 | + new_git_repository( |
| 62 | + name = name, |
| 63 | + remote = location["remote"], |
| 64 | + commit = location["commit"], |
| 65 | + init_submodules = True, |
| 66 | + recursive_init_submodules = True, |
| 67 | + shallow_since = location.get("shallow_since", ""), |
| 68 | + **kwargs |
| 69 | + ) |
| 70 | + |
46 | 71 | # For bazel repos do not require customization.
|
47 | 72 | def _bazel_repo(name, **kwargs):
|
48 | 73 | _repo_impl(name, **kwargs)
|
@@ -83,6 +108,8 @@ def _cc_deps():
|
83 | 108 | _include_all_repo("com_github_libuv_libuv", patches = ["//bazel/external:libuv.patch"], patch_args = ["-p1"])
|
84 | 109 | _include_all_repo("com_github_libarchive_libarchive")
|
85 | 110 |
|
| 111 | + _git_repo_impl("com_github_iovisor_bcc", build_file = "//bazel/external:bcc.BUILD") |
| 112 | + |
86 | 113 | _repo_impl("com_github_apache_arrow", build_file = "//bazel/external:arrow.BUILD")
|
87 | 114 | _repo_impl("com_github_ariafallah_csv_parser", build_file = "//bazel/external:csv_parser.BUILD")
|
88 | 115 | _repo_impl("com_github_arun11299_cpp_jwt", build_file = "//bazel/external:cpp_jwt.BUILD")
|
@@ -119,6 +146,12 @@ def list_pl_deps(name):
|
119 | 146 | best_url = url
|
120 | 147 | repo_urls.append(best_url)
|
121 | 148 |
|
| 149 | + for repo_name, repo_config in GIT_REPOSITORY_LOCATIONS.items(): |
| 150 | + remote = repo_config["remote"] |
| 151 | + if remote.endswith(".git"): |
| 152 | + remote = remote[:-len(".git")] |
| 153 | + repo_urls.append(remote) |
| 154 | + |
122 | 155 | native.genrule(
|
123 | 156 | name = name,
|
124 | 157 | outs = ["{}.out".format(name)],
|
|
0 commit comments