blob: b54f7d81274cd3a88d41cd352bdae982d9765984 [file] [log] [blame]
Colin Cross4f8d9e62016-12-01 15:55:00 -08001// 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
Adam Lesinski873ef0e2017-10-11 16:50:37 -070017cc_defaults {
18 name: "libandroidfw_defaults",
Colin Cross4f8d9e62016-12-01 15:55:00 -080019 cflags: [
Colin Cross4f8d9e62016-12-01 15:55:00 -080020 "-Werror",
Colin Cross4f8d9e62016-12-01 15:55:00 -080021 "-Wunreachable-code",
22 ],
Adam Lesinski873ef0e2017-10-11 16:50:37 -070023 target: {
24 windows: {
25 // The Windows compiler warns incorrectly for value initialization with {}.
26 cppflags: ["-Wno-missing-field-initializers"],
27 },
28 host: {
29 cflags: ["-DSTATIC_ANDROIDFW_FOR_TOOLS"],
30 },
31 },
32}
33
34cc_library {
35 name: "libandroidfw",
36 defaults: ["libandroidfw_defaults"],
37 host_supported: true,
Colin Cross4f8d9e62016-12-01 15:55:00 -080038 srcs: [
Adam Lesinski7ad11102016-10-28 16:39:15 -070039 "ApkAssets.cpp",
Colin Cross4f8d9e62016-12-01 15:55:00 -080040 "Asset.cpp",
41 "AssetDir.cpp",
42 "AssetManager.cpp",
Adam Lesinski7ad11102016-10-28 16:39:15 -070043 "AssetManager2.cpp",
Colin Cross4f8d9e62016-12-01 15:55:00 -080044 "AttributeResolution.cpp",
Adam Lesinski7ad11102016-10-28 16:39:15 -070045 "ChunkIterator.cpp",
Mårten Kongstad24c9aa62018-06-20 08:46:41 +020046 "ConfigDescription.cpp",
Adam Lesinski970bd8d2017-09-25 13:21:55 -070047 "Idmap.cpp",
Adam Lesinski7ad11102016-10-28 16:39:15 -070048 "LoadedArsc.cpp",
Mårten Kongstad24c9aa62018-06-20 08:46:41 +020049 "Locale.cpp",
Colin Cross4f8d9e62016-12-01 15:55:00 -080050 "LocaleData.cpp",
51 "misc.cpp",
52 "ObbFile.cpp",
Mårten Kongstad2503a492018-09-27 13:32:30 +020053 "PosixUtils.cpp",
Colin Cross4f8d9e62016-12-01 15:55:00 -080054 "ResourceTypes.cpp",
Adam Lesinski929d6512017-01-16 19:11:19 -080055 "ResourceUtils.cpp",
Colin Cross4f8d9e62016-12-01 15:55:00 -080056 "StreamingZipInflater.cpp",
57 "TypeWrappers.cpp",
Adam Lesinskida431a22016-12-29 16:08:16 -050058 "Util.cpp",
Colin Cross4f8d9e62016-12-01 15:55:00 -080059 "ZipFileRO.cpp",
60 "ZipUtils.cpp",
61 ],
62 export_include_dirs: ["include"],
Dan Willemsen4888b1f2018-05-09 20:30:33 -070063 export_shared_lib_headers: ["libz"],
Ryan Mitchelldb21f09a2020-11-16 23:08:18 +000064 static_libs: ["libincfs-utils"],
65 whole_static_libs: ["libincfs-utils"],
66 export_static_lib_headers: ["libincfs-utils"],
Colin Cross4f8d9e62016-12-01 15:55:00 -080067 target: {
68 android: {
69 srcs: [
70 "BackupData.cpp",
71 "BackupHelpers.cpp",
72 "CursorWindow.cpp",
Colin Cross4f8d9e62016-12-01 15:55:00 -080073 ],
74 shared_libs: [
Colin Cross4f8d9e62016-12-01 15:55:00 -080075 "libbase",
76 "libbinder",
77 "liblog",
78 "libcutils",
Ryan Mitchelldb21f09a2020-11-16 23:08:18 +000079 "libincfs",
Colin Cross4f8d9e62016-12-01 15:55:00 -080080 "libutils",
81 "libz",
Ryan Mitchelldb21f09a2020-11-16 23:08:18 +000082 "libziparchive",
Colin Cross4f8d9e62016-12-01 15:55:00 -080083 ],
84 static: {
85 enabled: false,
86 },
87 },
88 host: {
Colin Cross4f8d9e62016-12-01 15:55:00 -080089 shared: {
90 enabled: false,
91 },
Adam Lesinski7ad11102016-10-28 16:39:15 -070092 static_libs: [
Ryan Mitchell55ef6162020-11-13 23:55:20 +000093 "libbase",
Ryan Mitchell55ef6162020-11-13 23:55:20 +000094 "libcutils",
Ryan Mitchelldb21f09a2020-11-16 23:08:18 +000095 "liblog",
Ryan Mitchell55ef6162020-11-13 23:55:20 +000096 "libutils",
Ryan Mitchelldb21f09a2020-11-16 23:08:18 +000097 "libziparchive",
Adam Lesinski7ad11102016-10-28 16:39:15 -070098 ],
99 shared_libs: [
Dan Willemsena2902e32017-09-27 16:20:31 -0700100 "libz",
Adam Lesinski7ad11102016-10-28 16:39:15 -0700101 ],
Colin Cross4f8d9e62016-12-01 15:55:00 -0800102 },
Jerome Gaillard10447022020-11-02 16:16:17 +0000103 linux_glibc: {
104 srcs: [
105 "CursorWindow.cpp",
106 ],
107 },
Colin Cross4f8d9e62016-12-01 15:55:00 -0800108 windows: {
109 enabled: true,
Colin Cross4f8d9e62016-12-01 15:55:00 -0800110 },
111 },
Ivan Lozano02828742017-11-07 13:26:27 -0800112 sanitize: {
Pirama Arumuga Nainar88db3032020-07-28 14:38:20 -0700113 blocklist: "libandroidfw_blocklist.txt",
Ivan Lozano02828742017-11-07 13:26:27 -0800114 },
Colin Cross4f8d9e62016-12-01 15:55:00 -0800115}
Adam Lesinski873ef0e2017-10-11 16:50:37 -0700116
117common_test_libs = [
118 "libandroidfw",
119 "libbase",
120 "libcutils",
121 "libutils",
122 "libziparchive",
123]
124
125cc_test {
126 name: "libandroidfw_tests",
127 host_supported: true,
128 defaults: ["libandroidfw_defaults"],
129 cppflags: [
130 // This is to suppress warnings/errors from gtest
131 "-Wno-unnamed-type-template-args",
132 ],
133 srcs: [
134 // Helpers/infra for testing.
135 "tests/CommonHelpers.cpp",
136 "tests/TestHelpers.cpp",
137 "tests/TestMain.cpp",
138
139 // Actual tests.
140 "tests/ApkAssets_test.cpp",
141 "tests/AppAsLib_test.cpp",
142 "tests/Asset_test.cpp",
143 "tests/AssetManager2_test.cpp",
144 "tests/AttributeFinder_test.cpp",
145 "tests/AttributeResolution_test.cpp",
146 "tests/ByteBucketArray_test.cpp",
147 "tests/Config_test.cpp",
Mårten Kongstad24c9aa62018-06-20 08:46:41 +0200148 "tests/ConfigDescription_test.cpp",
Adam Lesinski873ef0e2017-10-11 16:50:37 -0700149 "tests/ConfigLocale_test.cpp",
Ryan Mitchellb9b540b2018-08-22 11:22:54 -0700150 "tests/DynamicRefTable_test.cpp",
Adam Lesinski873ef0e2017-10-11 16:50:37 -0700151 "tests/Idmap_test.cpp",
152 "tests/LoadedArsc_test.cpp",
Mårten Kongstad24c9aa62018-06-20 08:46:41 +0200153 "tests/Locale_test.cpp",
Adam Lesinski873ef0e2017-10-11 16:50:37 -0700154 "tests/ResourceUtils_test.cpp",
155 "tests/ResTable_test.cpp",
156 "tests/Split_test.cpp",
157 "tests/StringPiece_test.cpp",
158 "tests/Theme_test.cpp",
159 "tests/TypeWrappers_test.cpp",
160 "tests/ZipUtils_test.cpp",
161 ],
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800162 static_libs: ["libgmock"],
Adam Lesinski873ef0e2017-10-11 16:50:37 -0700163 target: {
164 android: {
165 srcs: [
166 "tests/BackupData_test.cpp",
Jeff Sharkeyae2d88a2020-09-26 18:57:32 -0600167 "tests/BackupHelpers_test.cpp",
168 "tests/CursorWindow_test.cpp",
Adam Lesinski873ef0e2017-10-11 16:50:37 -0700169 "tests/ObbFile_test.cpp",
Mårten Kongstad2503a492018-09-27 13:32:30 +0200170 "tests/PosixUtils_test.cpp",
Adam Lesinski873ef0e2017-10-11 16:50:37 -0700171 ],
Brett Chabotde3a2bc2020-11-04 08:59:06 -0800172 shared_libs: common_test_libs + [
173 "libbinder",
174 "liblog",
175 "libui",
176 ],
Adam Lesinski873ef0e2017-10-11 16:50:37 -0700177 },
178 host: {
Brett Chabotde3a2bc2020-11-04 08:59:06 -0800179 static_libs: common_test_libs + [
180 "liblog",
181 "libz",
182 ],
Adam Lesinski873ef0e2017-10-11 16:50:37 -0700183 },
184 },
Winson9947f1e2019-08-16 10:20:39 -0700185 data: [
Ryan Mitchell8a891d82019-07-01 09:48:23 -0700186 "tests/data/**/*.apk",
187 "tests/data/**/*.arsc",
188 "tests/data/**/*.idmap",
Winson9947f1e2019-08-16 10:20:39 -0700189 ],
Dan Shi8d7267e2018-12-18 16:06:40 -0800190 test_suites: ["device-tests"],
Adam Lesinski873ef0e2017-10-11 16:50:37 -0700191}
192
193cc_benchmark {
194 name: "libandroidfw_benchmarks",
195 defaults: ["libandroidfw_defaults"],
196 srcs: [
197 // Helpers/infra for benchmarking.
198 "tests/BenchMain.cpp",
199 "tests/BenchmarkHelpers.cpp",
200 "tests/CommonHelpers.cpp",
201
202 // Actual benchmarks.
203 "tests/AssetManager2_bench.cpp",
Adam Lesinskibebfcc42018-02-12 14:27:46 -0800204 "tests/AttributeResolution_bench.cpp",
Jeff Sharkeyae2d88a2020-09-26 18:57:32 -0600205 "tests/CursorWindow_bench.cpp",
Adam Lesinski873ef0e2017-10-11 16:50:37 -0700206 "tests/SparseEntry_bench.cpp",
207 "tests/Theme_bench.cpp",
208 ],
209 shared_libs: common_test_libs,
210 data: ["tests/data/**/*.apk"],
211}
Jeff Sharkey256da5a2020-10-13 09:40:52 -0600212
213cc_library {
214 name: "libandroidfw_fuzzer_lib",
215 defaults: ["libandroidfw_defaults"],
216 host_supported: true,
217 srcs: [
218 "CursorWindow.cpp",
219 ],
220 export_include_dirs: ["include"],
221 target: {
222 android: {
Brett Chabotde3a2bc2020-11-04 08:59:06 -0800223 shared_libs: common_test_libs + [
224 "libbinder",
225 "liblog",
226 ],
Jeff Sharkey256da5a2020-10-13 09:40:52 -0600227 },
228 host: {
Brett Chabotde3a2bc2020-11-04 08:59:06 -0800229 static_libs: common_test_libs + [
230 "libbinder",
231 "liblog",
232 ],
233 },
234 darwin: {
235 // libbinder is not supported on mac
236 enabled: false,
Jeff Sharkey256da5a2020-10-13 09:40:52 -0600237 },
238 },
239}