xref: /aosp_15_r20/external/executorch/Android.bp (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1cc_library {
2    name: "libexecutorch",
3    srcs: [
4        "extension/data_loader/file_data_loader.cpp",
5        "extension/data_loader/mmap_data_loader.cpp",
6        "extension/evalue_util/print_evalue.cpp",
7        "extension/runner_util/inputs.cpp",
8        "extension/runner_util/inputs_portable.cpp",
9        ":executorch_portable_ops_gen_cpp",
10        "kernels/portable/cpu/*.cpp",
11        "kernels/portable/cpu/pattern/*.cpp",
12        "kernels/portable/cpu/util/*.cpp",
13        "kernels/prim_ops/et_copy_index.cpp",
14        "kernels/prim_ops/et_view.cpp",
15        "kernels/prim_ops/register_prim_ops.cpp",
16        "runtime/backend/interface.cpp",
17        "runtime/core/evalue.cpp",
18        "runtime/core/exec_aten/util/tensor_util_portable.cpp",
19        "runtime/core/portable_type/tensor_impl.cpp",
20        "runtime/executor/method.cpp",
21        "runtime/executor/method_meta.cpp",
22        "runtime/executor/program.cpp",
23        "runtime/executor/tensor_parser_exec_aten.cpp",
24        "runtime/executor/tensor_parser_portable.cpp",
25        "runtime/kernel/operator_registry.cpp",
26        "runtime/platform/abort.cpp",
27        "runtime/platform/default/posix.cpp",
28        "runtime/platform/log.cpp",
29        "runtime/platform/profiler.cpp",
30        "runtime/platform/runtime.cpp",
31        "schema/extended_header.cpp",
32    ],
33    header_libs: [
34        "flatbuffer_headers",
35    ],
36    generated_headers: [
37        "executorch_fbs_gen",
38        "executorch_portable_ops_gen_h",
39    ],
40    stl: "libc++_static",
41    cflags: [
42        "-Wno-unused-parameter",
43    ],
44    host_supported: true,
45    apex_available: ["com.android.ondevicepersonalization"],
46    sdk_version: "current",
47    min_sdk_version: "33",
48    visibility: ["//packages/modules/OnDevicePersonalization:__subpackages__"],
49}
50
51cc_binary {
52    name: "executor_runner",
53    srcs: ["examples/portable/executor_runner/executor_runner.cpp"],
54    static_libs: [
55        "libgflags",
56    ],
57    whole_static_libs: [
58        "libexecutorch",
59    ],
60    host_supported: true,
61}
62
63cc_genrule {
64    name: "executorch_fbs_gen",
65    host_supported: true,
66    tools: ["flatc"],
67    srcs: [
68        "schema/program.fbs",
69        "schema/scalar_type.fbs",
70    ],
71    out: [
72        "executorch/schema/program_generated.h",
73        "executorch/schema/scalar_type_generated.h",
74    ],
75    sdk_version: "current",
76    apex_available: ["com.android.ondevicepersonalization"],
77    cmd: "$(location flatc) --cpp --cpp-std c++11 --gen-mutable --scoped-enums --include-prefix executorch/schema/ " +
78        "-o $(genDir)/executorch/schema/ $(in)",
79}
80
81filegroup {
82    name: "executorch_codegen_templates",
83    srcs: [
84        "codegen/templates/*.cpp",
85        "codegen/templates/*.h",
86        "codegen/templates/*.ini",
87    ],
88}
89
90filegroup {
91    name: "executorch_portable_yaml",
92    srcs: [
93        "kernels/portable/functions.yaml",
94    ],
95}
96
97cc_genrule {
98    name: "executorch_portable_ops_gen_cpp",
99    host_supported: true,
100    tools: ["torchgen_executorch"],
101    tool_files: [
102        ":executorch_codegen_templates",
103        ":executorch_portable_yaml",
104        ":torchgen_native_functions",
105        ":torchgen_tags",
106    ],
107    out: [
108        "RegisterCodegenUnboxedKernels_0.cpp",
109    ],
110    sdk_version: "current",
111    apex_available: ["com.android.ondevicepersonalization"],
112    cmd: "mkdir templates; cp $(locations :executorch_codegen_templates) templates;" +
113        "$(location torchgen_executorch) " +
114        "--source-path=. " +
115        "--tags-path=$(location :torchgen_tags) " +
116        "--aten_yaml_path=$(location :torchgen_native_functions) " +
117        "--functions_yaml_path=$(location :executorch_portable_yaml) " +
118        "--install_dir=$(genDir)/",
119}
120
121cc_genrule {
122    name: "executorch_portable_ops_gen_h",
123    host_supported: true,
124    tools: ["torchgen_executorch"],
125    tool_files: [
126        ":executorch_codegen_templates",
127        ":executorch_portable_yaml",
128        ":torchgen_native_functions",
129        ":torchgen_tags",
130    ],
131    out: [
132        "NativeFunctions.h",
133    ],
134    sdk_version: "current",
135    apex_available: ["com.android.ondevicepersonalization"],
136    cmd: "mkdir templates; cp $(locations :executorch_codegen_templates) templates;" +
137        "$(location torchgen_executorch) " +
138        "--source-path=. " +
139        "--tags-path=$(location :torchgen_tags) " +
140        "--aten_yaml_path=$(location :torchgen_native_functions) " +
141        "--functions_yaml_path=$(location :executorch_portable_yaml) " +
142        "--install_dir=$(genDir)/",
143}
144