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