xref: /aosp_15_r20/external/bazelbuild-rules_rust/crate_universe/deps_bootstrap.bzl (revision d4726bddaa87cc4778e7472feed243fa4b6c267f)
1*d4726bddSHONG Yifan"""A module is used to assist in bootstrapping cargo-bazel"""
2*d4726bddSHONG Yifan
3*d4726bddSHONG Yifanload("//cargo:defs.bzl", "cargo_bootstrap_repository")
4*d4726bddSHONG Yifanload("//crate_universe/private:srcs.bzl", "CARGO_BAZEL_SRCS")
5*d4726bddSHONG Yifan
6*d4726bddSHONG Yifan# buildifier: disable=bzl-visibility
7*d4726bddSHONG Yifanload("//rust/private:common.bzl", "rust_common")
8*d4726bddSHONG Yifan
9*d4726bddSHONG Yifandef cargo_bazel_bootstrap(name = "cargo_bazel_bootstrap", rust_version = rust_common.default_version, **kwargs):
10*d4726bddSHONG Yifan    """An optional repository which bootstraps `cargo-bazel` for use with `crates_repository`
11*d4726bddSHONG Yifan
12*d4726bddSHONG Yifan    Args:
13*d4726bddSHONG Yifan        name (str, optional): The name of the `cargo_bootstrap_repository`.
14*d4726bddSHONG Yifan        rust_version (str, optional): The rust version to use. Defaults to the default of `cargo_bootstrap_repository`.
15*d4726bddSHONG Yifan        **kwargs: kwargs to pass through to cargo_bootstrap_repository.
16*d4726bddSHONG Yifan    """
17*d4726bddSHONG Yifan    cargo_bootstrap_repository(
18*d4726bddSHONG Yifan        name = name,
19*d4726bddSHONG Yifan        srcs = CARGO_BAZEL_SRCS,
20*d4726bddSHONG Yifan        binary = "cargo-bazel",
21*d4726bddSHONG Yifan        cargo_lockfile = "@rules_rust//crate_universe:Cargo.lock",
22*d4726bddSHONG Yifan        cargo_toml = "@rules_rust//crate_universe:Cargo.toml",
23*d4726bddSHONG Yifan        version = rust_version,
24*d4726bddSHONG Yifan        # The increased timeout helps avoid flakes in CI
25*d4726bddSHONG Yifan        timeout = 900,
26*d4726bddSHONG Yifan        **kwargs
27*d4726bddSHONG Yifan    )
28