1"""Dependencies for Rust prost rules""" 2 3load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 4load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") 5load("//proto/prost/private/3rdparty/crates:crates.bzl", "crate_repositories") 6 7def rust_prost_dependencies(bzlmod = False): 8 """Declares repositories needed for prost. 9 10 Args: 11 bzlmod (bool): Whether bzlmod is enabled. 12 13 Returns: 14 list[struct(repo=str, is_dev_dep=bool)]: A list of the repositories 15 defined by this macro. 16 """ 17 18 direct_deps = [ 19 struct(repo = "rules_rust_prost__heck", is_dev_dep = False), 20 ] 21 if bzlmod: 22 # Without bzlmod, this function is normally called by the 23 # rust_prost_dependencies function in the private directory. 24 # However, the private directory is inaccessible, plus there's no 25 # reason to keep two rust_prost_dependencies functions with bzlmod. 26 direct_deps.extend(crate_repositories()) 27 else: 28 maybe( 29 http_archive, 30 name = "rules_proto", 31 sha256 = "dc3fb206a2cb3441b485eb1e423165b231235a1ea9b031b4433cf7bc1fa460dd", 32 strip_prefix = "rules_proto-5.3.0-21.7", 33 urls = [ 34 "https://mirror.bazel.build/github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.7.tar.gz", 35 "https://github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.7.tar.gz", 36 ], 37 ) 38 39 maybe( 40 http_archive, 41 name = "com_google_protobuf", 42 sha256 = "52b6160ae9266630adb5e96a9fc645215336371a740e87d411bfb63ea2f268a0", 43 strip_prefix = "protobuf-3.18.0", 44 urls = ["https://github.com/protocolbuffers/protobuf/releases/download/v3.18.0/protobuf-all-3.18.0.tar.gz"], 45 ) 46 47 maybe( 48 http_archive, 49 name = "rules_rust_prost__heck", 50 sha256 = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8", 51 type = "tar.gz", 52 urls = ["https://crates.io/api/v1/crates/heck/0.4.1/download"], 53 strip_prefix = "heck-0.4.1", 54 build_file = Label("@rules_rust//proto/prost/private/3rdparty/crates:BUILD.heck-0.4.1.bazel"), 55 ) 56 return direct_deps 57