xref: /aosp_15_r20/external/executorch/kernels/prim_ops/targets.bzl (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
2
3def define_common_targets():
4    """Defines targets that should be shared between fbcode and xplat.
5
6    The directory containing this targets.bzl file should also contain both
7    TARGETS and BUCK files that call this function.
8    """
9
10    for aten_mode in (True, False):
11        aten_suffix = ("_aten" if aten_mode else "")
12
13        runtime.cxx_library(
14            name = "et_copy_index" + aten_suffix,
15            srcs = ["et_copy_index.cpp"],
16            visibility = [],  # Private
17            exported_headers = ["et_copy_index.h"],
18            deps = [
19                "//executorch/runtime/kernel:kernel_includes" + aten_suffix,
20            ],
21            exported_deps = [
22                "//executorch/runtime/core:evalue" + aten_suffix,
23                "//executorch/runtime/kernel:kernel_runtime_context" + aten_suffix,
24            ],
25        )
26
27        runtime.cxx_library(
28            name = "et_view" + aten_suffix,
29            srcs = ["et_view.cpp"],
30            visibility = [],  # Private
31            exported_headers = ["et_view.h"],
32            deps = [
33                "//executorch/runtime/kernel:kernel_includes" + aten_suffix,
34            ],
35            exported_deps = [
36                "//executorch/runtime/core:evalue" + aten_suffix,
37                "//executorch/runtime/kernel:kernel_runtime_context" + aten_suffix,
38            ],
39        )
40
41        runtime.cxx_library(
42            name = "prim_ops_registry" + aten_suffix,
43            srcs = ["register_prim_ops.cpp"],
44            visibility = [
45                "//executorch/...",
46                "@EXECUTORCH_CLIENTS",
47            ],
48            # @lint-ignore BUCKLINT link_whole, need this to register prim ops.
49            link_whole = True,
50            # prim ops are registered through a global table so the ctor needs to be allowed
51            compiler_flags = select({
52                "DEFAULT": ["-Wno-global-constructors"],
53                "ovr_config//os:windows": [],
54            }),
55            deps = [
56                ":et_copy_index" + aten_suffix,
57                ":et_view" + aten_suffix,
58                "//executorch/runtime/core:evalue" + aten_suffix,
59                "//executorch/runtime/kernel:operator_registry",
60                "//executorch/runtime/kernel:kernel_includes" + aten_suffix,
61            ],
62        )
63