Skip to content

Commit 5e3b2d2

Browse files
committed
[bazel] Fix the Rust build and bump rules_rust
The Rust source in the project contains both a `lib.rs` and a `main.rs`. Cargo is smart enough to understand that this means it needs to compile a library and then a binary, but Bazel needs to be told this explicitly.
1 parent 476dc6b commit 5e3b2d2

File tree

4 files changed

+215
-201
lines changed

4 files changed

+215
-201
lines changed

WORKSPACE

+3-5
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,8 @@ selenium_register_dotnet()
160160

161161
http_archive(
162162
name = "rules_rust",
163-
sha256 = "dd79bd4e2e2adabae738c5e93c36d351cf18071ff2acf6590190acf4138984f6",
164-
urls = [
165-
"https://github.com/bazelbuild/rules_rust/releases/download/0.14.0/rules_rust-v0.14.0.tar.gz",
166-
],
163+
sha256 = "5c2b6745236f8ce547f82eeacbbcc81d736734cc8bd92e60d3e3cdfa6e167bb5",
164+
urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.15.0/rules_rust-v0.15.0.tar.gz"],
167165
)
168166

169167
load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains")
@@ -237,11 +235,11 @@ http_archive(
237235
patches = [
238236
"//py:rules_pkg_tree.patch",
239237
],
238+
sha256 = "eea0f59c28a9241156a47d7a8e32db9122f3d50b505fae0f33de6ce4d9b61834",
240239
urls = [
241240
"https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.8.0/rules_pkg-0.8.0.tar.gz",
242241
"https://github.com/bazelbuild/rules_pkg/releases/download/0.8.0/rules_pkg-0.8.0.tar.gz",
243242
],
244-
sha256 = "eea0f59c28a9241156a47d7a8e32db9122f3d50b505fae0f33de6ce4d9b61834",
245243
)
246244

247245
load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")

rust/BUILD.bazel

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
11
load("@crates//:defs.bzl", "all_crate_deps")
2-
load("@rules_rust//rust:defs.bzl", "rust_binary")
2+
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library")
33

44
rust_binary(
5+
# Yes, this name is very similar to the library. Note the dash
6+
# instead of an underscore
57
name = "selenium-manager",
6-
srcs = glob(["src/**/*.rs"]),
7-
edition = "2018",
8+
srcs = ["src/main.rs"],
9+
edition = "2021",
10+
visibility = ["//visibility:public"],
11+
deps = [
12+
":selenium_manager",
13+
] + all_crate_deps(normal = True),
14+
)
15+
16+
rust_library(
17+
# The name here is used as the crate name
18+
name = "selenium_manager",
19+
srcs = glob(
20+
["src/**/*.rs"],
21+
exclude = ["main.rs"],
22+
),
23+
edition = "2021",
824
deps = all_crate_deps(normal = True),
925
)

0 commit comments

Comments
 (0)