• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// 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
15package {
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
24cc_library_headers {
25    name: "libbinder_headers_base",
26    export_include_dirs: ["include"],
27    vendor_available: true,
28    recovery_available: true,
29    host_supported: true,
30    native_bridge_supported: true,
31    cmake_snapshot_supported: true,
32
33    header_libs: [
34        "libbinder_headers_platform_shared",
35    ],
36    export_header_lib_headers: [
37        "libbinder_headers_platform_shared",
38    ],
39    apex_available: [
40        "//apex_available:platform",
41        "com.android.media",
42        "com.android.media.swcodec",
43    ],
44    min_sdk_version: "29",
45    target: {
46        darwin: {
47            enabled: false,
48        },
49    },
50    visibility: [
51        ":__subpackages__",
52    ],
53}
54
55cc_library_headers {
56    name: "libbinder_headers",
57    vendor_available: true,
58    recovery_available: true,
59    host_supported: true,
60    native_bridge_supported: true,
61
62    header_libs: [
63        "libbase_headers",
64        "libbinder_headers_base",
65        "libcutils_headers",
66        "libutils_headers",
67    ],
68    export_header_lib_headers: [
69        "libbase_headers",
70        "libbinder_headers_base",
71        "libcutils_headers",
72        "libutils_headers",
73    ],
74    apex_available: [
75        "//apex_available:platform",
76        "com.android.media",
77        "com.android.media.swcodec",
78    ],
79    min_sdk_version: "29",
80    target: {
81        darwin: {
82            enabled: false,
83        },
84    },
85}
86
87cc_cmake_snapshot {
88    name: "binder_sdk",
89    modules: [
90        "libbinder_sdk",
91        "libbinder_sdk_single_threaded",
92        "libbinder_ndk_sdk",
93        "binderRpcTestNoKernel",
94    ],
95    prebuilts: [
96        // to enable arm64 host support, build with musl - e.g. on aosp_cf_arm64_phone
97        "aidl",
98        "libc++",
99    ],
100    include_sources: true,
101    cflags: [
102        "-DNDEBUG",
103        "-DBINDER_ENABLE_LIBLOG_ASSERT",
104        "-DBINDER_DISABLE_NATIVE_HANDLE",
105        "-DBINDER_DISABLE_BLOB",
106        "-DBINDER_NO_LIBBASE",
107        "-DBINDER_NO_KERNEL_IPC_TESTING",
108
109        // from Soong's global.go commonGlobalCflags and noOverrideGlobalCflags
110        "-Wno-c99-designator",
111        "-Wno-missing-field-initializers",
112
113        // warnings that only pop up on gcc
114        "-Wno-unknown-pragmas", // "pragma clang"
115        "-Wno-attributes", // attributes on compound-statements
116        "-Wno-psabi", // reminders about old ABI changes
117    ],
118    cflags_ignored: [
119        // gcc requires all header constexprs to be used in all dependent compilatinon units
120        "-Wunused-const-variable",
121    ],
122    library_mapping: [
123        {
124            android_name: "libssl",
125            mapped_name: "ssl",
126            package_pregenerated: "external/boringssl",
127        },
128        {
129            android_name: "libcrypto",
130            mapped_name: "crypto",
131            package_pregenerated: "external/boringssl",
132        },
133        {
134            android_name: "libgtest",
135            mapped_name: "GTest::gtest",
136            package_system: "GTest",
137        },
138        {
139            android_name: "libgtest_main",
140            mapped_name: "GTest::gtest",
141            package_system: "GTest",
142        },
143
144        // use libbinder_sdk and friends instead of full Android's libbinder
145        {
146            android_name: "libbinder_rpc_no_kernel",
147            mapped_name: "android::libbinder_sdk",
148        },
149        {
150            android_name: "libbinder_rpc_single_threaded_no_kernel",
151            mapped_name: "android::libbinder_sdk_single_threaded",
152        },
153        {
154            android_name: "libbinder_headers",
155            mapped_name: "android::libbinder_headers_base",
156        },
157        {
158            android_name: "libbinder",
159            mapped_name: "android::libbinder_sdk",
160        },
161        {
162            android_name: "libbinder_ndk",
163            mapped_name: "android::libbinder_ndk_sdk",
164        },
165        {
166            android_name: "liblog",
167            mapped_name: "android::liblog_stub",
168        },
169
170        // explicitly included by Binder tests, but not needed outside of Android
171        {
172            android_name: "libbase",
173        },
174        {
175            android_name: "libcutils",
176        },
177        {
178            android_name: "libutils",
179        },
180
181        // disable tests that don't work outside of Android yet
182        {
183            android_name: "binder_rpc_test_service",
184        },
185        {
186            android_name: "binder_rpc_test_service_single_threaded",
187        },
188
189        // trusty mocks are artificially triggered and not needed outside of Android build
190        {
191            android_name: "libbinder_on_trusty_mock",
192        },
193        {
194            android_name: "libbinder_ndk_on_trusty_mock",
195        },
196        {
197            android_name: "binderRpcTestService_on_trusty_mock",
198        },
199        {
200            android_name: "binderRpcTest_on_trusty_mock",
201        },
202    ],
203}
204
205// These interfaces are android-specific implementation unrelated to binder
206// transport itself and should be moved to AIDL or in domain-specific libs.
207//
208// Currently, these are only on system android (not vendor, not host)
209// TODO(b/183654927) - move these into separate libraries
210
211filegroup {
212    name: "libbinder_device_interface_sources",
213    srcs: [
214        "IPermissionController.cpp",
215        "PermissionCache.cpp",
216        "PermissionController.cpp",
217    ],
218}
219
220cc_defaults {
221    name: "libbinder_common_defaults",
222    host_supported: true,
223
224    srcs: [
225        "Binder.cpp",
226        "BpBinder.cpp",
227        "Debug.cpp",
228        "FdTrigger.cpp",
229        "IInterface.cpp",
230        "IResultReceiver.cpp",
231        "Parcel.cpp",
232        "ParcelFileDescriptor.cpp",
233        "RecordedTransaction.cpp",
234        "RpcSession.cpp",
235        "RpcServer.cpp",
236        "RpcState.cpp",
237        "RpcTransportRaw.cpp",
238        "Stability.cpp",
239        "Status.cpp",
240        "TextOutput.cpp",
241        "Utils.cpp",
242        "file.cpp",
243    ],
244
245    header_libs: [
246        "libbinder_headers_base",
247    ],
248    export_header_lib_headers: [
249        "libbinder_headers_base",
250    ],
251
252    cflags: [
253        "-Wextra",
254        "-Wextra-semi",
255        "-Werror",
256        "-Wzero-as-null-pointer-constant",
257        "-Wreorder-init-list",
258        "-Wunused-const-variable",
259        "-DANDROID_BASE_UNIQUE_FD_DISABLE_IMPLICIT_CONVERSION",
260        "-DANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION",
261    ],
262}
263
264cc_defaults {
265    name: "libbinder_android_defaults",
266
267    // TODO(b/31559095): get headers from bionic on host
268    include_dirs: [
269        "bionic/libc/kernel/android/uapi/",
270        "bionic/libc/kernel/uapi/",
271    ],
272
273    srcs: [
274        "OS_android.cpp",
275        "OS_unix_base.cpp",
276    ],
277
278    target: {
279        host: {
280            srcs: [
281                "UtilsHost.cpp",
282            ],
283        },
284        android: {
285            lto: {
286                thin: true,
287            },
288        },
289    },
290
291    aidl: {
292        export_aidl_headers: true,
293    },
294
295    product_variables: {
296        debuggable: {
297            cflags: [
298                "-DBINDER_RPC_DEV_SERVERS",
299                "-DBINDER_ENABLE_RECORDING",
300            ],
301        },
302    },
303
304    shared_libs: [
305        "libcutils",
306        "liblog",
307        "libutils",
308    ],
309
310    static_libs: [
311        "libbase",
312    ],
313
314    header_libs: [
315        "jni_headers",
316        "libbinder_headers",
317    ],
318
319    export_header_lib_headers: [
320        "libbinder_headers",
321    ],
322
323    sanitize: {
324        misc_undefined: ["integer"],
325    },
326
327    tidy: true,
328    tidy_flags: [
329        // Only check our headers
330        "--header-filter=^.*frameworks/native/libs/binder/.*.h$",
331    ],
332    tidy_checks: [
333        "-performance-no-int-to-ptr",
334    ],
335    tidy_checks_as_errors: [
336        // Explicitly list the checks that should not occur in this module.
337        "abseil-*",
338        "android-*",
339        "bugprone-*",
340        "-bugprone-branch-clone", // b/155034972
341        "cert-*",
342        "clang-analyzer-*",
343        "google-*",
344        "misc-*",
345        "performance*",
346        "-performance-move-const-arg", // b/273486801
347        "portability*",
348    ],
349}
350
351cc_library_headers {
352    name: "trusty_mock_headers",
353    host_supported: true,
354    vendor_available: true,
355
356    export_include_dirs: [
357        "trusty/include",
358        "trusty/include_mock",
359    ],
360
361    visibility: [
362        ":__subpackages__",
363    ],
364}
365
366cc_defaults {
367    name: "trusty_mock_defaults",
368    host_supported: true,
369    vendor_available: true,
370
371    header_libs: [
372        "libbinder_headers_base",
373        "liblog_stub",
374        "trusty_mock_headers",
375    ],
376    export_header_lib_headers: [
377        "libbinder_headers_base",
378        "liblog_stub",
379        "trusty_mock_headers",
380    ],
381
382    shared_libs: [
383        "libutils_binder_sdk",
384    ],
385
386    cflags: [
387        "-DBINDER_RPC_SINGLE_THREADED",
388        "-DBINDER_ENABLE_LIBLOG_ASSERT",
389        "-DBINDER_DISABLE_NATIVE_HANDLE",
390        "-DBINDER_DISABLE_BLOB",
391        "-DBINDER_NO_LIBBASE",
392        // TODO: switch to "vendor: true" rather than copying this
393        // Trusty libbinder uses vendor stability for its binders
394        "-D__ANDROID_VENDOR__",
395        "-D__ANDROID_VNDK__",
396        "-U__ANDROID__",
397        "-D__TRUSTY__",
398        "-DTRUSTY_USERSPACE",
399        // Flags from the Trusty build system
400        "-Werror",
401        "-Wsign-compare",
402        "-Wno-unused-function",
403        "-Wno-unused-label",
404        "-fno-common",
405        "-fno-omit-frame-pointer",
406        "-fno-threadsafe-statics",
407    ],
408    rtti: false,
409
410    visibility: [
411        ":__subpackages__",
412    ],
413}
414
415cc_library_shared {
416    name: "libbinder_on_trusty_mock",
417    defaults: [
418        "libbinder_common_defaults",
419        "trusty_mock_defaults",
420    ],
421
422    srcs: [
423        // Trusty-specific files
424        "trusty/OS.cpp",
425        "trusty/RpcServerTrusty.cpp",
426        "trusty/RpcTransportTipcTrusty.cpp",
427        "trusty/TrustyStatus.cpp",
428        "trusty/socket.cpp",
429    ],
430}
431
432cc_defaults {
433    name: "libbinder_kernel_defaults",
434    srcs: [
435        "BufferedTextOutput.cpp",
436        "IPCThreadState.cpp",
437        "IServiceManager.cpp",
438        "ProcessState.cpp",
439        "Static.cpp",
440        ":libbinder_aidl",
441        ":libbinder_device_interface_sources",
442    ],
443    target: {
444        vendor: {
445            exclude_srcs: [
446                ":libbinder_device_interface_sources",
447            ],
448        },
449        host: {
450            srcs: [
451                "ServiceManagerHost.cpp",
452            ],
453        },
454        android: {
455            shared_libs: [
456                "libapexsupport",
457                "libvndksupport",
458            ],
459        },
460        recovery: {
461            exclude_shared_libs: [
462                "libapexsupport",
463                "libvndksupport",
464            ],
465        },
466        native_bridge: {
467            exclude_shared_libs: [
468                "libapexsupport",
469                "libvndksupport",
470            ],
471        },
472    },
473    cflags: [
474        "-DBINDER_WITH_KERNEL_IPC",
475    ],
476}
477
478cc_library {
479    name: "libbinder",
480    defaults: [
481        "libbinder_common_defaults",
482        "libbinder_android_defaults",
483        "libbinder_kernel_defaults",
484    ],
485
486    version_script: "libbinder.map",
487
488    // for vndbinder
489    vendor_available: true,
490    recovery_available: true,
491    double_loadable: true,
492    // TODO(b/153609531): remove when no longer needed.
493    native_bridge_supported: true,
494    cmake_snapshot_supported: false,
495
496    // libbinder does not offer a stable wire protocol.
497    // if a second copy of it is installed, then it may break after security
498    // or dessert updates. Instead, apex users should use libbinder_ndk.
499    apex_available: [
500        "//apex_available:platform",
501    ],
502
503    srcs: [
504        "IMemory.cpp",
505        "IShellCallback.cpp",
506        "LazyServiceRegistrar.cpp",
507        "MemoryBase.cpp",
508        "MemoryDealer.cpp",
509        "MemoryHeapBase.cpp",
510        "ParcelableHolder.cpp",
511        "PersistableBundle.cpp",
512    ],
513
514    target: {
515        android: {
516            // NOT static to keep the wire protocol unfrozen
517            static: {
518                enabled: false,
519            },
520        },
521        darwin: {
522            enabled: false,
523        },
524        recovery: {
525            exclude_header_libs: [
526                "jni_headers",
527            ],
528        },
529    },
530
531    afdo: true,
532}
533
534cc_defaults {
535    name: "binder_sdk_defaults",
536
537    cflags: [
538        "-DBINDER_ENABLE_LIBLOG_ASSERT",
539        "-DBINDER_DISABLE_NATIVE_HANDLE",
540        "-DBINDER_DISABLE_BLOB",
541        "-DBINDER_NO_LIBBASE",
542    ],
543
544    header_libs: [
545        "liblog_stub",
546    ],
547}
548
549cc_defaults {
550    name: "libbinder_sdk_defaults",
551
552    cmake_snapshot_supported: true,
553
554    defaults: [
555        "libbinder_common_defaults",
556        "binder_sdk_defaults",
557    ],
558
559    shared_libs: [
560        "libutils_binder_sdk",
561    ],
562
563    srcs: [
564        "OS_non_android_linux.cpp",
565        "OS_unix_base.cpp",
566    ],
567
568    visibility: [
569        ":__subpackages__",
570    ],
571
572    target: {
573        windows: {
574            enabled: false,
575        },
576    },
577}
578
579cc_library_host_shared {
580    name: "libbinder_sdk",
581    defaults: ["libbinder_sdk_defaults"],
582}
583
584cc_library_host_shared {
585    name: "libbinder_sdk_single_threaded",
586    defaults: ["libbinder_sdk_defaults"],
587    cflags: [
588        "-DBINDER_RPC_SINGLE_THREADED",
589    ],
590}
591
592cc_library {
593    name: "libbinder_rpc_no_kernel",
594    vendor_available: true,
595    defaults: [
596        "libbinder_common_defaults",
597        "libbinder_android_defaults",
598    ],
599    visibility: [
600        ":__subpackages__",
601    ],
602}
603
604cc_library {
605    name: "libbinder_rpc_no_blob",
606    vendor_available: true,
607    defaults: [
608        "libbinder_common_defaults",
609        "libbinder_android_defaults",
610        "libbinder_kernel_defaults",
611    ],
612    cflags: [
613        "-DBINDER_DISABLE_BLOB",
614    ],
615    visibility: [
616        ":__subpackages__",
617    ],
618}
619
620cc_library {
621    name: "libbinder_rpc_no_native_handle",
622    vendor_available: true,
623    defaults: [
624        "libbinder_common_defaults",
625        "libbinder_android_defaults",
626        "libbinder_kernel_defaults",
627    ],
628    cflags: [
629        "-DBINDER_DISABLE_NATIVE_HANDLE",
630    ],
631    visibility: [
632        ":__subpackages__",
633    ],
634}
635
636cc_library {
637    name: "libbinder_rpc_single_threaded",
638    defaults: [
639        "libbinder_common_defaults",
640        "libbinder_android_defaults",
641        "libbinder_kernel_defaults",
642    ],
643    cflags: [
644        "-DBINDER_RPC_SINGLE_THREADED",
645    ],
646    visibility: [
647        ":__subpackages__",
648    ],
649}
650
651cc_library {
652    name: "libbinder_rpc_single_threaded_no_kernel",
653    defaults: [
654        "libbinder_common_defaults",
655        "libbinder_android_defaults",
656    ],
657    cflags: [
658        "-DBINDER_RPC_SINGLE_THREADED",
659    ],
660    visibility: [
661        ":__subpackages__",
662    ],
663}
664
665cc_defaults {
666    name: "libbinder_tls_shared_deps",
667    shared_libs: [
668        "libbinder",
669        "libcrypto",
670        "liblog",
671        "libssl",
672        "libutils",
673    ],
674}
675
676cc_defaults {
677    name: "libbinder_tls_defaults",
678    defaults: ["libbinder_tls_shared_deps"],
679    vendor_available: true,
680    host_supported: true,
681    cmake_snapshot_supported: true,
682
683    header_libs: [
684        "libbinder_headers",
685    ],
686    export_header_lib_headers: [
687        "libbinder_headers",
688    ],
689    export_shared_lib_headers: [
690        "libssl",
691    ],
692    export_include_dirs: ["include_tls"],
693    static_libs: [
694        "libbase",
695    ],
696    srcs: [
697        "RpcTransportTls.cpp",
698        "RpcTlsUtils.cpp",
699    ],
700}
701
702cc_library_shared {
703    name: "libbinder_tls",
704    defaults: ["libbinder_tls_defaults"],
705}
706
707cc_library {
708    name: "libbinder_trusty",
709    vendor: true,
710    srcs: [
711        "RpcTransportTipcAndroid.cpp",
712        "RpcTrusty.cpp",
713    ],
714
715    shared_libs: [
716        "libbinder",
717        "liblog",
718        "libtrusty",
719        "libutils",
720    ],
721    static_libs: [
722        "libbase",
723    ],
724    export_include_dirs: ["include_trusty"],
725
726    // Most of Android doesn't need this library and shouldn't use it,
727    // so we restrict its visibility to the Trusty-specific packages.
728    visibility: [
729        ":__subpackages__",
730        "//system/core/trusty:__subpackages__",
731        "//vendor:__subpackages__",
732    ],
733}
734
735// For testing
736cc_library_static {
737    name: "libbinder_tls_static",
738    defaults: ["libbinder_tls_defaults"],
739    visibility: [
740        ":__subpackages__",
741    ],
742}
743
744// AIDL interface between libbinder and framework.jar
745filegroup {
746    name: "libbinder_aidl",
747    srcs: [
748        "aidl/android/os/ConnectionInfo.aidl",
749        "aidl/android/os/IClientCallback.aidl",
750        "aidl/android/os/IServiceCallback.aidl",
751        "aidl/android/os/IServiceManager.aidl",
752        "aidl/android/os/ServiceDebugInfo.aidl",
753    ],
754    path: "aidl",
755}
756
757aidl_interface {
758    name: "packagemanager_aidl",
759    unstable: true,
760    local_include_dir: "aidl",
761    host_supported: true,
762    srcs: [
763        "aidl/android/content/pm/IPackageManagerNative.aidl",
764        "aidl/android/content/pm/IStagedApexObserver.aidl",
765        "aidl/android/content/pm/ApexStagedEvent.aidl",
766        "aidl/android/content/pm/StagedApexInfo.aidl",
767    ],
768    backend: {
769        rust: {
770            apex_available: [
771                "com.android.virt",
772            ],
773            enabled: true,
774        },
775    },
776}
777
778aidl_interface {
779    name: "libbinder_aidl_test_stub",
780    unstable: true,
781    local_include_dir: "aidl",
782    srcs: [":libbinder_aidl"],
783    vendor_available: true,
784    backend: {
785        java: {
786            enabled: false,
787        },
788    },
789    visibility: [
790        ":__subpackages__",
791        "//system/tools/aidl:__subpackages__",
792    ],
793}
794
795// TODO(b/184872979): remove once the Rust API is created.
796cc_library {
797    name: "libbinder_rpc_unstable",
798    srcs: ["libbinder_rpc_unstable.cpp"],
799    shared_libs: [
800        "libbase",
801        "libbinder",
802        "libbinder_ndk",
803        "liblog",
804        "libutils",
805    ],
806    export_include_dirs: ["include_rpc_unstable"],
807
808    // enumerate stable entry points, for apex use
809    stubs: {
810        symbol_file: "libbinder_rpc_unstable.map.txt",
811    },
812
813    // This library is intentionally limited to these targets, and it will be removed later.
814    // Do not expand the visibility.
815    visibility: [
816        ":__subpackages__",
817        "//packages/modules/Virtualization:__subpackages__",
818        "//device/google/cuttlefish/shared/minidroid:__subpackages__",
819        "//system/software_defined_vehicle:__subpackages__",
820        "//visibility:any_system_partition",
821    ],
822}
823
824// libbinder historically contained additional interfaces that provided specific
825// functionality in the platform but have nothing to do with binder itself. These
826// are moved out of libbinder in order to avoid the overhead of their vtables.
827// If you are working on or own one of these interfaces, the responsible things
828// to would be:
829// - give them a new home
830// - convert them to AIDL instead of having manually written parceling code
831
832cc_library {
833    name: "libbatterystats_aidl",
834    host_supported: true,
835    srcs: [
836        "IBatteryStats.cpp",
837    ],
838    export_include_dirs: ["include_batterystats"],
839    shared_libs: [
840        "libbinder",
841        "libutils",
842    ],
843}
844
845cc_library {
846    name: "libprocessinfoservice_aidl",
847    host_supported: true,
848    srcs: [
849        "IProcessInfoService.cpp",
850        "ProcessInfoService.cpp",
851    ],
852    export_include_dirs: ["include_processinfo"],
853    shared_libs: [
854        "libbinder",
855        "libutils",
856        "liblog",
857    ],
858}
859
860cc_library {
861    name: "libactivitymanager_aidl",
862    srcs: [
863        "ActivityManager.cpp",
864        "IActivityManager.cpp",
865        "IUidObserver.cpp",
866        ":activity_manager_procstate_aidl",
867    ],
868    export_include_dirs: ["include_activitymanager"],
869    shared_libs: [
870        "libbinder",
871        "libutils",
872        "liblog",
873    ],
874    aidl: {
875        export_aidl_headers: true,
876    },
877}
878
879cc_binary {
880    name: "servicedispatcher",
881    host_supported: false,
882    srcs: [
883        "servicedispatcher.cpp",
884    ],
885    shared_libs: [
886        "libbase",
887        "libbinder",
888        "liblog",
889        "libutils",
890        "android.debug_aidl-cpp",
891    ],
892}
893