1// Copyright 2023 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// Generate the C++ code that Rust calls into.
16package {
17    default_team: "trendy_team_input_framework",
18}
19
20genrule {
21    name: "inputflinger_rs_bootstrap_bridge_code",
22    tools: ["cxxbridge"],
23    cmd: "$(location cxxbridge) $(in) >> $(out)",
24    srcs: ["lib.rs"],
25    out: ["inputflinger_rs_bootstrap_cxx_generated.cc"],
26}
27
28// Generate a C++ header containing the C++ bindings
29// to the Rust exported functions in lib.rs.
30genrule {
31    name: "inputflinger_rs_bootstrap_bridge_header",
32    tools: ["cxxbridge"],
33    cmd: "$(location cxxbridge) $(in) --header >> $(out)",
34    srcs: ["lib.rs"],
35    out: ["inputflinger_bootstrap.rs.h"],
36}
37
38rust_defaults {
39    name: "libinputflinger_rs_defaults",
40    crate_name: "inputflinger",
41    srcs: ["lib.rs"],
42    rustlibs: [
43        "libcxx",
44        "com.android.server.inputflinger-rust",
45        "android.hardware.input.common-V1-rust",
46        "libbinder_rs",
47        "liblog_rust",
48        "liblogger",
49        "libnix",
50        "libinput_rust",
51    ],
52    host_supported: true,
53}
54
55rust_ffi_static {
56    name: "libinputflinger_rs",
57    defaults: ["libinputflinger_rs_defaults"],
58}
59
60rust_test {
61    name: "libinputflinger_rs_test",
62    defaults: ["libinputflinger_rs_defaults"],
63    test_options: {
64        unit_test: true,
65    },
66    test_suites: ["device_tests"],
67    sanitize: {
68        address: true,
69        hwaddress: true,
70    },
71}
72
73cc_library_headers {
74    name: "inputflinger_rs_bootstrap_cxx_headers",
75    host_supported: true,
76    export_include_dirs: ["ffi"],
77}
78