Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,14 @@ test:node_debug --test_output=streamed --test_strategy=exclusive --test_timeout=
test:ruby_debug --test_output=streamed --test_env=RUBY_DEBUG_FORK_MODE=parent --run_under="@bundle//bin:rdbg --nonstop --open --command"


# @llvm defaults to 14.0.
build --macos_minimum_os=11.0

build:release --stamp
build:release --compilation_mode=opt
# Match [profile.release] in rust/Cargo.toml, which Bazel doesn't read.
build:release --@rules_rust//rust/settings:lto=fat
build:release --@rules_rust//rust/settings:extra_rustc_flags=-Copt-level=z,-Ccodegen-units=1,-Cpanic=abort,-Cstrip=symbols

# As regular `release` but all the build work happens on the RBE
build:rbe_release --config=release
Expand Down
32 changes: 29 additions & 3 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ single_version_override(
],
)

# Build the `*-sys` C sources with the LLVM cc toolchain so they cross-compile to musl.
bazel_dep(name = "bzip2", version = "1.0.8.bcr.3")
bazel_dep(name = "xz", version = "5.4.5.bcr.8")
bazel_dep(name = "zstd", version = "1.5.7.bcr.1")

single_version_override(
module_name = "rules_jvm_external",
patch_strip = 1,
Expand Down Expand Up @@ -429,6 +434,14 @@ llvm_toolchains.exec(
arch = "x86_64",
os = "macos",
)
llvm_toolchains.exec(
arch = "x86_64",
os = "linux",
)
llvm_toolchains.exec(
arch = "aarch64",
os = "linux",
)
use_repo(llvm_toolchains, "llvm_toolchains")

# Registered only for Windows in .bazelrc so it cannot shadow @llvm elsewhere.
Expand All @@ -446,23 +459,36 @@ crate.from_cargo(
"aarch64-apple-darwin",
"aarch64-pc-windows-msvc",
"aarch64-unknown-linux-gnu",
"aarch64-unknown-linux-musl",
"x86_64-apple-darwin",
"x86_64-pc-windows-gnullvm",
"x86_64-pc-windows-msvc",
"x86_64-unknown-linux-gnu",
"x86_64-unknown-linux-musl",
],
)
crate.annotation(
crate = "bzip2-sys",
gen_build_script = "on",
gen_build_script = "off",
deps = ["@bzip2//:bz2"],
)
crate.annotation(
crate = "lzma-sys",
gen_build_script = "on",
gen_build_script = "off",
deps = ["@xz//:lzma"],
)
crate.annotation(
crate = "zstd-sys",
gen_build_script = "on",
gen_build_script = "off",
deps = ["@zstd"],
)

inject_repo(crate, "bzip2")

inject_repo(crate, "xz")

inject_repo(crate, "zstd")

use_repo(crate, "crates")

selenium_manager_artifacts = use_extension("//common:selenium_manager.bzl", "selenium_manager_artifacts")
Expand Down
8 changes: 8 additions & 0 deletions common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ string_flag(
values = [
"download",
"host",
"all",
],
)

Expand All @@ -30,6 +31,13 @@ config_setting(
},
)

config_setting(
name = "manager_all",
flag_values = {
":manager": "all",
},
)

bool_flag(
name = "headless",
build_setting_default = False,
Expand Down
4 changes: 4 additions & 0 deletions common/manager/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package(
alias(
name = "selenium-manager-linux-x86_64",
actual = select({
"//common:manager_all": "//rust:_xc_file-linux-x86_64",
Comment thread
titusfortner marked this conversation as resolved.
"//common:manager_host": "//rust:selenium-manager-linux-x86_64",
"//conditions:default": "@download_sm_linux_x86_64//file",
}),
Expand All @@ -20,6 +21,7 @@ alias(
alias(
name = "selenium-manager-linux-arm64",
actual = select({
"//common:manager_all": "//rust:_xc_file-linux-arm64",
"//common:manager_host": "//rust:selenium-manager-linux-arm64",
"//conditions:default": "@download_sm_linux_arm64//file",
}),
Expand All @@ -28,6 +30,7 @@ alias(
alias(
name = "selenium-manager-macos",
actual = select({
"//common:manager_all": "//rust:_xc_file-macos",
"//common:manager_host": "//rust:selenium-manager-macos",
"//conditions:default": "@download_sm_macos//file",
}),
Expand All @@ -36,6 +39,7 @@ alias(
alias(
name = "selenium-manager-windows",
actual = select({
"//common:manager_all": "//rust:_xc_file-windows",
"//common:manager_host": "//rust:selenium-manager-windows",
"//conditions:default": "@download_sm_windows//file",
}),
Expand Down
56 changes: 56 additions & 0 deletions rust/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
load("@aspect_bazel_lib//lib:output_files.bzl", "output_files")
load("@aspect_bazel_lib//lib:transitions.bzl", "platform_transition_binary")
load("@crates//:defs.bzl", "aliases", "all_crate_deps")
load("//rust:defs.bzl", "rust_binary", "rust_library", "rust_test", "rustfmt_config")

Expand All @@ -19,6 +21,60 @@ SELENIUM_MANAGER_PLATFORMS = [
"windows",
]

# musl: Rust's glibc stdlib needs `-lgcc_s`, which @llvm doesn't ship.
# gnullvm: @llvm links a PE binary without a Windows SDK.
SELENIUM_MANAGER_TRIPLES = {
"linux-arm64": "aarch64-unknown-linux-musl",
"linux-x86_64": "x86_64-unknown-linux-musl",
"macos-arm64": "aarch64-apple-darwin",
"macos-x86_64": "x86_64-apple-darwin",
"windows": "x86_64-pc-windows-gnullvm",
}

[
platform_transition_binary(
name = "_xc-%s" % target,
basename = "selenium-manager.exe" if target == "windows" else "selenium-manager",
binary = ":selenium-manager",
tags = ["manual"],
target_platform = "@rules_rs//rs/platforms:%s" % triple,
)
for (target, triple) in SELENIUM_MANAGER_TRIPLES.items()
]

# platform_transition_binary also forwards the rust_binary at a colliding path; keep only the wrapper.
# Windows hosts can't cross-compile until upstream fixes ship.
[
output_files(
name = "_xc_file-%s" % target,
paths = ["rust/_xc-%s/selenium-manager%s" % (
target,
".exe" if target == "windows" else "",
)],
tags = ["manual"],
target = ":_xc-%s" % target,
target_compatible_with = select({
"//common:windows": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
visibility = ["//common/manager:__pkg__"],
)
for target in SELENIUM_MANAGER_TRIPLES
]

genrule(
name = "_xc_file-macos",
srcs = [
":_xc_file-macos-arm64",
":_xc_file-macos-x86_64",
],
outs = ["_xc-macos/selenium-manager"],
cmd = "$(execpath @llvm//tools:llvm-lipo) -create -output $@ $(execpath :_xc_file-macos-arm64) $(execpath :_xc_file-macos-x86_64)",
tags = ["manual"],
tools = ["@llvm//tools:llvm-lipo"],
visibility = ["//common/manager:__pkg__"],
)

[
alias(
name = "selenium-manager-%s" % platform,
Expand Down
Loading