1// Copyright (C) 2016 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 15package { 16 default_applicable_licenses: ["Android-Apache-2.0"], 17} 18 19cc_library { 20 name: "libfmq", 21 shared_libs: [ 22 "libbase", 23 "liblog", 24 "libcutils", 25 "libutils", 26 ], 27 export_shared_lib_headers: [ 28 "libcutils", 29 "libutils", 30 ], 31 apex_available: [ 32 "//apex_available:platform", 33 "com.android.btservices", 34 "com.android.media.swcodec", 35 "com.android.neuralnetworks", 36 "test_com.android.media.swcodec", 37 "test_com.android.neuralnetworks", 38 ], 39 export_include_dirs: ["include"], 40 local_include_dirs: ["include"], 41 header_libs: [ 42 "libfmq-base", 43 ], 44 export_header_lib_headers: [ 45 "libfmq-base", 46 ], 47 srcs: [ 48 "EventFlag.cpp", 49 "FmqInternal.cpp", 50 ], 51 cflags: [ 52 "-Wall", 53 "-Werror", 54 ], 55 vendor_available: true, 56 product_available: true, 57 // TODO(b/153609531): remove when no longer needed. 58 native_bridge_supported: true, 59 double_loadable: true, 60 min_sdk_version: "29", 61 host_supported: true, 62} 63 64// Header only lib to share type between HIDL and AIDL MQDescriptor 65cc_library_headers { 66 name: "libfmq-base", 67 host_supported: true, 68 vendor_available: true, 69 product_available: true, 70 native_bridge_supported: true, 71 recovery_available: true, 72 apex_available: [ 73 "//apex_available:anyapex", 74 "//apex_available:platform", 75 ], 76 export_include_dirs: ["base"], 77 min_sdk_version: "29", 78} 79 80cc_library { 81 name: "libfmq_erased", 82 shared_libs: [ 83 "libbase", 84 "liblog", 85 "libcutils", 86 "libfmq", 87 "android.hardware.common.fmq-V1-ndk", 88 ], 89 srcs: [ 90 "ErasedMessageQueue.cpp", 91 ], 92 cflags: [ 93 "-Wall", 94 "-Werror", 95 ], 96 vendor_available: true, 97 product_available: true, 98 min_sdk_version: "29", 99 host_supported: true, 100} 101 102rust_bindgen { 103 name: "libfmq_bindgen", 104 wrapper_src: "ErasedMessageQueue.hpp", 105 crate_name: "fmq_bindgen", 106 edition: "2021", 107 host_supported: true, 108 vendor_available: true, 109 product_available: true, 110 visibility: [":__subpackages__"], 111 source_stem: "fmq", 112 bindgen_flags: [ 113 "--no-recursive-allowlist", 114 "--use-core", 115 "--ctypes-prefix=core::ffi", 116 "--raw-line=#![no_std]", 117 "--raw-line=pub use android_hardware_common_fmq::aidl::android::hardware::common::fmq::{MQDescriptor::MQDescriptor, UnsynchronizedWrite::UnsynchronizedWrite, SynchronizedReadWrite::SynchronizedReadWrite, GrantorDescriptor::GrantorDescriptor};", 118 "--raw-line=pub use android_hardware_common::{aidl::android::hardware::common::NativeHandle::NativeHandle, binder::ParcelFileDescriptor};", 119 "--raw-line=pub enum android_MQErased {}", 120 "--raw-line=#[repr(C)]", 121 "--raw-line=pub struct aidl_android_hardware_common_fmq_GrantorDescriptor {", 122 "--raw-line= pub fdIndex: i32,", 123 "--raw-line= pub offset: i32,", 124 "--raw-line= pub extent: i64,", 125 "--raw-line=}", 126 "--opaque-type=ErasedMessageQueueDesc", 127 "--opaque-type=.*AidlMessageQueue", 128 "--with-derive-default", 129 "--no-default=MessageQueueDesc", 130 "--no-default=ErasedMessageQueue", 131 "--allowlist-function=convertGrantor", 132 "--allowlist-function=convertDesc", 133 "--allowlist-function=freeDesc", 134 "--allowlist-type=ndk::ScopedFileDescriptor", 135 "--allowlist-function=descGrantors", 136 "--allowlist-function=descNumGrantors", 137 "--allowlist-function=descHandleFDs", 138 "--allowlist-function=descHandleNumFDs", 139 "--allowlist-function=descHandleInts", 140 "--allowlist-function=descHandleNumInts", 141 "--allowlist-function=descQuantum", 142 "--allowlist-function=descFlags", 143 "--allowlist-type=\\bErasedMessageQueue", 144 "--allowlist-type=\\bErasedMessageQueueDesc", 145 "--allowlist-type=\\bMemTransaction", 146 "--allowlist-type=.*MemTransaction.*MemRegion.*", 147 "--blocklist-type=std::.+", 148 "--allowlist-function=.*ErasedMessageQueue.*", 149 "--allowlist-function=.*beginWrite", 150 "--allowlist-function=.*beginRead", 151 "--allowlist-function=.*commitWrite", 152 "--allowlist-function=.*commitRead", 153 "--allowlist-function=getAddress", 154 "--allowlist-function=getLength.*", 155 "--allowlist-function=get(First|Second)Region", 156 ], 157 rustlibs: [ 158 "android.hardware.common.fmq-V1-rust", 159 "android.hardware.common-V2-rust", 160 ], 161 static_libs: [ 162 "libfmq", 163 ], 164 whole_static_libs: [ 165 "libfmq_erased", 166 ], 167 shared_libs: [ 168 "libc++", 169 "liblog", 170 "android.hardware.common.fmq-V1-ndk", 171 ], 172 apex_available: [ 173 ], 174} 175 176rust_test { 177 host_supported: true, 178 name: "libfmq_bindgen_test", 179 srcs: [":libfmq_bindgen"], 180 crate_name: "fmq_bindgen_test", 181 test_suites: ["general-tests"], 182 auto_gen_config: true, 183 clippy_lints: "none", 184 lints: "none", 185 rustlibs: [ 186 "android.hardware.common.fmq-V1-rust", 187 "android.hardware.common-V2-rust", 188 ], 189} 190 191rust_library { 192 name: "libfmq_rust", 193 host_supported: true, 194 vendor_available: true, 195 product_available: true, 196 visibility: [":__subpackages__"], 197 crate_name: "fmq", 198 srcs: ["libfmq.rs"], 199 edition: "2021", 200 rustlibs: [ 201 "libfmq_bindgen", 202 "liblog_rust", 203 "libzerocopy", 204 ], 205 proc_macros: [], 206} 207