• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1load(
2    "@fbsource//tools/build_defs:default_platform_defs.bzl",
3    "ANDROID",
4)
5load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
6load("@fbsource//xplat/executorch/backends/qualcomm/qnn_version.bzl", "get_qnn_library_verision")
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    runtime.cxx_library(
16        name = "logging",
17        srcs = [
18            "Logging.cpp",
19        ],
20        exported_headers = [
21            "Logging.h",
22        ],
23        define_static_target = True,
24        platforms = [ANDROID],
25        visibility = ["@EXECUTORCH_CLIENTS"],
26        deps = [
27            "fbsource//third-party/qualcomm/qnn/qnn-{0}:api".format(get_qnn_library_verision()),
28            "//executorch/runtime/backend:interface",
29        ],
30        exported_deps = [
31            "//executorch/backends/qualcomm:schema",
32            "//executorch/backends/qualcomm:qc_binary_info_schema",
33            "//executorch/runtime/core:core",
34        ],
35    )
36
37    runtime.cxx_library(
38        name = "runtime",
39        srcs = glob(
40            [
41                "*.cpp",
42                "backends/*.cpp",
43                "backends/htpbackend/*.cpp",
44                "backends/htpbackend/aarch64/*.cpp",
45            ],
46            exclude = ["Logging.cpp"],
47        ),
48        exported_headers = glob(
49            [
50                "*.h",
51                "backends/*.h",
52                "backends/htpbackend/*.h",
53            ],
54            exclude = ["Logging.h"],
55        ),
56        define_static_target = True,
57        link_whole = True,  # needed for executorch/examples/models/llama:main to register QnnBackend
58        platforms = [ANDROID],
59        visibility = ["@EXECUTORCH_CLIENTS"],
60        resources = {
61            "qnn_lib": "fbsource//third-party/qualcomm/qnn/qnn-{0}:qnn_offline_compile_libs".format(get_qnn_library_verision()),
62        },
63        deps = [
64            "fbsource//third-party/qualcomm/qnn/qnn-{0}:api".format(get_qnn_library_verision()),
65            ":logging",
66            "//executorch/backends/qualcomm:schema",
67            "//executorch/backends/qualcomm:qc_binary_info_schema",
68            "//executorch/backends/qualcomm/aot/ir:qcir_utils",
69            "//executorch/backends/qualcomm/aot/wrappers:wrappers",
70            "//executorch/runtime/backend:interface",
71            "//executorch/runtime/core:core",
72            "//executorch/extension/tensor:tensor",
73        ],
74        exported_deps = [
75            "//executorch/runtime/core/exec_aten/util:scalar_type_util",
76            "//executorch/runtime/core:event_tracer",
77        ],
78    )
79