xref: /aosp_15_r20/external/executorch/extension/threadpool/targets.bzl (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1load("@fbsource//xplat/executorch/backends/xnnpack/third-party:third_party_libs.bzl", "third_party_dep")
2load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
3
4def define_common_targets():
5    """Defines targets that should be shared between fbcode and xplat.
6
7    The directory containing this targets.bzl file should also contain both
8    TARGETS and BUCK files that call this function.
9    """
10
11    _THREADPOOL_SRCS = [
12        "threadpool.cpp",
13        "threadpool_guard.cpp",
14    ] + (["fb/threadpool_use_n_threads.cpp"] if not runtime.is_oss else [])
15
16    _THREADPOOL_HEADERS = [
17        "threadpool.h",
18        "threadpool_guard.h",
19    ] + (["fb/threadpool_use_n_threads.h"] if not runtime.is_oss else [])
20
21    runtime.cxx_library(
22        name = "threadpool",
23        srcs = _THREADPOOL_SRCS,
24        deps = [
25            "//executorch/runtime/core:core",
26        ],
27        exported_headers = _THREADPOOL_HEADERS,
28        exported_deps = [
29            third_party_dep("pthreadpool"),
30            third_party_dep("cpuinfo"),
31        ],
32        exported_preprocessor_flags = [
33            "-DET_USE_THREADPOOL",
34        ],
35        visibility = [
36            "//executorch/...",
37            "//executorch/backends/...",
38            "//executorch/runtime/backend/...",
39            "//executorch/extension/threadpool/test/...",
40            "@EXECUTORCH_CLIENTS",
41        ],
42    )
43
44    runtime.cxx_library(
45        name = "cpuinfo_utils",
46        srcs = [
47            "cpuinfo_utils.cpp",
48        ],
49        deps = [
50            "//executorch/runtime/core:core",
51        ],
52        exported_headers = [
53            "cpuinfo_utils.h",
54        ],
55        exported_deps = [
56            third_party_dep("pthreadpool"),
57            third_party_dep("cpuinfo"),
58        ],
59        visibility = [
60            "//executorch/...",
61            "//executorch/backends/...",
62            "//executorch/runtime/backend/...",
63            "//executorch/extension/threadpool/test/...",
64            "@EXECUTORCH_CLIENTS",
65        ],
66    )
67