-
Notifications
You must be signed in to change notification settings - Fork 3
/
workspace.bzl
34 lines (29 loc) · 1.18 KB
/
workspace.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@blackjack//:cargo_dependencies.bzl", "cargo_dependencies")
def _cargo_target(os_name):
if os_name.startswith("mac os"):
return "x86_64-apple-darwin"
if os_name.find("windows") != -1:
return "x86_64-pc-windows-msvc"
else:
return "x86_64-unknown-linux-gnu"
def _cargo_binary_name(os_name):
if os_name.find("windows") != -1:
return "cargo.exe"
else:
return "cargo"
def _blackjack_cargo_impl(ctx):
os_name = ctx.os.name.lower()
target = _cargo_target(os_name)
ctx.download_and_extract(
# Retrieved from https://static.rust-lang.org/dist/channel-rust-stable.toml
url = "https://static.rust-lang.org/dist/2021-12-02/cargo-1.57.0-%s.tar.gz" % target,
stripPrefix = "cargo-1.57.0-%s/cargo/bin" % target,
)
ctx.file("BUILD.bazel", """alias(name="blackjack_cargo.exe", actual = "%s", visibility = ["//visibility:public"])""" % _cargo_binary_name(os_name))
_blackjack_cargo = repository_rule(
implementation = _blackjack_cargo_impl,
)
def blackjack_cargo():
_blackjack_cargo(name = "blackjack_cargo")
cargo_dependencies()