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        "android/os/PointerIconType.aidl",
34    ],
35}
36
37/////////////////////////////////////////////////
38// flags
39/////////////////////////////////////////////////
40aconfig_declarations {
41    name: "com.android.input.flags-aconfig",
42    package: "com.android.input.flags",
43    container: "system",
44    srcs: ["input_flags.aconfig"],
45}
46
47cc_aconfig_library {
48    name: "com.android.input.flags-aconfig-cc",
49    aconfig_declarations: "com.android.input.flags-aconfig",
50    host_supported: true,
51    // Use the test version of the aconfig flag library by default to allow tests to set local
52    // overrides for flags, without having to link against a separate version of libinput or of this
53    // library. Bundling this library directly into libinput prevents us from having to add this
54    // library as a shared lib dependency everywhere where libinput is used.
55    mode: "test",
56    shared: {
57        enabled: false,
58    },
59}
60
61aidl_interface {
62    name: "inputconstants",
63    host_supported: true,
64    vendor_available: true,
65    unstable: true,
66    srcs: [
67        ":inputconstants_aidl",
68    ],
69
70    backend: {
71        rust: {
72            enabled: true,
73        },
74    },
75}
76
77rust_bindgen {
78    name: "libinput_bindgen",
79    host_supported: true,
80    crate_name: "input_bindgen",
81    visibility: ["//frameworks/native/services/inputflinger"],
82    wrapper_src: "InputWrapper.hpp",
83
84    source_stem: "bindings",
85
86    bindgen_flags: [
87        "--verbose",
88        "--allowlist-var=AMOTION_EVENT_ACTION_CANCEL",
89        "--allowlist-var=AMOTION_EVENT_ACTION_UP",
90        "--allowlist-var=AMOTION_EVENT_ACTION_POINTER_DOWN",
91        "--allowlist-var=AMOTION_EVENT_ACTION_DOWN",
92        "--allowlist-var=AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT",
93        "--allowlist-var=MAX_POINTER_ID",
94        "--allowlist-var=AINPUT_SOURCE_CLASS_NONE",
95        "--allowlist-var=AINPUT_SOURCE_CLASS_BUTTON",
96        "--allowlist-var=AINPUT_SOURCE_CLASS_POINTER",
97        "--allowlist-var=AINPUT_SOURCE_CLASS_NAVIGATION",
98        "--allowlist-var=AINPUT_SOURCE_CLASS_POSITION",
99        "--allowlist-var=AINPUT_SOURCE_CLASS_JOYSTICK",
100        "--allowlist-var=AINPUT_SOURCE_UNKNOWN",
101        "--allowlist-var=AINPUT_SOURCE_KEYBOARD",
102        "--allowlist-var=AINPUT_SOURCE_DPAD",
103        "--allowlist-var=AINPUT_SOURCE_GAMEPAD",
104        "--allowlist-var=AINPUT_SOURCE_TOUCHSCREEN",
105        "--allowlist-var=AINPUT_SOURCE_MOUSE",
106        "--allowlist-var=AINPUT_SOURCE_STYLUS",
107        "--allowlist-var=AINPUT_SOURCE_BLUETOOTH_STYLUS",
108        "--allowlist-var=AINPUT_SOURCE_TRACKBALL",
109        "--allowlist-var=AINPUT_SOURCE_MOUSE_RELATIVE",
110        "--allowlist-var=AINPUT_SOURCE_TOUCHPAD",
111        "--allowlist-var=AINPUT_SOURCE_TOUCH_NAVIGATION",
112        "--allowlist-var=AINPUT_SOURCE_JOYSTICK",
113        "--allowlist-var=AINPUT_SOURCE_HDMI",
114        "--allowlist-var=AINPUT_SOURCE_SENSOR",
115        "--allowlist-var=AINPUT_SOURCE_ROTARY_ENCODER",
116        "--allowlist-var=AINPUT_KEYBOARD_TYPE_NONE",
117        "--allowlist-var=AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC",
118        "--allowlist-var=AINPUT_KEYBOARD_TYPE_ALPHABETIC",
119        "--allowlist-var=AMETA_NONE",
120        "--allowlist-var=AMETA_ALT_ON",
121        "--allowlist-var=AMETA_ALT_LEFT_ON",
122        "--allowlist-var=AMETA_ALT_RIGHT_ON",
123        "--allowlist-var=AMETA_SHIFT_ON",
124        "--allowlist-var=AMETA_SHIFT_LEFT_ON",
125        "--allowlist-var=AMETA_SHIFT_RIGHT_ON",
126        "--allowlist-var=AMETA_SYM_ON",
127        "--allowlist-var=AMETA_FUNCTION_ON",
128        "--allowlist-var=AMETA_CTRL_ON",
129        "--allowlist-var=AMETA_CTRL_LEFT_ON",
130        "--allowlist-var=AMETA_CTRL_RIGHT_ON",
131        "--allowlist-var=AMETA_META_ON",
132        "--allowlist-var=AMETA_META_LEFT_ON",
133        "--allowlist-var=AMETA_META_RIGHT_ON",
134        "--allowlist-var=AMETA_CAPS_LOCK_ON",
135        "--allowlist-var=AMETA_NUM_LOCK_ON",
136        "--allowlist-var=AMETA_SCROLL_LOCK_ON",
137    ],
138
139    static_libs: [
140        "inputconstants-cpp",
141        "libui-types",
142    ],
143    shared_libs: ["libc++"],
144    header_libs: [
145        "native_headers",
146        "jni_headers",
147        "flatbuffer_headers",
148    ],
149}
150
151cc_library_static {
152    name: "iinputflinger_aidl_lib_static",
153    host_supported: true,
154    srcs: [
155        "android/os/IInputFlinger.aidl",
156        "android/os/InputChannelCore.aidl",
157    ],
158    shared_libs: [
159        "libbinder",
160    ],
161    whole_static_libs: [
162        "libgui_window_info_static",
163    ],
164    aidl: {
165        export_aidl_headers: true,
166        local_include_dirs: ["."],
167        include_dirs: [
168            "frameworks/native/libs/gui",
169            "frameworks/native/libs/input",
170        ],
171    },
172}
173
174// Contains methods to help access C++ code from rust
175cc_library_static {
176    name: "libinput_from_rust_to_cpp",
177    cpp_std: "c++20",
178    host_supported: true,
179    cflags: [
180        "-Wall",
181        "-Wextra",
182        "-Werror",
183    ],
184    srcs: [
185        "FromRustToCpp.cpp",
186    ],
187
188    generated_headers: [
189        "cxx-bridge-header",
190    ],
191    generated_sources: ["libinput_cxx_bridge_code"],
192
193    lto: {
194        never: true,
195    },
196
197    shared_libs: [
198        "libbase",
199    ],
200}
201
202cc_library {
203    name: "libinput",
204    cpp_std: "c++20",
205    host_supported: true,
206    cflags: [
207        "-Wall",
208        "-Wextra",
209        "-Werror",
210        "-Wno-unused-parameter",
211        "-Wthread-safety",
212        "-Wshadow",
213        "-Wshadow-field-in-constructor-modified",
214        "-Wshadow-uncaptured-local",
215        "-DANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION",
216    ],
217    srcs: [
218        "AccelerationCurve.cpp",
219        "Input.cpp",
220        "InputConsumer.cpp",
221        "InputConsumerNoResampling.cpp",
222        "InputDevice.cpp",
223        "InputEventLabels.cpp",
224        "InputTransport.cpp",
225        "InputVerifier.cpp",
226        "Keyboard.cpp",
227        "KeyCharacterMap.cpp",
228        "KeyboardClassifier.cpp",
229        "KeyLayoutMap.cpp",
230        "MotionPredictor.cpp",
231        "MotionPredictorMetricsManager.cpp",
232        "PrintTools.cpp",
233        "PropertyMap.cpp",
234        "TfLiteMotionPredictor.cpp",
235        "TouchVideoFrame.cpp",
236        "VelocityControl.cpp",
237        "VelocityTracker.cpp",
238        "VirtualInputDevice.cpp",
239        "VirtualKeyMap.cpp",
240    ],
241
242    header_libs: [
243        "flatbuffer_headers",
244        "jni_headers",
245        "libeigen",
246        "tensorflow_headers",
247    ],
248    export_header_lib_headers: [
249        "jni_headers",
250        "libeigen",
251    ],
252
253    generated_headers: [
254        "cxx-bridge-header",
255        "libinput_cxx_bridge_header",
256        "toolbox_input_labels",
257    ],
258
259    shared_libs: [
260        "libbase",
261        "libbinder",
262        "libbinder_ndk",
263        "libcutils",
264        "liblog",
265        "libPlatformProperties",
266        "libtinyxml2",
267        "libutils",
268        "libz", // needed by libkernelconfigs
269        "server_configurable_flags",
270    ],
271
272    ldflags: [
273        "-Wl,--exclude-libs=libtflite_static.a",
274    ],
275
276    sanitize: {
277        undefined: true,
278        all_undefined: true,
279        misc_undefined: ["integer"],
280    },
281
282    static_libs: [
283        "inputconstants-cpp",
284        "libui-types",
285        "libtflite_static",
286        "libkernelconfigs",
287    ],
288
289    whole_static_libs: [
290        "com.android.input.flags-aconfig-cc",
291        "libinput_rust_ffi",
292        "iinputflinger_aidl_lib_static",
293    ],
294
295    export_static_lib_headers: [
296        "libui-types",
297    ],
298
299    export_generated_headers: [
300        "cxx-bridge-header",
301        "libinput_cxx_bridge_header",
302    ],
303
304    target: {
305        android: {
306            required: [
307                "motion_predictor_model_prebuilt",
308                "motion_predictor_model_config",
309            ],
310            static_libs: [
311                "libstatslog_libinput",
312                "libstatssocket_lazy",
313            ],
314        },
315        host: {
316            include_dirs: [
317                "bionic/libc/kernel/android/uapi/",
318                "bionic/libc/kernel/uapi",
319            ],
320        },
321    },
322}
323
324cc_library_static {
325    name: "libstatslog_libinput",
326    generated_sources: ["statslog_libinput.cpp"],
327    generated_headers: ["statslog_libinput.h"],
328    cflags: [
329        "-Wall",
330        "-Werror",
331    ],
332    export_generated_headers: ["statslog_libinput.h"],
333    shared_libs: [
334        "libcutils",
335        "liblog",
336        "libutils",
337    ],
338    static_libs: [
339        "libstatssocket_lazy",
340    ],
341}
342
343genrule {
344    name: "statslog_libinput.h",
345    tools: ["stats-log-api-gen"],
346    cmd: "$(location stats-log-api-gen) --header $(genDir)/statslog_libinput.h " +
347        "--module libinput --namespace android,libinput",
348    out: [
349        "statslog_libinput.h",
350    ],
351}
352
353genrule {
354    name: "statslog_libinput.cpp",
355    tools: ["stats-log-api-gen"],
356    cmd: "$(location stats-log-api-gen) --cpp $(genDir)/statslog_libinput.cpp " +
357        "--module libinput --namespace android,libinput " +
358        "--importHeader statslog_libinput.h",
359    out: [
360        "statslog_libinput.cpp",
361    ],
362}
363
364cc_defaults {
365    name: "libinput_fuzz_defaults",
366    cpp_std: "c++20",
367    host_supported: true,
368    shared_libs: [
369        "libutils",
370        "libbase",
371        "liblog",
372    ],
373}
374
375cc_fuzz {
376    name: "libinput_fuzz_propertymap",
377    defaults: ["libinput_fuzz_defaults"],
378    srcs: [
379        "PropertyMap.cpp",
380        "PropertyMap_fuzz.cpp",
381    ],
382}
383
384subdirs = ["tests"]
385