1// Copyright (C) 2010 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
15// libandroidfw is partially built for the host (used by obbtool, aapt, and others)
16
17package {
18    default_applicable_licenses: ["frameworks_base_libs_androidfw_license"],
19}
20
21// Added automatically by a large-scale-change
22// See: http://go/android-license-faq
23license {
24    name: "frameworks_base_libs_androidfw_license",
25    visibility: [":__subpackages__"],
26    license_kinds: [
27        "SPDX-license-identifier-Apache-2.0",
28    ],
29    license_text: [
30        "NOTICE",
31    ],
32}
33
34cc_defaults {
35    name: "libandroidfw_defaults",
36    cpp_std: "gnu++2b",
37    cflags: [
38        "-Werror",
39        "-Wunreachable-code",
40    ],
41    target: {
42        windows: {
43            // The Windows compiler warns incorrectly for value initialization with {}.
44            cppflags: ["-Wno-missing-field-initializers"],
45        },
46        host: {
47            cflags: ["-DSTATIC_ANDROIDFW_FOR_TOOLS"],
48        },
49    },
50}
51
52cc_library {
53    name: "libandroidfw",
54    defaults: ["libandroidfw_defaults"],
55    host_supported: true,
56    srcs: [
57        "ApkAssets.cpp",
58        "ApkParsing.cpp",
59        "Asset.cpp",
60        "AssetDir.cpp",
61        "AssetManager.cpp",
62        "AssetManager2.cpp",
63        "AssetsProvider.cpp",
64        "AttributeResolution.cpp",
65        "BigBuffer.cpp",
66        "ChunkIterator.cpp",
67        "ConfigDescription.cpp",
68        "Idmap.cpp",
69        "LoadedArsc.cpp",
70        "Locale.cpp",
71        "LocaleData.cpp",
72        "misc.cpp",
73        "ObbFile.cpp",
74        "PosixUtils.cpp",
75        "ResourceTimer.cpp",
76        "ResourceTypes.cpp",
77        "ResourceUtils.cpp",
78        "StreamingZipInflater.cpp",
79        "StringPool.cpp",
80        "TypeWrappers.cpp",
81        "Util.cpp",
82        "ZipFileRO.cpp",
83        "ZipUtils.cpp",
84    ],
85    export_include_dirs: ["include"],
86    export_shared_lib_headers: ["libz"],
87    static_libs: ["libincfs-utils"],
88    whole_static_libs: ["libincfs-utils"],
89    export_static_lib_headers: ["libincfs-utils"],
90    target: {
91        android: {
92            srcs: [
93                "BackupData.cpp",
94                "BackupHelpers.cpp",
95                "CursorWindow.cpp",
96            ],
97            shared_libs: [
98                "libbase",
99                "libbinder",
100                "liblog",
101                "libcutils",
102                "libincfs",
103                "libutils",
104                "libz",
105            ],
106            static_libs: ["libziparchive_for_incfs"],
107            static: {
108                enabled: false,
109            },
110        },
111        host: {
112            shared: {
113                enabled: false,
114            },
115            static_libs: [
116                "libbase",
117                "libcutils",
118                "liblog",
119                "libutils",
120                "libziparchive",
121            ],
122            shared_libs: [
123                "libz",
124            ],
125        },
126        host_linux: {
127            srcs: [
128                "CursorWindow.cpp",
129            ],
130        },
131        windows: {
132            enabled: true,
133        },
134    },
135    sanitize: {
136        blocklist: "libandroidfw_blocklist.txt",
137    },
138}
139
140common_test_libs = [
141    "libandroidfw",
142    "libbase",
143    "libcutils",
144    "libutils",
145    "libziparchive",
146]
147
148cc_test {
149    name: "libandroidfw_tests",
150    host_supported: true,
151    defaults: ["libandroidfw_defaults"],
152    cppflags: [
153        // This is to suppress warnings/errors from gtest
154        "-Wno-unnamed-type-template-args",
155    ],
156    srcs: [
157        // Helpers/infra for testing.
158        "tests/CommonHelpers.cpp",
159        "tests/TestHelpers.cpp",
160        "tests/TestMain.cpp",
161
162        // Actual tests.
163        "tests/ApkAssets_test.cpp",
164        "tests/ApkParsing_test.cpp",
165        "tests/AppAsLib_test.cpp",
166        "tests/Asset_test.cpp",
167        "tests/AssetManager2_test.cpp",
168        "tests/AttributeFinder_test.cpp",
169        "tests/AttributeResolution_test.cpp",
170        "tests/BigBuffer_test.cpp",
171        "tests/ByteBucketArray_test.cpp",
172        "tests/Config_test.cpp",
173        "tests/ConfigDescription_test.cpp",
174        "tests/ConfigLocale_test.cpp",
175        "tests/DynamicRefTable_test.cpp",
176        "tests/Idmap_test.cpp",
177        "tests/LoadedArsc_test.cpp",
178        "tests/Locale_test.cpp",
179        "tests/ResourceTimer_test.cpp",
180        "tests/ResourceUtils_test.cpp",
181        "tests/ResTable_test.cpp",
182        "tests/Split_test.cpp",
183        "tests/StringPiece_test.cpp",
184        "tests/StringPool_test.cpp",
185        "tests/Theme_test.cpp",
186        "tests/TypeWrappers_test.cpp",
187        "tests/ZipUtils_test.cpp",
188    ],
189    static_libs: ["libgmock"],
190    target: {
191        android: {
192            srcs: [
193                "tests/BackupData_test.cpp",
194                "tests/BackupHelpers_test.cpp",
195                "tests/CursorWindow_test.cpp",
196                "tests/ObbFile_test.cpp",
197                "tests/PosixUtils_test.cpp",
198            ],
199            shared_libs: common_test_libs + [
200                "libbinder",
201                "liblog",
202                "libui",
203            ],
204        },
205        host: {
206            static_libs: common_test_libs + [
207                "liblog",
208                "libz",
209            ],
210        },
211    },
212    data: [
213        "tests/data/**/*.apk",
214        "tests/data/**/*.arsc",
215        "tests/data/**/*.idmap",
216        ":FrameworkResourcesSparseTestApp",
217        ":FrameworkResourcesNotSparseTestApp",
218    ],
219    test_suites: ["device-tests"],
220}
221
222cc_benchmark {
223    name: "libandroidfw_benchmarks",
224    defaults: ["libandroidfw_defaults"],
225    srcs: [
226        // Helpers/infra for benchmarking.
227        "tests/BenchMain.cpp",
228        "tests/BenchmarkHelpers.cpp",
229        "tests/CommonHelpers.cpp",
230
231        // Actual benchmarks.
232        "tests/AssetManager2_bench.cpp",
233        "tests/AttributeResolution_bench.cpp",
234        "tests/CursorWindow_bench.cpp",
235        "tests/SparseEntry_bench.cpp",
236        "tests/Theme_bench.cpp",
237    ],
238    shared_libs: common_test_libs,
239    data: ["tests/data/**/*.apk"],
240}
241
242cc_library {
243    name: "libandroidfw_fuzzer_lib",
244    defaults: ["libandroidfw_defaults"],
245    host_supported: true,
246    srcs: [
247        "CursorWindow.cpp",
248    ],
249    export_include_dirs: ["include"],
250    target: {
251        android: {
252            shared_libs: common_test_libs + [
253                "libbinder",
254                "liblog",
255            ],
256        },
257        host: {
258            static_libs: common_test_libs + [
259                "libbinder",
260                "liblog",
261            ],
262        },
263        darwin: {
264            // libbinder is not supported on mac
265            enabled: false,
266        },
267    },
268}
269