xref: /aosp_15_r20/external/executorch/extension/module/test/targets.bzl (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1load(
2    "@fbsource//tools/build_defs:default_platform_defs.bzl",
3    "ANDROID",
4    "CXX",
5)
6load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
7
8def define_common_targets():
9    """Defines targets that should be shared between fbcode and xplat.
10
11    The directory containing this targets.bzl file should also contain both
12    TARGETS and BUCK files that call this function.
13    """
14
15    for aten_mode in (True, False):
16        aten_suffix = ("_aten" if aten_mode else "")
17
18        runtime.cxx_test(
19            name = "test" + aten_suffix,
20            srcs = [
21                "module_test.cpp",
22            ],
23            deps = [
24                "//executorch/kernels/portable:generated_lib" + aten_suffix,
25                "//executorch/extension/data_loader:file_data_loader",
26                "//executorch/extension/module:module" + aten_suffix,
27                "//executorch/extension/tensor:tensor" + aten_suffix,
28            ],
29            env = {
30                "RESOURCES_PATH": "$(location :resources)/resources",
31            },
32            platforms = [CXX, ANDROID],  # Cannot bundle resources on Apple platform.
33            compiler_flags = [
34                "-Wno-error=deprecated-declarations",
35            ],
36        )
37
38    runtime.filegroup(
39        name = "resources",
40        srcs = native.glob([
41            "resources/**",
42        ]),
43    )
44