• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1"""Dependencies needed for the cross-installer tool"""
2
3load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
4load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
5
6def cross_installer_deps():
7    version = "0.2.1"
8
9    components = {
10        "x86_64-apple-darwin": "589da89453291dc26f0b10b521cdadb98376d495645b210574bd9ca4ec8cfa2c",
11        "x86_64-pc-windows-msvc": "3af59ff5a2229f92b54df937c50a9a88c96dffc8ac3dde520a38fdf046d656c4",
12        "x86_64-unknown-linux-gnu": "06dcce3248488e95fbb368d14bef17fa8e77461d5055fbd5193538574820f413",
13    }
14
15    for triple, sha256 in components.items():
16        maybe(
17            http_archive,
18            name = "cross_{}".format(triple),
19            urls = ["https://github.com/rust-embedded/cross/releases/download/v{version}/cross-v{version}-{triple}.tar.gz".format(
20                triple = triple,
21                version = version,
22            )],
23            sha256 = sha256,
24            build_file_content = """exports_files(glob(["**"]), visibility = ["//visibility:public"])""",
25        )
26
27def cross_binary(name = "cross"):
28    native.config_setting(
29        name = "linux",
30        constraint_values = ["@platforms//os:linux"],
31    )
32
33    native.config_setting(
34        name = "macos",
35        constraint_values = ["@platforms//os:macos"],
36    )
37
38    native.config_setting(
39        name = "windows",
40        constraint_values = ["@platforms//os:windows"],
41    )
42
43    native.alias(
44        name = name,
45        actual = select({
46            ":linux": "@cross_x86_64-unknown-linux-gnu//:cross",
47            ":macos": "@cross_x86_64-apple-darwin//:cross",
48            ":windows": "@cross_x86_64-pc-windows-msvc//:cross.exe",
49        }),
50    )
51