fork/rules_rust

git clone https://git.julia.blue/fork/rules_rust

UebelAndreRenamed `crate_index` repository to `crate_universe_crate_index` (#1217)e48c834a

0.6.0
2.4 KiB70 linesraw
1"""A module defining dependencies of the `cargo-bazel` Rust target"""
2
3load("@rules_rust//rust:defs.bzl", "rust_common")
4load("//crate_universe:deps_bootstrap.bzl", "cargo_bazel_bootstrap")
5load("//crate_universe/3rdparty:third_party_deps.bzl", "third_party_deps")
6load("//crate_universe/3rdparty/crates:crates.bzl", _vendor_crate_repositories = "crate_repositories")
7load("//crate_universe/private:crate.bzl", "crate")
8load("//crate_universe/private:crates_repository.bzl", "crates_repository")
9load("//crate_universe/private:crates_vendor.bzl", "crates_vendor")
10load("//crate_universe/private:vendor_utils.bzl", "crates_vendor_deps")
11load("//crate_universe/tools/cross_installer:cross_installer_deps.bzl", "cross_installer_deps")
12
13USE_CRATES_REPOSITORY = False
14
15_REPOSITORY_NAME = "crate_universe_crate_index"
16
17_ANNOTATIONS = {
18    "libgit2-sys": [crate.annotation(
19        gen_build_script = False,
20        deps = ["@libgit2"],
21    )],
22    "libz-sys": [crate.annotation(
23        gen_build_script = False,
24        deps = ["@zlib"],
25    )],
26}
27
28_MANIFESTS = [
29    "@rules_rust//crate_universe:Cargo.toml",
30    "@rules_rust//crate_universe/tools/cross_installer:Cargo.toml",
31    "@rules_rust//crate_universe/tools/urls_generator:Cargo.toml",
32]
33
34def crate_universe_dependencies(rust_version = rust_common.default_version, bootstrap = False):
35    """Define dependencies of the `cargo-bazel` Rust target
36
37    Args:
38        rust_version (str, optional): The version of rust to use when generating dependencies.
39        bootstrap (bool, optional): If true, a `cargo_bootstrap_repository` target will be generated.
40    """
41    third_party_deps()
42
43    cargo_bazel_bootstrap(rust_version = rust_version)
44
45    if USE_CRATES_REPOSITORY:
46        crates_repository(
47            name = _REPOSITORY_NAME,
48            annotations = _ANNOTATIONS,
49            generator = "@cargo_bazel_bootstrap//:cargo-bazel" if bootstrap else None,
50            lockfile = "@rules_rust//crate_universe:Cargo.Bazel.lock",
51            manifests = _MANIFESTS,
52            rust_version = rust_version,
53        )
54
55    else:
56        _vendor_crate_repositories()
57
58    crates_vendor_deps()
59    cross_installer_deps()
60
61def crate_deps_target(name = "crates_vendor", vendor_path = "crates"):
62    crates_vendor(
63        name = name,
64        repository_name = _REPOSITORY_NAME,
65        annotations = _ANNOTATIONS,
66        manifests = _MANIFESTS,
67        vendor_path = vendor_path,
68        mode = "remote",
69        tags = ["manual"],
70    )