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        export_llndk_headers: ["libvendorsupport_llndk_headers"],
86    },
87
88    cflags: [
89        "-DBINDER_WITH_KERNEL_IPC",
90    ],
91
92    srcs: [
93        "ibinder_jni.cpp",
94        "parcel_jni.cpp",
95        "persistable_bundle.cpp",
96        "process.cpp",
97        "service_manager.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        "libvendorsupport_llndk_headers",
113        "jni_headers",
114    ],
115    export_header_lib_headers: [
116        "libvendorsupport_llndk_headers",
117        "jni_headers",
118    ],
119
120    target: {
121        android: {
122            // Only one copy of this library on an Android device
123            static: {
124                enabled: false,
125            },
126        },
127        linux: {
128            version_script: "libbinder_ndk.map.txt",
129        },
130        darwin: {
131            enabled: false,
132        },
133    },
134    stubs: {
135        symbol_file: "libbinder_ndk.map.txt",
136        versions: [
137            "29",
138            "30",
139        ],
140    },
141    sanitize: {
142        misc_undefined: ["integer"],
143    },
144    tidy: true,
145    tidy_flags: [
146        // Only check our headers
147        "--header-filter=^.*frameworks/native/libs/binder/.*.h$",
148    ],
149    tidy_checks_as_errors: [
150        // Explicitly list the checks that should not occur in this module.
151        "abseil-*",
152        "android-*",
153        "bugprone-*",
154        "-bugprone-branch-clone", // b/155034972
155        "cert-*",
156        "clang-analyzer-*",
157        "-clang-analyzer-core.CallAndMessage",
158        "-clang-analyzer-core.uninitialized.Assign",
159        "-clang-analyzer-unix.Malloc",
160        "-clang-analyzer-deadcode.DeadStores",
161        "-clang-analyzer-optin.cplusplus.UninitializedObject",
162        "google-*",
163        "-google-readability-*",
164        "-google-runtime-references",
165        "misc-*",
166        "-misc-no-recursion",
167        "-misc-non-private-member-variables-in-classes",
168        "-misc-redundant-expression",
169        "-misc-unused-parameters",
170        "-misc-unused-using-decls",
171        "performance*",
172        "portability*",
173    ],
174    afdo: true,
175}
176
177cc_library {
178    name: "libbinder_ndk_on_trusty_mock",
179    defaults: [
180        "trusty_mock_defaults",
181    ],
182
183    export_include_dirs: [
184        "include_cpp",
185        "include_ndk",
186        "include_platform",
187    ],
188
189    srcs: [
190        "ibinder.cpp",
191        "libbinder.cpp",
192        "parcel.cpp",
193        "stability.cpp",
194        "status.cpp",
195    ],
196
197    shared_libs: [
198        "libbinder_on_trusty_mock",
199    ],
200
201    header_libs: [
202        "libbinder_trusty_ndk_headers",
203    ],
204    export_header_lib_headers: [
205        "libbinder_trusty_ndk_headers",
206    ],
207
208    cflags: [
209        "-Wall",
210        "-Wextra",
211        "-Werror",
212    ],
213
214    visibility: ["//frameworks/native/libs/binder:__subpackages__"],
215}
216
217cc_library_headers {
218    name: "libbinder_headers_platform_shared",
219    export_include_dirs: ["include_cpp"],
220    vendor_available: true,
221    recovery_available: true,
222    host_supported: true,
223    // TODO(b/153609531): remove when no longer needed.
224    native_bridge_supported: true,
225    cmake_snapshot_supported: true,
226    target: {
227        darwin: {
228            enabled: false,
229        },
230    },
231    apex_available: [
232        "//apex_available:platform",
233        "com.android.media",
234        "com.android.media.swcodec",
235    ],
236    min_sdk_version: "29",
237}
238
239ndk_headers {
240    name: "libbinder_ndk_headers",
241    from: "include_ndk/android",
242    to: "android",
243    srcs: [
244        "include_ndk/android/*.h",
245    ],
246    license: "NOTICE",
247}
248
249// TODO(b/160624671): package with the aidl compiler
250ndk_headers {
251    name: "libbinder_ndk_helper_headers",
252    from: "include_cpp/android",
253    to: "android",
254    srcs: [
255        "include_cpp/android/*.h",
256    ],
257    license: "NOTICE",
258}
259
260ndk_library {
261    name: "libbinder_ndk",
262    symbol_file: "libbinder_ndk.map.txt",
263    first_version: "29",
264    export_header_libs: [
265        "libbinder_ndk_headers",
266        "libbinder_ndk_helper_headers",
267    ],
268}
269