1*38e8c45fSAndroid Build Coastguard Worker// Copyright 2023 The Android Open Source Project 2*38e8c45fSAndroid Build Coastguard Worker// 3*38e8c45fSAndroid Build Coastguard Worker// Licensed under the Apache License, Version 2.0 (the "License"); 4*38e8c45fSAndroid Build Coastguard Worker// you may not use this file except in compliance with the License. 5*38e8c45fSAndroid Build Coastguard Worker// You may obtain a copy of the License at 6*38e8c45fSAndroid Build Coastguard Worker// 7*38e8c45fSAndroid Build Coastguard Worker// http://www.apache.org/licenses/LICENSE-2.0 8*38e8c45fSAndroid Build Coastguard Worker// 9*38e8c45fSAndroid Build Coastguard Worker// Unless required by applicable law or agreed to in writing, software 10*38e8c45fSAndroid Build Coastguard Worker// distributed under the License is distributed on an "AS IS" BASIS, 11*38e8c45fSAndroid Build Coastguard Worker// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*38e8c45fSAndroid Build Coastguard Worker// See the License for the specific language governing permissions and 13*38e8c45fSAndroid Build Coastguard Worker// limitations under the License. 14*38e8c45fSAndroid Build Coastguard Worker 15*38e8c45fSAndroid Build Coastguard Worker// Generate the C++ code that Rust calls into. 16*38e8c45fSAndroid Build Coastguard Workerpackage { 17*38e8c45fSAndroid Build Coastguard Worker default_team: "trendy_team_input_framework", 18*38e8c45fSAndroid Build Coastguard Worker} 19*38e8c45fSAndroid Build Coastguard Worker 20*38e8c45fSAndroid Build Coastguard Workergenrule { 21*38e8c45fSAndroid Build Coastguard Worker name: "inputflinger_rs_bootstrap_bridge_code", 22*38e8c45fSAndroid Build Coastguard Worker tools: ["cxxbridge"], 23*38e8c45fSAndroid Build Coastguard Worker cmd: "$(location cxxbridge) $(in) >> $(out)", 24*38e8c45fSAndroid Build Coastguard Worker srcs: ["lib.rs"], 25*38e8c45fSAndroid Build Coastguard Worker out: ["inputflinger_rs_bootstrap_cxx_generated.cc"], 26*38e8c45fSAndroid Build Coastguard Worker} 27*38e8c45fSAndroid Build Coastguard Worker 28*38e8c45fSAndroid Build Coastguard Worker// Generate a C++ header containing the C++ bindings 29*38e8c45fSAndroid Build Coastguard Worker// to the Rust exported functions in lib.rs. 30*38e8c45fSAndroid Build Coastguard Workergenrule { 31*38e8c45fSAndroid Build Coastguard Worker name: "inputflinger_rs_bootstrap_bridge_header", 32*38e8c45fSAndroid Build Coastguard Worker tools: ["cxxbridge"], 33*38e8c45fSAndroid Build Coastguard Worker cmd: "$(location cxxbridge) $(in) --header >> $(out)", 34*38e8c45fSAndroid Build Coastguard Worker srcs: ["lib.rs"], 35*38e8c45fSAndroid Build Coastguard Worker out: ["inputflinger_bootstrap.rs.h"], 36*38e8c45fSAndroid Build Coastguard Worker} 37*38e8c45fSAndroid Build Coastguard Worker 38*38e8c45fSAndroid Build Coastguard Workerrust_defaults { 39*38e8c45fSAndroid Build Coastguard Worker name: "libinputflinger_rs_defaults", 40*38e8c45fSAndroid Build Coastguard Worker crate_name: "inputflinger", 41*38e8c45fSAndroid Build Coastguard Worker srcs: ["lib.rs"], 42*38e8c45fSAndroid Build Coastguard Worker rustlibs: [ 43*38e8c45fSAndroid Build Coastguard Worker "libcxx", 44*38e8c45fSAndroid Build Coastguard Worker "com.android.server.inputflinger-rust", 45*38e8c45fSAndroid Build Coastguard Worker "android.hardware.input.common-V1-rust", 46*38e8c45fSAndroid Build Coastguard Worker "libbinder_rs", 47*38e8c45fSAndroid Build Coastguard Worker "liblog_rust", 48*38e8c45fSAndroid Build Coastguard Worker "liblogger", 49*38e8c45fSAndroid Build Coastguard Worker "libnix", 50*38e8c45fSAndroid Build Coastguard Worker "libinput_rust", 51*38e8c45fSAndroid Build Coastguard Worker ], 52*38e8c45fSAndroid Build Coastguard Worker host_supported: true, 53*38e8c45fSAndroid Build Coastguard Worker} 54*38e8c45fSAndroid Build Coastguard Worker 55*38e8c45fSAndroid Build Coastguard Workerrust_ffi_static { 56*38e8c45fSAndroid Build Coastguard Worker name: "libinputflinger_rs", 57*38e8c45fSAndroid Build Coastguard Worker defaults: ["libinputflinger_rs_defaults"], 58*38e8c45fSAndroid Build Coastguard Worker} 59*38e8c45fSAndroid Build Coastguard Worker 60*38e8c45fSAndroid Build Coastguard Workerrust_test { 61*38e8c45fSAndroid Build Coastguard Worker name: "libinputflinger_rs_test", 62*38e8c45fSAndroid Build Coastguard Worker defaults: ["libinputflinger_rs_defaults"], 63*38e8c45fSAndroid Build Coastguard Worker test_options: { 64*38e8c45fSAndroid Build Coastguard Worker unit_test: true, 65*38e8c45fSAndroid Build Coastguard Worker }, 66*38e8c45fSAndroid Build Coastguard Worker test_suites: ["device_tests"], 67*38e8c45fSAndroid Build Coastguard Worker sanitize: { 68*38e8c45fSAndroid Build Coastguard Worker address: true, 69*38e8c45fSAndroid Build Coastguard Worker hwaddress: true, 70*38e8c45fSAndroid Build Coastguard Worker }, 71*38e8c45fSAndroid Build Coastguard Worker} 72*38e8c45fSAndroid Build Coastguard Worker 73*38e8c45fSAndroid Build Coastguard Workercc_library_headers { 74*38e8c45fSAndroid Build Coastguard Worker name: "inputflinger_rs_bootstrap_cxx_headers", 75*38e8c45fSAndroid Build Coastguard Worker host_supported: true, 76*38e8c45fSAndroid Build Coastguard Worker export_include_dirs: ["ffi"], 77*38e8c45fSAndroid Build Coastguard Worker} 78