blob: a67ed298081717702d38dba8ea43da1546051268 [file] [log] [blame]
Dan Willemsen59e086f2016-07-25 17:13:45 -07001// Copyright (C) 2013 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15// libinput is partially built for the host (used by build time keymap validation tool)
16
Bob Badour3306e492021-02-25 15:35:37 -080017package {
18 // See: http://go/android-license-faq
19 // A large-scale-change added 'default_applicable_licenses' to import
20 // all of the 'license_kinds' from "frameworks_native_license"
21 // to get the below license kinds:
22 // SPDX-license-identifier-Apache-2.0
23 default_applicable_licenses: ["frameworks_native_license"],
24}
25
Siarhei Vishniakou70622952020-07-30 11:17:23 -050026filegroup {
27 name: "inputconstants_aidl",
28 srcs: [
Siarhei Vishniakouae6229e2019-12-30 16:23:19 -080029 "android/os/IInputConstants.aidl",
30 "android/os/InputEventInjectionResult.aidl",
31 "android/os/InputEventInjectionSync.aidl",
Prabir Pradhan51e7db02022-02-07 06:02:57 -080032 "android/os/InputConfig.aidl",
Siarhei Vishniakou70622952020-07-30 11:17:23 -050033 ],
34}
35
Siarhei Vishniakou5c02a712023-05-15 15:45:02 -070036aidl_interface {
37 name: "inputconstants",
38 host_supported: true,
39 vendor_available: true,
40 unstable: true,
41 srcs: [
42 ":inputconstants_aidl",
43 ],
44
45 backend: {
46 rust: {
47 enabled: true,
48 },
49 },
50}
51
52rust_bindgen {
53 name: "libinput_bindgen",
54 host_supported: true,
55 crate_name: "input_bindgen",
56 visibility: ["//frameworks/native/services/inputflinger"],
57 wrapper_src: "InputWrapper.hpp",
58
59 include_dirs: [
60 "frameworks/native/include",
61 ],
62
63 source_stem: "bindings",
64
65 bindgen_flags: [
66 "--verbose",
67 "--allowlist-var=AMOTION_EVENT_FLAG_CANCELED",
68 "--allowlist-var=AMOTION_EVENT_ACTION_CANCEL",
69 "--allowlist-var=AMOTION_EVENT_ACTION_UP",
70 "--allowlist-var=AMOTION_EVENT_ACTION_POINTER_DOWN",
71 "--allowlist-var=AMOTION_EVENT_ACTION_DOWN",
72 "--allowlist-var=AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT",
73 "--allowlist-var=MAX_POINTER_ID",
74 ],
75
76 static_libs: [
77 "inputconstants-cpp",
78 "libui-types",
79 ],
80 shared_libs: ["libc++"],
81 header_libs: [
82 "native_headers",
83 "jni_headers",
84 "flatbuffer_headers",
85 ],
86}
87
88// Contains methods to help access C++ code from rust
89cc_library_static {
90 name: "libinput_from_rust_to_cpp",
91 cpp_std: "c++20",
92 host_supported: true,
93 cflags: [
94 "-Wall",
95 "-Wextra",
96 "-Werror",
97 ],
98 srcs: [
99 "FromRustToCpp.cpp",
100 ],
101
102 generated_headers: [
103 "cxx-bridge-header",
104 ],
105 generated_sources: ["libinput_cxx_bridge_code"],
106
107 shared_libs: [
108 "libbase",
109 ],
110}
111
112genrule {
113 name: "libinput_cxx_bridge_code",
114 tools: ["cxxbridge"],
115 cmd: "$(location cxxbridge) $(in) >> $(out)",
116 srcs: ["input_verifier.rs"],
117 out: ["inputverifier_generated.cpp"],
118}
119
120genrule {
121 name: "libinput_cxx_bridge_header",
122 tools: ["cxxbridge"],
123 cmd: "$(location cxxbridge) $(in) --header >> $(out)",
124 srcs: ["input_verifier.rs"],
125 out: ["input_verifier.rs.h"],
126}
127
128rust_defaults {
129 name: "libinput_rust_defaults",
130 srcs: ["input_verifier.rs"],
131 host_supported: true,
132 rustlibs: [
133 "libbitflags",
134 "libcxx",
135 "libinput_bindgen",
136 "liblogger",
137 "liblog_rust",
138 "inputconstants-rust",
139 ],
140
141 shared_libs: [
142 "libbase",
143 "liblog",
144 ],
145}
146
147rust_ffi_static {
148 name: "libinput_rust",
149 crate_name: "input",
150 defaults: ["libinput_rust_defaults"],
151}
152
153rust_test {
154 name: "libinput_rust_test",
155 defaults: ["libinput_rust_defaults"],
156 whole_static_libs: [
157 "libinput_from_rust_to_cpp",
158 ],
159 test_options: {
160 unit_test: true,
161 },
162 test_suites: ["device_tests"],
163 sanitize: {
164 hwaddress: true,
165 },
166}
167
Dan Willemsen59e086f2016-07-25 17:13:45 -0700168cc_library {
169 name: "libinput",
Siarhei Vishniakoubb192872021-12-09 17:14:49 -0800170 cpp_std: "c++20",
Dan Willemsen59e086f2016-07-25 17:13:45 -0700171 host_supported: true,
Frank Barchard9e947882017-03-06 11:17:52 -0800172 cflags: [
173 "-Wall",
174 "-Wextra",
175 "-Werror",
Philip Quinn8f953ab2022-12-06 15:37:07 -0800176 "-Wno-unused-parameter",
Frank Barchard9e947882017-03-06 11:17:52 -0800177 ],
Dan Willemsen59e086f2016-07-25 17:13:45 -0700178 srcs: [
Siarhei Vishniakou5c02a712023-05-15 15:45:02 -0700179 "FromRustToCpp.cpp",
Dan Willemsen59e086f2016-07-25 17:13:45 -0700180 "Input.cpp",
181 "InputDevice.cpp",
Chris Ye4958d062020-08-20 13:21:10 -0700182 "InputEventLabels.cpp",
Siarhei Vishniakou92c8fd52023-01-29 14:57:43 -0800183 "InputVerifier.cpp",
Dan Willemsen59e086f2016-07-25 17:13:45 -0700184 "Keyboard.cpp",
185 "KeyCharacterMap.cpp",
186 "KeyLayoutMap.cpp",
Siarhei Vishniakou39147ce2022-11-15 12:13:04 -0800187 "MotionPredictor.cpp",
Cody Heiner7543d902023-06-29 13:19:01 -0700188 "MotionPredictorMetricsManager.cpp",
Siarhei Vishniakou814ace32022-03-04 15:12:16 -0800189 "PrintTools.cpp",
Siarhei Vishniakou32f36ae2020-09-02 20:17:10 -0700190 "PropertyMap.cpp",
Philip Quinn8f953ab2022-12-06 15:37:07 -0800191 "TfLiteMotionPredictor.cpp",
Siarhei Vishniakou26cf29d2019-02-15 16:48:38 -0600192 "TouchVideoFrame.cpp",
Brett Chabot58208522020-09-09 13:55:24 -0700193 "VelocityControl.cpp",
194 "VelocityTracker.cpp",
Zixuan Qudd0635d2023-02-06 04:52:38 +0000195 "VirtualInputDevice.cpp",
Siarhei Vishniakou5ac663d2019-02-15 17:15:56 -0600196 "VirtualKeyMap.cpp",
Dan Willemsen59e086f2016-07-25 17:13:45 -0700197 ],
198
Philip Quinn8f953ab2022-12-06 15:37:07 -0800199 header_libs: [
200 "flatbuffer_headers",
201 "jni_headers",
Cody Heiner7543d902023-06-29 13:19:01 -0700202 "libeigen",
Philip Quinn8f953ab2022-12-06 15:37:07 -0800203 "tensorflow_headers",
204 ],
Cody Heiner7543d902023-06-29 13:19:01 -0700205 export_header_lib_headers: [
206 "jni_headers",
207 "libeigen",
208 ],
Orion Hodsone32877a2020-04-22 11:10:13 +0100209
Prabir Pradhan1e63fc22023-02-23 19:03:03 +0000210 generated_headers: [
Siarhei Vishniakou5c02a712023-05-15 15:45:02 -0700211 "cxx-bridge-header",
212 "libinput_cxx_bridge_header",
Prabir Pradhan1e63fc22023-02-23 19:03:03 +0000213 "toolbox_input_labels",
214 ],
215
Siarhei Vishniakou5c02a712023-05-15 15:45:02 -0700216 generated_sources: ["libinput_cxx_bridge_code"],
217
Dan Willemsen59e086f2016-07-25 17:13:45 -0700218 shared_libs: [
Siarhei Vishniakouec2727e2017-07-06 10:22:03 -0700219 "libbase",
Dan Willemsen59e086f2016-07-25 17:13:45 -0700220 "libcutils",
Siarhei Vishniakou39147ce2022-11-15 12:13:04 -0800221 "liblog",
222 "libPlatformProperties",
Philip Quinnf84fa492023-06-26 14:15:15 -0700223 "libtinyxml2",
Jooyung Han336a87e2023-12-05 14:18:19 +0900224 "libz", // needed by libkernelconfigs
Philip Quinnda6a4482023-02-07 10:09:57 -0800225 ],
226
227 ldflags: [
228 "-Wl,--exclude-libs=libtflite_static.a",
Dan Willemsen59e086f2016-07-25 17:13:45 -0700229 ],
230
Siarhei Vishniakoudd882482023-04-28 21:13:26 +0000231 sanitize: {
232 undefined: true,
233 all_undefined: true,
234 misc_undefined: ["integer"],
235 },
236
chaviwfd9c1ed2020-07-01 10:57:59 -0700237 static_libs: [
Siarhei Vishniakou5c02a712023-05-15 15:45:02 -0700238 "inputconstants-cpp",
chaviwfd9c1ed2020-07-01 10:57:59 -0700239 "libui-types",
Philip Quinnda6a4482023-02-07 10:09:57 -0800240 "libtflite_static",
Jooyung Han336a87e2023-12-05 14:18:19 +0900241 "libkernelconfigs",
chaviwfd9c1ed2020-07-01 10:57:59 -0700242 ],
243
Siarhei Vishniakou5c02a712023-05-15 15:45:02 -0700244 whole_static_libs: [
245 "libinput_rust",
246 ],
247
chaviwfd9c1ed2020-07-01 10:57:59 -0700248 export_static_lib_headers: [
249 "libui-types",
250 ],
251
Siarhei Vishniakou5c02a712023-05-15 15:45:02 -0700252 export_generated_headers: [
253 "cxx-bridge-header",
254 "libinput_cxx_bridge_header",
255 ],
256
Dan Willemsen59e086f2016-07-25 17:13:45 -0700257 target: {
258 android: {
259 srcs: [
Dan Willemsen59e086f2016-07-25 17:13:45 -0700260 "InputTransport.cpp",
Siarhei Vishniakou7766c032021-03-02 20:32:20 +0000261 "android/os/IInputFlinger.aidl",
Dan Willemsen59e086f2016-07-25 17:13:45 -0700262 ],
263
Bernardo Rufinoea97d182020-08-19 14:43:14 +0100264 export_shared_lib_headers: ["libbinder"],
265
Dan Willemsen59e086f2016-07-25 17:13:45 -0700266 shared_libs: [
267 "libutils",
268 "libbinder",
Cody Heiner7543d902023-06-29 13:19:01 -0700269 // Stats logging library and its dependencies.
270 "libstatslog_libinput",
271 "libstatsbootstrap",
272 "android.os.statsbootstrap_aidl-cpp",
Dan Willemsen59e086f2016-07-25 17:13:45 -0700273 ],
Evgenii Stepanovde982972017-01-31 16:37:44 -0800274
Colin Cross433cfd92021-07-16 22:29:59 -0700275 static_libs: [
276 "libgui_window_info_static",
277 ],
278
279 export_static_lib_headers: [
280 "libgui_window_info_static",
281 ],
282
Philip Quinn8f953ab2022-12-06 15:37:07 -0800283 required: [
284 "motion_predictor_model_prebuilt",
Philip Quinnf84fa492023-06-26 14:15:15 -0700285 "motion_predictor_model_config",
Philip Quinn8f953ab2022-12-06 15:37:07 -0800286 ],
Dan Willemsen59e086f2016-07-25 17:13:45 -0700287 },
288 host: {
289 shared: {
290 enabled: false,
291 },
Brett Chabot58208522020-09-09 13:55:24 -0700292 include_dirs: [
Zixuan Qudd0635d2023-02-06 04:52:38 +0000293 "bionic/libc/kernel/android/uapi/",
294 "bionic/libc/kernel/uapi",
Brett Chabot58208522020-09-09 13:55:24 -0700295 "frameworks/native/libs/arect/include",
296 ],
297 },
Colin Cross4a4a85f2022-03-08 18:25:24 -0800298 host_linux: {
Brett Chabot58208522020-09-09 13:55:24 -0700299 srcs: [
300 "InputTransport.cpp",
Brett Chabot58208522020-09-09 13:55:24 -0700301 ],
302 static_libs: [
Colin Cross433cfd92021-07-16 22:29:59 -0700303 "libgui_window_info_static",
Brett Chabot58208522020-09-09 13:55:24 -0700304 ],
305 shared_libs: [
306 "libbinder",
307 ],
Colin Cross433cfd92021-07-16 22:29:59 -0700308
309 export_static_lib_headers: [
310 "libgui_window_info_static",
311 ],
Dan Willemsen59e086f2016-07-25 17:13:45 -0700312 },
313 },
Chris Ye0783e992020-06-02 21:34:49 -0700314
315 aidl: {
316 local_include_dirs: ["."],
Brett Chabot58208522020-09-09 13:55:24 -0700317 export_aidl_headers: true,
chaviw3277faf2021-05-19 16:45:23 -0500318 include_dirs: [
319 "frameworks/native/libs/gui",
320 ],
Chris Ye0783e992020-06-02 21:34:49 -0700321 },
Dan Willemsen59e086f2016-07-25 17:13:45 -0700322}
Dan Willemsenc7dd2b92016-08-25 17:05:22 -0700323
Cody Heiner7543d902023-06-29 13:19:01 -0700324// Use bootstrap version of stats logging library.
325// libinput is a bootstrap process (starts early in the boot process), and thus can't use the normal
326// `libstatslog` because that requires `libstatssocket`, which is only available later in the boot.
327cc_library {
328 name: "libstatslog_libinput",
329 generated_sources: ["statslog_libinput.cpp"],
330 generated_headers: ["statslog_libinput.h"],
331 export_generated_headers: ["statslog_libinput.h"],
332 shared_libs: [
333 "libbinder",
334 "libstatsbootstrap",
335 "libutils",
336 "android.os.statsbootstrap_aidl-cpp",
337 ],
338}
339
340genrule {
341 name: "statslog_libinput.h",
342 tools: ["stats-log-api-gen"],
343 cmd: "$(location stats-log-api-gen) --header $(genDir)/statslog_libinput.h --module libinput" +
344 " --namespace android,stats,libinput --bootstrap",
345 out: [
346 "statslog_libinput.h",
347 ],
348}
349
350genrule {
351 name: "statslog_libinput.cpp",
352 tools: ["stats-log-api-gen"],
353 cmd: "$(location stats-log-api-gen) --cpp $(genDir)/statslog_libinput.cpp --module libinput" +
354 " --namespace android,stats,libinput --importHeader statslog_libinput.h" +
355 " --bootstrap",
356 out: [
357 "statslog_libinput.cpp",
358 ],
359}
360
Siarhei Vishniakou32f36ae2020-09-02 20:17:10 -0700361cc_defaults {
362 name: "libinput_fuzz_defaults",
Harry Cutts2b67ff12023-03-13 11:32:06 +0000363 cpp_std: "c++20",
Siarhei Vishniakou32f36ae2020-09-02 20:17:10 -0700364 host_supported: true,
365 shared_libs: [
366 "libutils",
367 "libbase",
368 "liblog",
369 ],
370}
371
372cc_fuzz {
373 name: "libinput_fuzz_propertymap",
374 defaults: ["libinput_fuzz_defaults"],
375 srcs: [
376 "PropertyMap.cpp",
377 "PropertyMap_fuzz.cpp",
378 ],
379}
380
Dan Willemsenc7dd2b92016-08-25 17:05:22 -0700381subdirs = ["tests"]