blob: 20bf30122d80ec26273d1f1bb158f27b5fef79ae [file] [log] [blame]
Dan Willemsene05dc6d2016-07-25 17:13:45 -07001// Copyright (C) 2009 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
Bob Badour3c538232021-02-12 21:26:48 -080015package {
16 // See: http://go/android-license-faq
17 // A large-scale-change added 'default_applicable_licenses' to import
18 // all of the 'license_kinds' from "frameworks_native_license"
19 // to get the below license kinds:
20 // SPDX-license-identifier-Apache-2.0
21 default_applicable_licenses: ["frameworks_native_license"],
22}
23
Vijay Venkatraman5583be72017-03-24 16:13:58 -070024cc_library_headers {
25 name: "libbinder_headers",
26 export_include_dirs: ["include"],
Jiyong Park172bd722017-06-21 12:14:18 +090027 vendor_available: true,
Steven Moreland28723ae2019-04-01 18:52:30 -070028 host_supported: true,
Victor Khimenko38786ab2020-07-03 00:06:50 +020029 // TODO(b/153609531): remove when no longer needed.
30 native_bridge_supported: true,
Steven Moreland28723ae2019-04-01 18:52:30 -070031
Jiyong Parkb7df6cb2017-04-13 21:19:48 -070032 header_libs: [
33 "libbase_headers",
Jooyung Hancaede592021-02-04 10:18:37 +090034 "libbinder_headers_platform_shared",
Jiyong Parkb7df6cb2017-04-13 21:19:48 -070035 "libcutils_headers",
36 "libutils_headers",
37 ],
38 export_header_lib_headers: [
39 "libbase_headers",
Jooyung Hancaede592021-02-04 10:18:37 +090040 "libbinder_headers_platform_shared",
Jiyong Parkb7df6cb2017-04-13 21:19:48 -070041 "libcutils_headers",
42 "libutils_headers",
43 ],
Jooyung Han5f6a89a2021-02-05 15:28:58 +090044 apex_available: [
45 "//apex_available:platform",
46 "com.android.media",
47 "com.android.media.swcodec",
48 ],
Jooyung Hana395c8d2020-04-16 18:48:32 +090049 min_sdk_version: "29",
Yifan Hongf856a982020-10-30 14:51:17 -070050 target: {
51 darwin: {
52 enabled: false,
53 },
54 },
Vijay Venkatraman5583be72017-03-24 16:13:58 -070055}
56
Steven Moreland28723ae2019-04-01 18:52:30 -070057// These interfaces are android-specific implementation unrelated to binder
58// transport itself and should be moved to AIDL or in domain-specific libs.
59//
60// Currently, these are only on system android (not vendor, not host)
Steven Morelandea6bfab2021-04-01 00:10:31 +000061// TODO(b/183654927) - move these into separate libraries
Steven Moreland28723ae2019-04-01 18:52:30 -070062libbinder_device_interface_sources = [
Steven Moreland28723ae2019-04-01 18:52:30 -070063 "IPermissionController.cpp",
Steven Moreland28723ae2019-04-01 18:52:30 -070064 "PermissionCache.cpp",
65 "PermissionController.cpp",
Steven Moreland28723ae2019-04-01 18:52:30 -070066]
Steven Morelandd8310092021-05-14 03:37:35 +000067libbinder_no_vendor_interface_sources = [
68 ":packagemanager_aidl",
69]
Steven Moreland28723ae2019-04-01 18:52:30 -070070
Steven Moreland899ab372019-09-24 15:16:21 -070071cc_library {
Dan Willemsene05dc6d2016-07-25 17:13:45 -070072 name: "libbinder",
73
Yi Kong0bae3072021-05-31 23:22:23 +080074 version_script: "libbinder.map",
75
Steven Moreland3aa76162017-04-13 21:19:48 -070076 // for vndbinder
77 vendor_available: true,
Justin Yunb367ff42017-08-02 17:02:05 +090078 vndk: {
79 enabled: true,
80 },
Jiyong Parkfe0a8242018-04-09 12:16:30 +090081 double_loadable: true,
Steven Moreland28723ae2019-04-01 18:52:30 -070082 host_supported: true,
Victor Khimenko38786ab2020-07-03 00:06:50 +020083 // TODO(b/153609531): remove when no longer needed.
84 native_bridge_supported: true,
Steven Moreland28723ae2019-04-01 18:52:30 -070085
86 // TODO(b/31559095): get headers from bionic on host
87 include_dirs: [
88 "bionic/libc/kernel/android/uapi/",
89 "bionic/libc/kernel/uapi/",
90 ],
Steven Moreland636d7d52019-08-26 10:42:38 -070091
92 // libbinder does not offer a stable wire protocol.
93 // if a second copy of it is installed, then it may break after security
94 // or dessert updates. Instead, apex users should use libbinder_ndk.
Jiyong Parkdd52ad32019-09-30 19:25:16 +090095 apex_available: [
96 "//apex_available:platform",
Jiyong Parkdd52ad32019-09-30 19:25:16 +090097 ],
Steven Moreland3aa76162017-04-13 21:19:48 -070098
Dan Willemsene05dc6d2016-07-25 17:13:45 -070099 srcs: [
Dan Willemsene05dc6d2016-07-25 17:13:45 -0700100 "Binder.cpp",
101 "BpBinder.cpp",
102 "BufferedTextOutput.cpp",
103 "Debug.cpp",
Yifan Hong8c950422021-08-05 17:13:55 -0700104 "FdTrigger.cpp",
Dan Willemsene05dc6d2016-07-25 17:13:45 -0700105 "IInterface.cpp",
Dan Willemsene05dc6d2016-07-25 17:13:45 -0700106 "IMemory.cpp",
107 "IPCThreadState.cpp",
Dan Willemsene05dc6d2016-07-25 17:13:45 -0700108 "IResultReceiver.cpp",
109 "IServiceManager.cpp",
Dianne Hackborn1941a402016-08-29 12:30:43 -0700110 "IShellCallback.cpp",
Jon Spivack9f503a42019-10-22 16:49:19 -0700111 "LazyServiceRegistrar.cpp",
Dan Willemsene05dc6d2016-07-25 17:13:45 -0700112 "MemoryBase.cpp",
113 "MemoryDealer.cpp",
114 "MemoryHeapBase.cpp",
115 "Parcel.cpp",
Jeongik Cha8cb23452020-08-26 23:38:03 +0900116 "ParcelableHolder.cpp",
Ryo Hashimotobf551892018-05-31 16:58:35 +0900117 "ParcelFileDescriptor.cpp",
Dan Willemsene05dc6d2016-07-25 17:13:45 -0700118 "PersistableBundle.cpp",
Dan Willemsene05dc6d2016-07-25 17:13:45 -0700119 "ProcessState.cpp",
Steven Moreland5553ac42020-11-11 02:14:45 +0000120 "RpcAddress.cpp",
Steven Morelandbdb53ab2021-05-05 17:57:41 +0000121 "RpcSession.cpp",
Steven Moreland5553ac42020-11-11 02:14:45 +0000122 "RpcServer.cpp",
123 "RpcState.cpp",
Yifan Hongf6b4d5c2021-06-23 19:12:32 -0700124 "RpcTransportRaw.cpp",
Dan Willemsene05dc6d2016-07-25 17:13:45 -0700125 "Static.cpp",
Steven Morelanda86a3562019-08-01 23:28:34 +0000126 "Stability.cpp",
Dan Willemsene05dc6d2016-07-25 17:13:45 -0700127 "Status.cpp",
128 "TextOutput.cpp",
Steven Morelandf183fdd2020-10-27 00:12:12 +0000129 "Utils.cpp",
Colin Cross21c210e2017-11-14 13:05:37 -0800130 ":libbinder_aidl",
Steven Morelandd8310092021-05-14 03:37:35 +0000131 ] + libbinder_no_vendor_interface_sources,
Dan Willemsene05dc6d2016-07-25 17:13:45 -0700132
Jiyong Park47f876b2018-04-17 13:56:46 +0900133 target: {
Steven Moreland28723ae2019-04-01 18:52:30 -0700134 android: {
135 srcs: libbinder_device_interface_sources,
Steven Moreland899ab372019-09-24 15:16:21 -0700136
137 // NOT static to keep the wire protocol unfrozen
138 static: {
139 enabled: false,
140 },
Steven Moreland28723ae2019-04-01 18:52:30 -0700141 },
Jiyong Park47f876b2018-04-17 13:56:46 +0900142 vendor: {
Steven Morelandd8310092021-05-14 03:37:35 +0000143 exclude_srcs: libbinder_device_interface_sources + libbinder_no_vendor_interface_sources,
Jiyong Park47f876b2018-04-17 13:56:46 +0900144 },
Yifan Hongf856a982020-10-30 14:51:17 -0700145 darwin: {
146 enabled: false,
147 },
Yifan Hongaf766e62021-06-14 13:24:19 -0700148 host: {
Yifan Hongaf766e62021-06-14 13:24:19 -0700149 srcs: [
Yifan Hongf7760012021-06-04 16:04:42 -0700150 "ServiceManagerHost.cpp",
Yifan Hongaf766e62021-06-14 13:24:19 -0700151 "UtilsHost.cpp",
152 ],
153 },
Jiyong Park47f876b2018-04-17 13:56:46 +0900154 },
155
Todd Kennedy757186e2017-08-02 07:49:20 -0700156 aidl: {
157 export_aidl_headers: true,
158 },
159
Steven Moreland2f2c4e02020-07-28 18:11:21 +0000160 // TODO(b/142684679): for com.android.media which is compiled
161 // as vendor and used as system code.
162 use_apex_name_macro: true,
163
Dan Willemsene05dc6d2016-07-25 17:13:45 -0700164 cflags: [
165 "-Wall",
166 "-Wextra",
Jooyung Hanc91e3cb2020-11-25 06:38:17 +0900167 "-Wextra-semi",
Dan Willemsene05dc6d2016-07-25 17:13:45 -0700168 "-Werror",
Yi Kongc2376e42018-07-10 15:12:36 -0700169 "-Wzero-as-null-pointer-constant",
Steven Moreland74cf6132020-11-14 00:09:44 +0000170 "-DANDROID_BASE_UNIQUE_FD_DISABLE_IMPLICIT_CONVERSION",
Steven Moreland1a3a8ef2021-04-02 02:52:46 +0000171 "-DANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION",
Dan Willemsene05dc6d2016-07-25 17:13:45 -0700172 ],
173 product_variables: {
174 binder32bit: {
175 cflags: ["-DBINDER_IPC_32BIT=1"],
176 },
Yifan Hong84bedeb2021-04-21 21:37:17 -0700177
178 debuggable: {
179 cflags: ["-DBINDER_RPC_DEV_SERVERS"],
180 },
Dan Willemsene05dc6d2016-07-25 17:13:45 -0700181 },
182
183 shared_libs: [
Dan Willemsene05dc6d2016-07-25 17:13:45 -0700184 "liblog",
185 "libcutils",
186 "libutils",
Dan Willemsene05dc6d2016-07-25 17:13:45 -0700187 ],
Jiyong Park42842052017-06-20 13:51:22 +0900188
Steven Moreland62129012021-07-29 12:14:44 -0700189 static_libs: [
190 "libbase",
191 ],
192
Jiyong Park42842052017-06-20 13:51:22 +0900193 header_libs: [
194 "libbinder_headers",
Yifan Hong194acf22021-06-29 18:44:56 -0700195 "libandroid_runtime_vm_headers",
Jiyong Park42842052017-06-20 13:51:22 +0900196 ],
197
Jiyong Park42842052017-06-20 13:51:22 +0900198 export_header_lib_headers: [
199 "libbinder_headers",
Dan Stozad630e522016-12-01 15:16:31 -0800200 ],
201
Dan Willemsene05dc6d2016-07-25 17:13:45 -0700202 clang: true,
203 sanitize: {
204 misc_undefined: ["integer"],
205 },
Jooyung Hana395c8d2020-04-16 18:48:32 +0900206 min_sdk_version: "29",
Jiyong Park25265082020-11-13 16:58:57 +0900207
208 tidy: true,
209 tidy_flags: [
210 // Only check our headers
211 "--header-filter=^.*frameworks/native/libs/binder/.*.h$",
212 ],
Steven Moreland525dd902021-04-22 23:00:04 +0000213 tidy_checks: [
214 "-performance-no-int-to-ptr",
215 ],
Jiyong Park25265082020-11-13 16:58:57 +0900216 tidy_checks_as_errors: [
Chih-Hung Hsieh09d11b32021-01-11 21:29:01 -0800217 // Explicitly list the checks that should not occur in this module.
218 "abseil-*",
219 "android-*",
220 "bugprone-*",
221 "cert-*",
222 "clang-analyzer-*",
Chih-Hung Hsieh09d11b32021-01-11 21:29:01 -0800223 "google-*",
Chih-Hung Hsieh09d11b32021-01-11 21:29:01 -0800224 "misc-*",
Chih-Hung Hsieh09d11b32021-01-11 21:29:01 -0800225 "performance*",
226 "portability*",
Jiyong Park25265082020-11-13 16:58:57 +0900227 ],
Yi Kong054f2fa2021-03-05 01:50:23 +0800228
229 pgo: {
230 sampling: true,
231 profile_file: "libbinder/libbinder.profdata",
232 },
Dan Willemsene05dc6d2016-07-25 17:13:45 -0700233}
234
Yifan Honge8212f22021-06-28 15:49:08 -0700235cc_defaults {
236 name: "libbinder_tls_shared_deps",
237 shared_libs: [
238 "libbinder",
239 "libcrypto",
240 "liblog",
241 "libssl",
242 "libutils",
243 ],
244}
245
246cc_defaults {
247 name: "libbinder_tls_defaults",
248 defaults: ["libbinder_tls_shared_deps"],
249 host_supported: true,
250
251 header_libs: [
252 "libbinder_headers",
253 ],
254 export_header_lib_headers: [
255 "libbinder_headers",
256 ],
257 export_include_dirs: ["include_tls"],
258 static_libs: [
259 "libbase",
260 ],
261 srcs: [
262 "RpcTransportTls.cpp",
263 ],
264}
265
266cc_library_shared {
267 name: "libbinder_tls",
268 defaults: ["libbinder_tls_defaults"],
269}
270
Colin Cross21c210e2017-11-14 13:05:37 -0800271// AIDL interface between libbinder and framework.jar
272filegroup {
273 name: "libbinder_aidl",
274 srcs: [
Jon Spivack9f503a42019-10-22 16:49:19 -0700275 "aidl/android/os/IClientCallback.aidl",
Steven Moreland27cfab02019-08-12 14:34:16 -0700276 "aidl/android/os/IServiceCallback.aidl",
Steven Moreland80e1e6d2019-06-21 12:35:59 -0700277 "aidl/android/os/IServiceManager.aidl",
Steven Moreland3ea43272021-01-28 22:49:28 +0000278 "aidl/android/os/ServiceDebugInfo.aidl",
Colin Cross21c210e2017-11-14 13:05:37 -0800279 ],
Dan Willemsena5d65222018-09-14 21:27:01 -0700280 path: "aidl",
Colin Cross21c210e2017-11-14 13:05:37 -0800281}
Steven Moreland82c97cf2019-10-16 16:29:27 -0700282
Steven Morelandf9514192021-03-26 01:34:55 +0000283filegroup {
284 name: "packagemanager_aidl",
285 srcs: [
286 "aidl/android/content/pm/IPackageChangeObserver.aidl",
287 "aidl/android/content/pm/IPackageManagerNative.aidl",
288 "aidl/android/content/pm/PackageChangeEvent.aidl",
Samiul Islam643744f2021-08-04 15:56:52 +0100289 "aidl/android/content/pm/IStagedApexObserver.aidl",
290 "aidl/android/content/pm/ApexStagedEvent.aidl",
291 "aidl/android/content/pm/StagedApexInfo.aidl",
Steven Morelandf9514192021-03-26 01:34:55 +0000292 ],
293 path: "aidl",
294}
295
Steven Moreland82c97cf2019-10-16 16:29:27 -0700296aidl_interface {
297 name: "libbinder_aidl_test_stub",
Jiyong Park701fa1a2020-04-13 12:55:44 +0900298 unstable: true,
Steven Moreland82c97cf2019-10-16 16:29:27 -0700299 local_include_dir: "aidl",
300 srcs: [":libbinder_aidl"],
Steven Moreland82c97cf2019-10-16 16:29:27 -0700301 vendor_available: true,
302 backend: {
303 java: {
304 enabled: false,
305 },
306 },
307}
Steven Morelandea6bfab2021-04-01 00:10:31 +0000308
Victor Hsiehd35d31d2021-06-03 11:24:31 -0700309// TODO(b/184872979): remove once the Rust API is created.
310cc_library {
311 name: "libbinder_rpc_unstable",
312 srcs: ["libbinder_rpc_unstable.cpp"],
313 defaults: ["libbinder_ndk_host_user"],
314 shared_libs: [
315 "libbase",
316 "libbinder",
317 "libbinder_ndk",
318 "libutils",
319 ],
320
321 // enumerate stable entry points, for apex use
322 stubs: {
323 symbol_file: "libbinder_rpc_unstable.map.txt",
324 },
325
326 // This library is intentionally limited to these targets, and it will be removed later.
327 // Do not expand the visibility.
328 visibility: [
329 "//packages/modules/Virtualization/authfs:__subpackages__",
Alan Stokes564d0592021-07-16 11:28:49 +0100330 "//packages/modules/Virtualization/compos:__subpackages__",
Victor Hsiehd35d31d2021-06-03 11:24:31 -0700331 "//packages/modules/Virtualization/microdroid",
332 ],
333}
334
Steven Morelandea6bfab2021-04-01 00:10:31 +0000335// libbinder historically contained additional interfaces that provided specific
336// functionality in the platform but have nothing to do with binder itself. These
337// are moved out of libbinder in order to avoid the overhead of their vtables.
338// If you are working on or own one of these interfaces, the responsible things
339// to would be:
340// - give them a new home
341// - convert them to AIDL instead of having manually written parceling code
342
343cc_library {
344 name: "libbatterystats_aidl",
345 srcs: [
346 "IBatteryStats.cpp",
347 ],
348 export_include_dirs: ["include_batterystats"],
349 shared_libs: [
350 "libbinder",
351 "libutils",
352 ],
353}
Steven Moreland45e25cb2021-04-02 04:30:41 +0000354
355cc_library {
356 name: "libprocessinfoservice_aidl",
357 srcs: [
358 "IProcessInfoService.cpp",
359 "ProcessInfoService.cpp",
360 ],
361 export_include_dirs: ["include_processinfo"],
362 shared_libs: [
363 "libbinder",
364 "libutils",
365 "liblog",
366 ],
367}
Steven Moreland8a2085c2021-04-05 22:01:48 +0000368
Steven Moreland8a2085c2021-04-05 22:01:48 +0000369cc_library {
370 name: "libactivitymanager_aidl",
Steven Moreland710ad482021-04-05 23:17:21 +0000371 srcs: [
372 "ActivityManager.cpp",
373 "IActivityManager.cpp",
374 "IUidObserver.cpp",
375 ":activity_manager_procstate_aidl",
376 ],
377 export_include_dirs: ["include_activitymanager"],
Steven Moreland8a2085c2021-04-05 22:01:48 +0000378 shared_libs: [
379 "libbinder",
380 "libutils",
381 "liblog",
382 ],
Steven Moreland710ad482021-04-05 23:17:21 +0000383 aidl: {
384 export_aidl_headers: true,
385 },
Steven Moreland8a2085c2021-04-05 22:01:48 +0000386}
Yifan Hongdbf58d42021-06-03 19:21:11 -0700387
388cc_binary {
389 name: "servicedispatcher",
390 host_supported: false,
391 srcs: [
392 "servicedispatcher.cpp",
393 ],
394 shared_libs: [
395 "libbase",
396 "libbinder",
397 "liblog",
398 "libutils",
Yifan Honga5b02692021-07-22 20:06:48 -0700399 "android.debug_aidl-cpp",
Yifan Hongdbf58d42021-06-03 19:21:11 -0700400 ],
401}