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