• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// 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
17package {
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
26filegroup {
27    name: "inputconstants_aidl",
28    srcs: [
29        "android/os/IInputConstants.aidl",
30        "android/os/InputEventInjectionResult.aidl",
31        "android/os/InputEventInjectionSync.aidl",
32        "android/os/InputConfig.aidl",
33    ],
34}
35
36aidl_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
168cc_library {
169    name: "libinput",
170    cpp_std: "c++20",
171    host_supported: true,
172    cflags: [
173        "-Wall",
174        "-Wextra",
175        "-Werror",
176        "-Wno-unused-parameter",
177    ],
178    srcs: [
179        "FromRustToCpp.cpp",
180        "Input.cpp",
181        "InputDevice.cpp",
182        "InputEventLabels.cpp",
183        "InputVerifier.cpp",
184        "Keyboard.cpp",
185        "KeyCharacterMap.cpp",
186        "KeyLayoutMap.cpp",
187        "MotionPredictor.cpp",
188        "MotionPredictorMetricsManager.cpp",
189        "PrintTools.cpp",
190        "PropertyMap.cpp",
191        "TfLiteMotionPredictor.cpp",
192        "TouchVideoFrame.cpp",
193        "VelocityControl.cpp",
194        "VelocityTracker.cpp",
195        "VirtualInputDevice.cpp",
196        "VirtualKeyMap.cpp",
197    ],
198
199    header_libs: [
200        "flatbuffer_headers",
201        "jni_headers",
202        "libeigen",
203        "tensorflow_headers",
204    ],
205    export_header_lib_headers: [
206        "jni_headers",
207        "libeigen",
208    ],
209
210    generated_headers: [
211        "cxx-bridge-header",
212        "libinput_cxx_bridge_header",
213        "toolbox_input_labels",
214    ],
215
216    generated_sources: ["libinput_cxx_bridge_code"],
217
218    shared_libs: [
219        "libbase",
220        "libcutils",
221        "liblog",
222        "libPlatformProperties",
223        "libtinyxml2",
224        "libvintf",
225    ],
226
227    ldflags: [
228        "-Wl,--exclude-libs=libtflite_static.a",
229    ],
230
231    sanitize: {
232        undefined: true,
233        all_undefined: true,
234        misc_undefined: ["integer"],
235    },
236
237    static_libs: [
238        "inputconstants-cpp",
239        "libui-types",
240        "libtflite_static",
241    ],
242
243    whole_static_libs: [
244        "libinput_rust",
245    ],
246
247    export_static_lib_headers: [
248        "libui-types",
249    ],
250
251    export_generated_headers: [
252        "cxx-bridge-header",
253        "libinput_cxx_bridge_header",
254    ],
255
256    target: {
257        android: {
258            srcs: [
259                "InputTransport.cpp",
260                "android/os/IInputFlinger.aidl",
261            ],
262
263            export_shared_lib_headers: ["libbinder"],
264
265            shared_libs: [
266                "libutils",
267                "libbinder",
268                // Stats logging library and its dependencies.
269                "libstatslog_libinput",
270                "libstatsbootstrap",
271                "android.os.statsbootstrap_aidl-cpp",
272            ],
273
274            static_libs: [
275                "libgui_window_info_static",
276            ],
277
278            export_static_lib_headers: [
279                "libgui_window_info_static",
280            ],
281
282            required: [
283                "motion_predictor_model_prebuilt",
284                "motion_predictor_model_config",
285            ],
286        },
287        host: {
288            shared: {
289                enabled: false,
290            },
291            include_dirs: [
292                "bionic/libc/kernel/android/uapi/",
293                "bionic/libc/kernel/uapi",
294                "frameworks/native/libs/arect/include",
295            ],
296        },
297        host_linux: {
298            srcs: [
299                "InputTransport.cpp",
300            ],
301            static_libs: [
302                "libgui_window_info_static",
303            ],
304            shared_libs: [
305                "libbinder",
306            ],
307
308            export_static_lib_headers: [
309                "libgui_window_info_static",
310            ],
311        },
312    },
313
314    aidl: {
315        local_include_dirs: ["."],
316        export_aidl_headers: true,
317        include_dirs: [
318            "frameworks/native/libs/gui",
319        ],
320    },
321}
322
323// Use bootstrap version of stats logging library.
324// libinput is a bootstrap process (starts early in the boot process), and thus can't use the normal
325// `libstatslog` because that requires `libstatssocket`, which is only available later in the boot.
326cc_library {
327    name: "libstatslog_libinput",
328    generated_sources: ["statslog_libinput.cpp"],
329    generated_headers: ["statslog_libinput.h"],
330    export_generated_headers: ["statslog_libinput.h"],
331    shared_libs: [
332        "libbinder",
333        "libstatsbootstrap",
334        "libutils",
335        "android.os.statsbootstrap_aidl-cpp",
336    ],
337}
338
339genrule {
340    name: "statslog_libinput.h",
341    tools: ["stats-log-api-gen"],
342    cmd: "$(location stats-log-api-gen) --header $(genDir)/statslog_libinput.h --module libinput" +
343        " --namespace android,stats,libinput --bootstrap",
344    out: [
345        "statslog_libinput.h",
346    ],
347}
348
349genrule {
350    name: "statslog_libinput.cpp",
351    tools: ["stats-log-api-gen"],
352    cmd: "$(location stats-log-api-gen) --cpp $(genDir)/statslog_libinput.cpp --module libinput" +
353        " --namespace android,stats,libinput --importHeader statslog_libinput.h" +
354        " --bootstrap",
355    out: [
356        "statslog_libinput.cpp",
357    ],
358}
359
360cc_defaults {
361    name: "libinput_fuzz_defaults",
362    cpp_std: "c++20",
363    host_supported: true,
364    shared_libs: [
365        "libutils",
366        "libbase",
367        "liblog",
368    ],
369}
370
371cc_fuzz {
372    name: "libinput_fuzz_propertymap",
373    defaults: ["libinput_fuzz_defaults"],
374    srcs: [
375        "PropertyMap.cpp",
376        "PropertyMap_fuzz.cpp",
377    ],
378}
379
380subdirs = ["tests"]
381