| 1 |
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") |
| 2 |
|
| 3 |
def xds_http_archive(name, locations, **kwargs): |
| 4 |
# `existing_rule_keys` contains the names of repositories that have already |
| 5 |
# been defined in the Bazel workspace. By skipping repos with existing keys, |
| 6 |
# users can override dependency versions by using standard Bazel repository |
| 7 |
# rules in their WORKSPACE files. |
| 8 |
existing_rule_keys = native.existing_rules().keys() |
| 9 |
if name in existing_rule_keys: |
| 10 |
# This repository has already been defined, probably because the user |
| 11 |
# wants to override the version. Do nothing. |
| 12 |
return |
| 13 |
|
| 14 |
loc_key = kwargs.pop("repository_key", name) |
| 15 |
location = locations[loc_key] |
| 16 |
|
| 17 |
# HTTP tarball at a given URL. Add a BUILD file if requested. |
| 18 |
http_archive( |
| 19 |
name = name, |
| 20 |
urls = location["urls"], |
| 21 |
sha256 = location["sha256"], |
| 22 |
strip_prefix = location.get("strip_prefix", ""), |
| 23 |
**kwargs |
| 24 |
) |
| 25 |
|
| 26 |
# Old name for backward compatibility. |
| 27 |
# TODO(roth): Remove once all callers are changed to use the new name. |
| 28 |
def udpa_http_archive(name, locations, **kwargs): |
| 29 |
xds_http_archive(name, locations, **kwargs) |