fork/rules_rust

git clone https://git.julia.blue/fork/rules_rust

Marvin HansenUpdated Bazelmod cross compilation to catch MacOS sys dependency issues (#2926)11343929

main
1.8 KiB89 linesraw
1load("@rules_rust//rust:defs.bzl", "rust_binary")
2
3package(default_visibility = ["//visibility:public"])
4
5filegroup(
6    name = "all",
7    srcs = [
8        ":hello_world_aarch64",
9        ":hello_world_host",
10        ":hello_world_x86_64",
11    ],
12)
13
14rust_binary(
15    name = "hello_world_host",
16    srcs = ["src/main.rs"],
17    deps = [
18        "@crates//:lz4-sys",
19        "@crates//:mimalloc",
20    ],
21)
22
23rust_binary(
24    name = "hello_world_x86_64",
25    srcs = ["src/main.rs"],
26    platform = "//build/platforms:linux-x86_64",
27    deps = [
28        "@crates//:lz4-sys",
29        "@crates//:mimalloc",
30    ],
31)
32
33rust_binary(
34    name = "hello_world_aarch64",
35    srcs = ["src/main.rs"],
36    platform = "//build/platforms:linux-aarch64",
37    deps = [
38        "@crates//:lz4-sys",
39        "@crates//:mimalloc",
40    ],
41)
42
43# Test if the host binary works.
44# Note, we cannot test for platform since Bazel determines the host platform automatically
45sh_test(
46    name = "test_hello_world_host",
47    srcs = ["test_hello_world.sh"],
48    args = [
49        "$(rlocationpath :hello_world_host)",
50    ],
51    data = [
52        ":hello_world_host",
53    ],
54    deps = [
55        "@bazel_tools//tools/bash/runfiles",
56    ],
57)
58
59# Test the for x86_64 architecture
60sh_test(
61    name = "test_linux_x86_64",
62    srcs = ["test_platform.sh"],
63    args = [
64        "$(rootpath :hello_world_x86_64)",
65        "x86_64",
66    ],
67    data = [
68        ":hello_world_x86_64",
69    ],
70    deps = [
71        "@bazel_tools//tools/bash/runfiles",
72    ],
73)
74
75# Test for ARM architecture
76sh_test(
77    name = "test_linux_arm64",
78    srcs = ["test_platform.sh"],
79    args = [
80        "$(rootpath :hello_world_aarch64)",
81        "aarch64",
82    ],
83    data = [
84        ":hello_world_aarch64",
85    ],
86    deps = [
87        "@bazel_tools//tools/bash/runfiles",
88    ],
89)