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