Protocol Buffers - Google's data interchange format (grpc依赖)
https://developers.google.com/protocol-buffers/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.7 KiB
57 lines
1.7 KiB
2 years ago
|
"""Generated unittests to verify that a binary is built for the expected architecture."""
|
||
|
|
||
|
load("//build_defs:internal_shell.bzl", "inline_sh_test")
|
||
|
|
||
|
def _arch_test_impl(
|
||
|
name,
|
||
|
platform,
|
||
|
file_platform,
|
||
|
bazel_binaries = [],
|
||
|
system_binaries = [],
|
||
|
**kwargs):
|
||
2 years ago
|
"""Bazel rule to verify that a Bazel or system binary is built for the aarch64 architecture.
|
||
2 years ago
|
|
||
|
Args:
|
||
|
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.
|
||
2 years ago
|
**kwargs: other keyword arguments that are passed to the test.
|
||
2 years ago
|
"""
|
||
|
|
||
|
inline_sh_test(
|
||
|
name = name,
|
||
|
tools = bazel_binaries,
|
||
|
cmd = """
|
||
|
for binary in "$(rootpaths %s) %s"; do
|
||
|
(file -L $$binary | grep -q "%s") \
|
||
|
|| (echo "Test binary is not an %s binary: "; file -L $$binary; exit 1)
|
||
|
done
|
||
2 years ago
|
""" % (
|
||
|
" ".join(bazel_binaries),
|
||
|
" ".join(system_binaries),
|
||
|
file_platform,
|
||
|
platform,
|
||
|
),
|
||
2 years ago
|
target_compatible_with = select({
|
||
2 years ago
|
"//build_defs:" + platform: [],
|
||
|
"//conditions:default": ["@platforms//:incompatible"],
|
||
2 years ago
|
}),
|
||
2 years ago
|
**kwargs
|
||
2 years ago
|
)
|
||
|
|
||
|
def aarch64_test(**kwargs):
|
||
2 years ago
|
_arch_test_impl(
|
||
|
platform = "aarch64",
|
||
|
file_platform = "ELF 64-bit LSB executable, ARM aarch64",
|
||
|
**kwargs
|
||
|
)
|
||
2 years ago
|
|
||
|
def x86_64_test(**kwargs):
|
||
2 years ago
|
_arch_test_impl(
|
||
|
platform = "x86_64",
|
||
|
file_platform = "ELF 64-bit LSB executable, ARM x86_64",
|
||
|
**kwargs
|
||
|
)
|