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