-
Notifications
You must be signed in to change notification settings - Fork 529
/
Copy pathtargets.bzl
95 lines (84 loc) · 3.35 KB
/
targets.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
load(
"@fbsource//tools/build_defs:default_platform_defs.bzl",
"ANDROID",
)
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
load("@fbsource//xplat/executorch/backends/qualcomm/qnn_version.bzl", "get_qnn_library_version")
# Construct the input and output file names. All input and output files rely on scalar_type file.
SCHEMA_NAME = "qc_compiler_spec"
INPUT_SCHEMA = "serialization/" + SCHEMA_NAME + ".fbs"
OUTPUT_SCHEMA_HEADER = SCHEMA_NAME + "_generated.h"
SCHEMA_GEN_RULE_NAME = "qc_compiler_spec_generated"
SCHEMA_LIRRARY_NAME = SCHEMA_NAME
def generate_schema_header(rule_name, srcs, headers, default_header):
"""Generate header file given flatbuffer schema
"""
runtime.genrule(
name = rule_name,
srcs = srcs,
# We're only generating a single file, so it seems like we could use
# `out`, but `flatc` takes a directory as a parameter, not a single
# file. Use `outs` so that `${OUT}` is expanded as the containing
# directory instead of the file itself.
outs = {header: [header] for header in headers},
default_outs = [default_header],
cmd = " ".join([
"$(exe {})".format(runtime.external_dep_location("flatc")),
"--cpp",
"--cpp-std c++11",
"--gen-mutable",
"--scoped-enums",
"-o ${OUT}",
"${SRCS}",
# Let our infra know that the file was generated.
" ".join(["&& echo // @" + "generated >> ${OUT}/" + header for header in headers]),
]),
visibility = [], # Private
)
def define_common_targets():
"""Defines targets that should be shared between fbcode and xplat.
The directory containing this targets.bzl file should also contain both
TARGETS and BUCK files that call this function.
"""
generate_schema_header(
SCHEMA_GEN_RULE_NAME,
[INPUT_SCHEMA],
[OUTPUT_SCHEMA_HEADER],
OUTPUT_SCHEMA_HEADER,
)
# Header-only library target with the generate executorch program schema header.
runtime.cxx_library(
name = "schema",
srcs = [],
visibility = [
# Lock this down as tightly as possible to ensure that flatbuffers
# are an implementation detail. Ideally this list would only include
# //executorch/runtime/executor/...
"//executorch/codegen/tools/...",
"//executorch/runtime/executor/...",
"//executorch/backends/qualcomm/...",
"//executorch/backends/qualcomm/runtime/...",
],
exported_headers = {
OUTPUT_SCHEMA_HEADER: ":{}[{}]".format(SCHEMA_GEN_RULE_NAME, OUTPUT_SCHEMA_HEADER),
},
exported_external_deps = ["flatbuffers-api"],
define_static_target = True,
platforms = [ANDROID],
)
runtime.cxx_library(
name = "qnn_executorch_backend",
srcs = [],
headers = [],
define_static_target = True,
visibility = ["@EXECUTORCH_CLIENTS"],
deps = [
"fbsource//third-party/qualcomm/qnn/qnn-{0}:api".format(get_qnn_library_version()),
"//executorch/runtime/backend:interface",
"//executorch/runtime/core:core",
"//executorch/backends/qualcomm/runtime:runtime_android_build",
],
exported_deps = [
":schema",
],
)