blob: d1698036a850b96baf2e5a0b14cbf794ffc7781b [file] [log] [blame]
load("@rules_rust//rust:defs.bzl", "rust_binary")
load("@rules_shell//shell:sh_test.bzl", "sh_test")
package(default_visibility = ["//visibility:public"])
filegroup(
name = "all",
srcs = [
":hello_world_aarch64",
":hello_world_host",
":hello_world_x86_64",
],
)
rust_binary(
name = "hello_world_host",
srcs = ["src/main.rs"],
deps = [
"@crates//:lz4-sys",
"@crates//:mimalloc",
],
)
rust_binary(
name = "hello_world_x86_64",
srcs = ["src/main.rs"],
platform = "//build/platforms:linux-x86_64",
deps = [
"@crates//:lz4-sys",
"@crates//:mimalloc",
],
)
rust_binary(
name = "hello_world_aarch64",
srcs = ["src/main.rs"],
platform = "//build/platforms:linux-aarch64",
deps = [
"@crates//:lz4-sys",
"@crates//:mimalloc",
],
)
# Test if the host binary works.
# Note, we cannot test for platform since Bazel determines the host platform automatically
sh_test(
name = "test_hello_world_host",
srcs = ["test_hello_world.sh"],
args = [
"$(rlocationpath :hello_world_host)",
],
data = [
":hello_world_host",
],
deps = [
"@bazel_tools//tools/bash/runfiles",
],
)
# Test the for x86_64 architecture
sh_test(
name = "test_linux_x86_64",
srcs = ["test_platform.sh"],
args = [
"$(rootpath :hello_world_x86_64)",
"x86_64",
],
data = [
":hello_world_x86_64",
],
deps = [
"@bazel_tools//tools/bash/runfiles",
],
)
# Test for ARM architecture
sh_test(
name = "test_linux_arm64",
srcs = ["test_platform.sh"],
args = [
"$(rootpath :hello_world_aarch64)",
"aarch64",
],
data = [
":hello_world_aarch64",
],
deps = [
"@bazel_tools//tools/bash/runfiles",
],
)