Skip to content

Commit

Permalink
Expose crates_vendor deps to bzlmod
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Dec 28, 2023
1 parent 6190e52 commit 47615b0
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
bindgen/3rdparty/crates/** linguist-generated
crate_universe/3rdparty/crates/** linguist-generated
crate_universe/test_data/metadata/*/metadata.json linguist-generated
examples/bzlmod/hello_world/third-party/crates/** linguist-generated
examples/crate_universe/vendor_external/crates/** linguist-generated
examples/crate_universe/vendor_local_manifests/crates/** linguist-generated
examples/crate_universe/vendor_local_pkgs/crates/** linguist-generated
Expand Down
5 changes: 5 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ internal_deps = use_extension("//rust/private:extensions.bzl", "internal_deps")
use_repo(
internal_deps,
"bazelci_rules",
"cargo_bazel.buildifier-darwin-amd64",
"cargo_bazel.buildifier-darwin-arm64",
"cargo_bazel.buildifier-linux-amd64",
"cargo_bazel.buildifier-linux-arm64",
"cargo_bazel.buildifier-windows-amd64.exe",
"com_google_googleapis",
"cui",
"cui__anyhow-1.0.75",
Expand Down
13 changes: 12 additions & 1 deletion crate_universe/private/vendor_utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,18 @@ _BUILDIFIER_SHA256S = {
}

def crates_vendor_deps():
"""Define dependencies of the `crates_vendor` rule
Returns:
list[struct(repo=str, is_dev_dep=bool)]: List of the dependency repositories.
"""
direct_deps = []

for bin, sha256 in _BUILDIFIER_SHA256S.items():
repo = "cargo_bazel.{}".format(bin)
maybe(
http_file,
name = "cargo_bazel.{}".format(bin),
name = repo,
urls = [_BUILDIFIER_URL_TEMPLATE.format(
bin = bin,
version = _BUILDIFIER_VERSION,
Expand All @@ -26,6 +34,9 @@ def crates_vendor_deps():
downloaded_file_path = "buildifier.exe",
executable = True,
)
direct_deps.append(struct(repo = repo, is_dev_dep = False))

return direct_deps

# buildifier: disable=unnamed-macro
def crates_vendor_deps_targets():
Expand Down
3 changes: 1 addition & 2 deletions crate_universe/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def crate_universe_dependencies(rust_version = rust_common.default_version, boot
cargo_bazel_bootstrap(rust_version = rust_version, **kwargs)

direct_deps = _vendor_crate_repositories()

crates_vendor_deps()
direct_deps.extend(crates_vendor_deps())
cross_installer_deps()
return direct_deps
1 change: 0 additions & 1 deletion examples/bzlmod/hello_world/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module(
)

bazel_dep(name = "bazel_skylib", version = "1.5.0")

bazel_dep(name = "rules_rust", version = "0.0.0")
local_path_override(
module_name = "rules_rust",
Expand Down

0 comments on commit 47615b0

Please sign in to comment.