xref: /aosp_15_r20/external/executorch/kernels/optimized/test/targets.bzl (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
2load(
3    "@fbsource//xplat/executorch/kernels/optimized:lib_defs.bzl",
4    "get_vec_preprocessor_flags",
5    "get_vec_cxx_preprocessor_flags",
6)
7load("@fbsource//xplat/executorch/kernels/test:util.bzl", "define_supported_features_lib")
8
9def _lib_test_bin(name, extra_deps = [], in_cpu = False):
10    """Defines a cxx_binary() for a single test file.
11    """
12    if not (name.endswith("_test_bin")):
13        fail("'{}' must match the pattern '*_vec_test_bin'")
14
15    src_root = name[:-len("_bin")]
16    lib_root = name[:-len("_test_bin")]
17
18    cpu_path = "/cpu" if in_cpu else ""
19
20    runtime.cxx_binary(
21        name = name,
22        srcs = [
23            "{}.cpp".format(src_root),
24        ],
25        deps = [
26            "//executorch/test/utils:utils",
27            "//executorch/kernels/optimized{}:{}".format(cpu_path, lib_root),
28        ] + extra_deps,
29        cxx_platform_preprocessor_flags = get_vec_cxx_preprocessor_flags(),
30        preprocessor_flags = get_vec_preprocessor_flags(),
31    )
32
33def define_common_targets():
34    """Defines targets that should be shared between fbcode and xplat.
35
36    The directory containing this targets.bzl file should also contain both
37    TARGETS and BUCK files that call this function.
38    """
39    define_supported_features_lib()
40
41    _lib_test_bin("libvec_test_bin")
42    _lib_test_bin("moments_utils_test_bin", in_cpu = True)
43    _lib_test_bin("libblas_test_bin")
44