| """Generated unittests to verify that a binary is built for the expected architecture.""" |
| load("//build_defs:internal_shell.bzl", "inline_sh_test") |
| """Bazel rule to verify that a Bazel or system binary is built for the aarch64 architecture. |
| name: the name of the test. |
| platform: a diagnostic name for this architecture. |
| file_platform: the expected output of `file`. |
| bazel_binaries: a set of binary targets to inspect. |
| system_binaries: a set of paths to system executables to inspect. |
| **kwargs: other keyword arguments that are passed to the test. |
| (file -L $$binary | grep -q "%s") \ |
| || (echo "Test binary is not an %s binary: "; file -L $$binary; exit 1) |
| " ".join(["$(rootpaths %s)" % b for b in bazel_binaries] + system_binaries), |
| target_compatible_with = select({ |
| "//build_defs:" + platform: [], |
| "//conditions:default": ["@platforms//:incompatible"], |
| def aarch64_test(**kwargs): |
| file_platform = "ELF 64-bit LSB.* ARM aarch64", |
| def x86_64_test(**kwargs): |
| file_platform = "ELF 64-bit LSB.*, ARM x86_64", |