|
1 | 1 | load("@rules_rust//rust/platform:triple.bzl", "triple") |
2 | 2 | load("@rules_rust//rust/private:repository_utils.bzl", "BUILD_for_rustfmt") |
3 | 3 | load(":rust_repository_utils.bzl", "RUST_REPOSITORY_COMMON_ATTR", "download_and_extract") |
4 | | -load(":symlink_utils.bzl", "relative_symlink") |
5 | | - |
6 | | -_RUSTFMT_LIB_FILEGROUP_TEMPLATE = """ |
7 | | -filegroup( |
8 | | - name = "rustc_lib", |
9 | | - srcs = ["lib", {upstream_rustc_lib}], |
10 | | - visibility = ["//visibility:public"], |
11 | | -) |
12 | | -""" |
13 | 4 |
|
14 | 5 | def _rustfmt_repository_impl(rctx): |
15 | 6 | exec_triple = triple(rctx.attr.triple) |
16 | 7 | download_and_extract(rctx, "rustfmt", "rustfmt-preview", exec_triple) |
17 | | - |
18 | | - rctx.file( |
19 | | - "BUILD.bazel", |
20 | | - BUILD_for_rustfmt(exec_triple) + _RUSTFMT_LIB_FILEGROUP_TEMPLATE.format( |
21 | | - upstream_rustc_lib = repr(str(rctx.attr.rustc_repo_build_file.same_package_label("rustc_lib"))), |
22 | | - ), |
23 | | - ) |
24 | | - |
25 | | - rustc_repo_root = rctx.path(rctx.attr.rustc_repo_build_file).dirname |
26 | | - relative_symlink(rctx, rustc_repo_root.get_child("lib"), "lib") |
| 8 | + download_and_extract(rctx, "rustc", "rustc", exec_triple, sha256 = rctx.attr.rustc_sha256) |
| 9 | + rctx.file("BUILD.bazel", BUILD_for_rustfmt(exec_triple, include_rustc_lib = True)) |
27 | 10 |
|
28 | 11 | return rctx.repo_metadata(reproducible = True) |
29 | 12 |
|
30 | 13 | rustfmt_repository = repository_rule( |
31 | 14 | implementation = _rustfmt_repository_impl, |
32 | 15 | attrs = { |
33 | | - "rustc_repo_build_file": attr.label(allow_single_file = True, mandatory = True), |
| 16 | + "rustc_sha256": attr.string(mandatory = True), |
34 | 17 | } | RUST_REPOSITORY_COMMON_ATTR, |
35 | 18 | ) |
0 commit comments