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