• 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:targets.bzl", "generate_schema_header")
7load("@fbsource//xplat/executorch/backends/qualcomm/qnn_version.bzl", "get_qnn_library_verision")
8
9QCIR_NAME = "qcir"
10INPUT_QCIR = QCIR_NAME + ".fbs"
11OUTPUT_QCIR_HEADER = QCIR_NAME + "_generated.h"
12QCIR_GEN_RULE_NAME = "qcir_generated"
13
14def define_common_targets():
15    """Defines targets that should be shared between fbcode and xplat.
16    The directory containing this targets.bzl file should also contain both
17    TARGETS and BUCK files that call this function.
18    """
19
20    generate_schema_header(
21        QCIR_GEN_RULE_NAME,
22        [INPUT_QCIR],
23        [OUTPUT_QCIR_HEADER],
24        OUTPUT_QCIR_HEADER,
25    )
26
27    # Header-only library target with the generate executorch program schema header.
28    runtime.cxx_library(
29        name = "qcir_schema",
30        srcs = [],
31        exported_headers = {
32            OUTPUT_QCIR_HEADER: ":{}[{}]".format(QCIR_GEN_RULE_NAME, OUTPUT_QCIR_HEADER),
33        },
34        visibility = [
35            # Lock this down as tightly as possible to ensure that flatbuffers
36            # are an implementation detail. Ideally this list would only include
37            # //executorch/runtime/executor/...
38            "//executorch/backends/qualcomm/...",
39            "//executorch/backends/qualcomm/aot/ir/...",
40        ],
41        exported_external_deps = ["flatbuffers-api"],
42        define_static_target = True,
43        platforms = [ANDROID],
44    )
45
46
47    runtime.cxx_library(
48        name = "qcir_utils",
49        srcs = [
50            "qcir_utils.cpp",
51        ],
52        exported_headers = [
53            "qcir_utils.h",
54        ],
55        define_static_target = True,
56        platforms = [ANDROID],
57        visibility = ["@EXECUTORCH_CLIENTS"],
58        deps = [
59            "fbsource//third-party/qualcomm/qnn/qnn-{0}:api".format(get_qnn_library_verision()),
60            "//executorch/runtime/backend:interface",
61            "//executorch/runtime/core:core",
62            "//executorch/backends/qualcomm/aot/wrappers:wrappers",
63        ],
64        exported_deps = [
65            ":qcir_schema",
66        ],
67    )
68