xref: /aosp_15_r20/frameworks/base/cmds/idmap2/Android.bp (revision d57664e9bc4670b3ecf6748a746a57c557b6bc9e)
1// Copyright (C) 2018 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_base_license"
19    // to get the below license kinds:
20    //   SPDX-license-identifier-Apache-2.0
21    default_applicable_licenses: ["frameworks_base_license"],
22}
23
24cc_defaults {
25    name: "idmap2_defaults",
26    cpp_std: "gnu++2b",
27    tidy: true,
28    tidy_checks: [
29        "modernize-*",
30        "-modernize-avoid-c-arrays",
31        "-modernize-use-nodiscard",
32        "-modernize-use-trailing-return-type",
33        "android-*",
34        "misc-*",
35        "-misc-const-correctness",
36        "readability-*",
37        "-readability-identifier-length",
38        "-readability-implicit-bool-conversion",
39    ],
40    tidy_checks_as_errors: [
41        "modernize-*",
42        "-modernize-avoid-c-arrays",
43        "-modernize-concat-nested-namespaces",
44        "-modernize-pass-by-value",
45        "-modernize-replace-disallow-copy-and-assign-macro",
46        "-modernize-return-braced-init-list",
47        "-modernize-use-default-member-init",
48        "-modernize-use-equals-default",
49        "-modernize-use-emplace",
50        "-modernize-use-nodiscard",
51        "-modernize-use-override",
52        "-modernize-use-trailing-return-type",
53        "-modernize-use-using",
54        "android-*",
55        "misc-*",
56        "-misc-non-private-member-variables-in-classes",
57        "readability-*",
58        "-readability-braces-around-statements",
59        "-readability-const-return-type",
60        "-readability-convert-member-functions-to-static",
61        "-readability-duplicate-include",
62        "-readability-implicit-bool-conversion",
63        "-readability-else-after-return",
64        "-readability-named-parameter",
65        "-readability-redundant-access-specifiers",
66        "-readability-uppercase-literal-suffix",
67    ],
68}
69
70cc_library {
71    name: "libidmap2",
72    defaults: [
73        "idmap2_defaults",
74    ],
75    host_supported: true,
76    srcs: [
77        "libidmap2/**/*.cpp",
78        "self_targeting/*.cpp",
79    ],
80    export_include_dirs: ["include"],
81    target: {
82        android: {
83            static: {
84                enabled: false,
85            },
86            static_libs: [
87                "libidmap2_policies",
88                "libidmap2_protos",
89                "libpng",
90            ],
91            shared_libs: [
92                "libandroidfw",
93                "libbase",
94                "libcutils",
95                "libprotobuf-cpp-lite",
96                "libutils",
97                "libz",
98                "libziparchive",
99            ],
100        },
101        host: {
102            shared: {
103                enabled: false,
104            },
105            static_libs: [
106                "libandroidfw",
107                "libbase",
108                "libcutils",
109                "libidmap2_policies",
110                "libidmap2_protos",
111                "libpng",
112                "libprotobuf-cpp-lite",
113                "libutils",
114                "libz",
115                "libziparchive",
116            ],
117        },
118    },
119}
120
121cc_library {
122    name: "libidmap2_protos",
123    srcs: [
124        "libidmap2/proto/*.proto",
125    ],
126    host_supported: true,
127    tidy: false,
128    proto: {
129        type: "lite",
130        export_proto_headers: true,
131    },
132}
133
134cc_library_static {
135    name: "libidmap2_policies",
136    defaults: [
137        "idmap2_defaults",
138    ],
139    host_supported: true,
140    export_include_dirs: ["libidmap2_policies/include"],
141    target: {
142        windows: {
143            enabled: true,
144        },
145        android: {
146            shared_libs: [
147                "libandroidfw",
148            ],
149        },
150        host: {
151            static_libs: [
152                "libandroidfw",
153            ],
154        },
155    },
156}
157
158cc_test {
159    name: "idmap2_tests",
160    defaults: [
161        "idmap2_defaults",
162    ],
163    tidy_checks: [
164        "-readability-magic-numbers",
165    ],
166    host_supported: true,
167    test_suites: ["general-tests"],
168    require_root: true,
169    srcs: [
170        "tests/BinaryStreamVisitorTests.cpp",
171        "tests/CommandLineOptionsTests.cpp",
172        "tests/FabricatedOverlayTests.cpp",
173        "tests/FileUtilsTests.cpp",
174        "tests/Idmap2BinaryTests.cpp",
175        "tests/IdmapTests.cpp",
176        "tests/Main.cpp",
177        "tests/PoliciesTests.cpp",
178        "tests/PrettyPrintVisitorTests.cpp",
179        "tests/RawPrintVisitorTests.cpp",
180        "tests/ResourceMappingTests.cpp",
181        "tests/ResourceUtilsTests.cpp",
182        "tests/ResultTests.cpp",
183        "tests/XmlParserTests.cpp",
184    ],
185    required: [
186        "idmap2",
187    ],
188    static_libs: [
189        "libgmock",
190        "libidmap2_protos",
191        "libpng",
192    ],
193    target: {
194        android: {
195            shared_libs: [
196                "libandroidfw",
197                "libbase",
198                "libidmap2",
199                "liblog",
200                "libprotobuf-cpp-lite",
201                "libutils",
202                "libz",
203                "libz",
204                "libziparchive",
205            ],
206            static_libs: [
207                "libidmap2_policies",
208            ],
209        },
210        host: {
211            static_libs: [
212                "libandroidfw",
213                "libbase",
214                "libcutils",
215                "libidmap2",
216                "libidmap2_policies",
217                "liblog",
218                "libprotobuf-cpp-lite",
219                "libutils",
220                "libziparchive",
221            ],
222            shared_libs: [
223                "libz",
224            ],
225            data: [
226                ":libz",
227                ":idmap2",
228            ],
229        },
230    },
231    data: [
232        "tests/data/**/*.apk",
233        "tests/data/**/*.png",
234    ],
235    compile_multilib: "first",
236    test_options: {
237        unit_test: true,
238    },
239}
240
241cc_binary {
242    name: "idmap2",
243    defaults: [
244        "idmap2_defaults",
245    ],
246    host_supported: true,
247    srcs: [
248        "idmap2/CommandUtils.cpp",
249        "idmap2/Create.cpp",
250        "idmap2/CreateMultiple.cpp",
251        "idmap2/Dump.cpp",
252        "idmap2/Lookup.cpp",
253        "idmap2/Main.cpp",
254    ],
255    static_libs: [
256        "libidmap2_protos",
257    ],
258    target: {
259        android: {
260            shared_libs: [
261                "libandroidfw",
262                "libbase",
263                "libcutils",
264                "libidmap2",
265                "libpng",
266                "libprotobuf-cpp-lite",
267                "libutils",
268                "libz",
269                "libziparchive",
270            ],
271            static_libs: [
272                "libidmap2_policies",
273            ],
274        },
275        host: {
276            static_libs: [
277                "libandroidfw",
278                "libbase",
279                "libcutils",
280                "libidmap2",
281                "libidmap2_policies",
282                "liblog",
283                "libpng",
284                "libprotobuf-cpp-lite",
285                "libutils",
286                "libziparchive",
287            ],
288            shared_libs: [
289                "libz",
290            ],
291        },
292    },
293
294}
295
296cc_binary {
297    name: "idmap2d",
298    defaults: [
299        "idmap2_defaults",
300    ],
301    host_supported: false,
302    srcs: [
303        "idmap2d/Idmap2Service.cpp",
304        "idmap2d/Main.cpp",
305    ],
306    shared_libs: [
307        "libandroidfw",
308        "libbase",
309        "libbinder",
310        "libcutils",
311        "libidmap2",
312        "libprotobuf-cpp-lite",
313        "libutils",
314        "libziparchive",
315    ],
316    static_libs: [
317        "libidmap2_policies",
318        "libidmap2_protos",
319        "libidmap2daidl",
320    ],
321    init_rc: ["idmap2d/idmap2d.rc"],
322}
323
324cc_library_static {
325    name: "libidmap2daidl",
326    srcs: [
327        ":idmap2_aidl",
328        ":idmap2_core_aidl",
329    ],
330    header_libs: [
331        "libbinder_headers",
332    ],
333    shared_libs: [
334        "libbase",
335    ],
336    aidl: {
337        export_aidl_headers: true,
338        local_include_dirs: [
339            "idmap2d/aidl/core",
340            "idmap2d/aidl/services/",
341        ],
342    },
343}
344
345filegroup {
346    name: "idmap2_core_aidl",
347    srcs: [
348        "idmap2d/aidl/core/android/os/FabricatedOverlayInternal.aidl",
349        "idmap2d/aidl/core/android/os/FabricatedOverlayInternalEntry.aidl",
350        "idmap2d/aidl/core/android/os/FabricatedOverlayInfo.aidl",
351    ],
352    path: "idmap2d/aidl/core/",
353}
354
355filegroup {
356    name: "idmap2_aidl",
357    srcs: [
358        "idmap2d/aidl/services/android/os/IIdmap2.aidl",
359    ],
360    path: "idmap2d/aidl/services/",
361}
362
363aidl_interface {
364    name: "overlayable_policy_aidl",
365    unstable: true,
366    srcs: [":overlayable_policy_aidl_files"],
367}
368
369filegroup {
370    name: "overlayable_policy_aidl_files",
371    srcs: [
372        "idmap2d/aidl/services/android/os/OverlayablePolicy.aidl",
373    ],
374    path: "idmap2d/aidl/services/",
375}
376