xref: /aosp_15_r20/frameworks/native/libs/binder/ndk/Android.bp (revision 38e8c45f13ce32b0dcecb25141ffecaf386fa17f)
1/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17// TODO(b/31559095): bionic on host should define this
18package {
19    default_applicable_licenses: ["frameworks_native_libs_binder_ndk_license"],
20}
21
22// Added automatically by a large-scale-change
23// See: http://go/android-license-faq
24license {
25    name: "frameworks_native_libs_binder_ndk_license",
26    visibility: [":__subpackages__"],
27    license_kinds: [
28        "SPDX-license-identifier-Apache-2.0",
29    ],
30    license_text: [
31        "NOTICE",
32    ],
33}
34
35cc_defaults {
36    name: "libbinder_ndk_common_defaults",
37    host_supported: true,
38    recovery_available: true,
39
40    export_include_dirs: [
41        "include_cpp",
42        "include_ndk",
43        "include_platform",
44    ],
45
46    cflags: [
47        "-Wall",
48        "-Wextra",
49        "-Wextra-semi",
50        "-Werror",
51    ],
52
53    srcs: [
54        "ibinder.cpp",
55        "libbinder.cpp",
56        "parcel.cpp",
57        "stability.cpp",
58        "status.cpp",
59    ],
60}
61
62cc_library_host_shared {
63    name: "libbinder_ndk_sdk",
64
65    defaults: [
66        "libbinder_ndk_common_defaults",
67        "binder_sdk_defaults",
68    ],
69    cmake_snapshot_supported: true,
70
71    shared_libs: [
72        "libbinder_sdk",
73        "libutils_binder_sdk",
74    ],
75}
76
77cc_library {
78    name: "libbinder_ndk",
79
80    defaults: ["libbinder_ndk_common_defaults"],
81    cmake_snapshot_supported: false,
82
83    llndk: {
84        symbol_file: "libbinder_ndk.map.txt",
85    },
86
87    cflags: [
88        "-DBINDER_WITH_KERNEL_IPC",
89    ],
90
91    srcs: [
92        "ibinder_jni.cpp",
93        "parcel_jni.cpp",
94        "persistable_bundle.cpp",
95        "process.cpp",
96        "service_manager.cpp",
97        "binder_rpc.cpp",
98    ],
99
100    static_libs: [
101        "libandroid_runtime_lazy",
102        "libbase",
103    ],
104
105    shared_libs: [
106        "libbinder",
107        "liblog",
108        "libutils",
109    ],
110
111    header_libs: [
112        "jni_headers",
113    ],
114    export_header_lib_headers: [
115        "jni_headers",
116    ],
117
118    target: {
119        android: {
120            // Only one copy of this library on an Android device
121            static: {
122                enabled: false,
123            },
124        },
125        linux: {
126            version_script: "libbinder_ndk.map.txt",
127        },
128        darwin: {
129            enabled: false,
130        },
131    },
132    stubs: {
133        symbol_file: "libbinder_ndk.map.txt",
134        versions: [
135            "29",
136            "30",
137        ],
138    },
139    sanitize: {
140        misc_undefined: ["integer"],
141    },
142    tidy: true,
143    tidy_flags: [
144        // Only check our headers
145        "--header-filter=^.*frameworks/native/libs/binder/.*.h$",
146    ],
147    tidy_checks_as_errors: [
148        // Explicitly list the checks that should not occur in this module.
149        "abseil-*",
150        "android-*",
151        "bugprone-*",
152        "-bugprone-branch-clone", // b/155034972
153        "cert-*",
154        "clang-analyzer-*",
155        "-clang-analyzer-core.CallAndMessage",
156        "-clang-analyzer-core.uninitialized.Assign",
157        "-clang-analyzer-unix.Malloc",
158        "-clang-analyzer-deadcode.DeadStores",
159        "-clang-analyzer-optin.cplusplus.UninitializedObject",
160        "google-*",
161        "-google-readability-*",
162        "-google-runtime-references",
163        "misc-*",
164        "-misc-no-recursion",
165        "-misc-non-private-member-variables-in-classes",
166        "-misc-redundant-expression",
167        "-misc-unused-parameters",
168        "-misc-unused-using-decls",
169        "performance*",
170        "portability*",
171    ],
172    afdo: true,
173}
174
175cc_library {
176    name: "libbinder_ndk_on_trusty_mock",
177    defaults: [
178        "trusty_mock_defaults",
179    ],
180
181    export_include_dirs: [
182        "include_cpp",
183        "include_ndk",
184        "include_platform",
185    ],
186
187    srcs: [
188        "ibinder.cpp",
189        "libbinder.cpp",
190        "parcel.cpp",
191        "stability.cpp",
192        "status.cpp",
193    ],
194
195    shared_libs: [
196        "libbinder_on_trusty_mock",
197    ],
198
199    header_libs: [
200        "libbinder_trusty_ndk_headers",
201    ],
202    export_header_lib_headers: [
203        "libbinder_trusty_ndk_headers",
204    ],
205
206    cflags: [
207        "-Wall",
208        "-Wextra",
209        "-Werror",
210    ],
211
212    visibility: ["//frameworks/native/libs/binder:__subpackages__"],
213}
214
215cc_library_headers {
216    name: "libbinder_headers_platform_shared",
217    export_include_dirs: ["include_cpp"],
218    vendor_available: true,
219    recovery_available: true,
220    host_supported: true,
221    // TODO(b/153609531): remove when no longer needed.
222    native_bridge_supported: true,
223    cmake_snapshot_supported: true,
224    target: {
225        darwin: {
226            enabled: false,
227        },
228    },
229    apex_available: [
230        "//apex_available:platform",
231        "//apex_available:anyapex",
232        "com.android.media",
233        "com.android.media.swcodec",
234    ],
235    min_sdk_version: "29",
236}
237
238// TODO: if you try to export libbinder_headers_platform_shared from libbinder_ndk.ndk, it will
239// not select the NDK variant of libbinder_headers_platform_shared and instead, it will error
240// that the NDK can't depend on glibc C++.
241cc_library_headers {
242    name: "libbinder_headers_platform_shared_ndk",
243    export_include_dirs: ["include_cpp"],
244    sdk_version: "29",
245    min_sdk_version: "29",
246    visibility: [":__subpackages__"],
247}
248
249ndk_headers {
250    name: "libbinder_ndk_headers",
251    from: "include_ndk/android",
252    to: "android",
253    srcs: [
254        "include_ndk/android/*.h",
255    ],
256    license: "NOTICE",
257}
258
259// include_cpp are packaged in development/build/sdk.atree with the AIDL compiler
260
261ndk_library {
262    name: "libbinder_ndk",
263    symbol_file: "libbinder_ndk.map.txt",
264    first_version: "29",
265    export_header_libs: [
266        // used to be part of the NDK, platform things depend on it
267        "libbinder_headers_platform_shared_ndk",
268    ],
269}
270