Skip to content

Commit 634a6f3

Browse files
dforsythacmcarther
authored andcommitted
Add FreeBSD toolchain. (#85)
1 parent b07eca4 commit 634a6f3

File tree

1 file changed

+68
-1
lines changed

1 file changed

+68
-1
lines changed

rust/repositories.bzl

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,39 @@ filegroup(
6464
)
6565
"""
6666

67+
RUST_FREEBSD_BUILD_FILE = """
68+
filegroup(
69+
name = "rustc",
70+
srcs = ["rustc/bin/rustc"],
71+
visibility = ["//visibility:public"],
72+
)
73+
74+
filegroup(
75+
name = "rustc_lib",
76+
srcs = glob(["rustc/lib/*.so"]),
77+
visibility = ["//visibility:public"],
78+
)
79+
80+
filegroup(
81+
name = "rustdoc",
82+
srcs = ["rustc/bin/rustdoc"],
83+
visibility = ["//visibility:public"],
84+
)
85+
86+
filegroup(
87+
name = "rust_lib",
88+
srcs = glob([
89+
"rust-std-x86_64-unknown-freebsd/lib/rustlib/x86_64-unknown-freebsd/lib/*.rlib",
90+
"rust-std-x86_64-unknown-freebsd/lib/rustlib/x86_64-unknown-freebsd/lib/*.so",
91+
"rust-std-x86_64-unknown-freebsd/lib/rustlib/x86_64-unknown-freebsd/lib/*.a",
92+
"rustc/lib/rustlib/x86_64-unknown-freebsd/lib/*.rlib",
93+
"rustc/lib/rustlib/x86_64-unknown-freebsd/lib/*.so",
94+
"rustc/lib/rustlib/x86_64-unknown-freebsd/lib/*.a",
95+
]),
96+
visibility = ["//visibility:public"],
97+
)
98+
"""
99+
67100
# This defines the default toolchain separately from the actual repositories, so that the remote
68101
# repositories will only be downloaded if they are actually used.
69102
DEFAULT_TOOLCHAINS = """
@@ -118,6 +151,31 @@ rust_toolchain(
118151
dylib_ext = ".dylib",
119152
visibility = ["//visibility:public"],
120153
)
154+
155+
toolchain(
156+
name = "rust-freebsd-x86_64",
157+
exec_compatible_with = [
158+
"@bazel_tools//platforms:freebsd",
159+
"@bazel_tools//platforms:x86_64",
160+
],
161+
target_compatible_with = [
162+
"@bazel_tools//platforms:freebsd",
163+
"@bazel_tools//platforms:x86_64",
164+
],
165+
toolchain = ":rust-freebsd-x86_64_impl",
166+
toolchain_type = "@io_bazel_rules_rust//rust:toolchain",
167+
)
168+
169+
rust_toolchain(
170+
name = "rust-freebsd-x86_64_impl",
171+
rust_doc = "@rust_freebsd_x86_64//:rustdoc",
172+
rust_lib = ["@rust_freebsd_x86_64//:rust_lib"],
173+
rustc = "@rust_freebsd_x86_64//:rustc",
174+
rustc_lib = ["@rust_freebsd_x86_64//:rustc_lib"],
175+
staticlib_ext = ".a",
176+
dylib_ext = ".so",
177+
visibility = ["//visibility:public"],
178+
)
121179
"""
122180

123181
# Eventually with better toolchain hosting options we could load only one of these, not both.
@@ -138,6 +196,14 @@ def rust_repositories():
138196
build_file_content = RUST_DARWIN_BUILD_FILE,
139197
)
140198

199+
native.new_http_archive(
200+
name = "rust_freebsd_x86_64",
201+
url = "https://static.rust-lang.org/dist/rust-1.24.1-x86_64-unknown-freebsd.tar.gz",
202+
strip_prefix = "rust-1.24.1-x86_64-unknown-freebsd",
203+
sha256 = "a33af1434186a42b3156060f0343f4816f9df5ec253c199d1be59fd42ed1e304",
204+
build_file_content = RUST_FREEBSD_BUILD_FILE,
205+
)
206+
141207
native.new_local_repository(
142208
name = "rust_default_toolchains",
143209
path = ".",
@@ -146,4 +212,5 @@ def rust_repositories():
146212
# Register toolchains
147213
native.register_toolchains(
148214
"@rust_default_toolchains//:rust-linux-x86_64",
149-
"@rust_default_toolchains//:rust-darwin-x86_64")
215+
"@rust_default_toolchains//:rust-darwin-x86_64",
216+
"@rust_default_toolchains//:rust-freebsd-x86_64")

0 commit comments

Comments
 (0)