xref: /aosp_15_r20/external/executorch/backends/vulkan/serialization/targets.bzl (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
2
3def define_common_targets(is_fbcode = False):
4    runtime.genrule(
5        name = "gen_vk_delegate_schema",
6        srcs = ["schema.fbs"],
7        # We're only generating a single file, so it seems like we could use
8        # `out`, but `flatc` takes a directory as a parameter, not a single
9        # file. Use `outs` so that `${OUT}` is expanded as the containing
10        # directory instead of the file itself.
11        outs = {
12            "schema_generated.h": ["schema_generated.h"],
13        },
14        cmd = " ".join([
15            "$(exe {})".format(runtime.external_dep_location("flatc")),
16            "--cpp",
17            "--cpp-std c++11",
18            "--scoped-enums",
19            "-o ${OUT}",
20            "${SRCS}",
21        ]),
22        default_outs = ["."],
23    )
24
25    runtime.cxx_library(
26        name = "vk_delegate_schema",
27        srcs = [],
28        visibility = [
29            "//executorch/backends/vulkan/...",
30        ],
31        exported_headers = {
32            "schema_generated.h": ":gen_vk_delegate_schema[schema_generated.h]",
33        },
34        exported_external_deps = [
35            "flatbuffers-api",
36        ],
37    )
38
39    if is_fbcode:
40        runtime.python_library(
41            name = "lib",
42            srcs = [
43                "vulkan_graph_builder.py",
44                "vulkan_graph_schema.py",
45                "vulkan_graph_serialize.py",
46            ],
47            resources = [
48                "schema.fbs",
49            ],
50            visibility = [
51                "//executorch/...",
52                "//executorch/vulkan/...",
53                "@EXECUTORCH_CLIENTS",
54            ],
55            deps = [
56                "//executorch/exir:graph_module",
57                "//executorch/exir/_serialize:_bindings",
58                "//executorch/exir/_serialize:lib",
59            ],
60        )
61