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
17cc_defaults {
18    name: "libandroidfw_defaults",
19    cflags: [
20        "-Werror",
21        "-Wunreachable-code",
22    ],
23    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,
38    srcs: [
39        "ApkAssets.cpp",
40        "Asset.cpp",
41        "AssetDir.cpp",
42        "AssetManager.cpp",
43        "AssetManager2.cpp",
44        "AttributeResolution.cpp",
45        "ChunkIterator.cpp",
46        "Idmap.cpp",
47        "LoadedArsc.cpp",
48        "LocaleData.cpp",
49        "misc.cpp",
50        "ObbFile.cpp",
51        "ResourceTypes.cpp",
52        "ResourceUtils.cpp",
53        "StreamingZipInflater.cpp",
54        "TypeWrappers.cpp",
55        "Util.cpp",
56        "ZipFileRO.cpp",
57        "ZipUtils.cpp",
58    ],
59    export_include_dirs: ["include"],
60    target: {
61        android: {
62            srcs: [
63                "BackupData.cpp",
64                "BackupHelpers.cpp",
65                "CursorWindow.cpp",
66                "DisplayEventDispatcher.cpp",
67            ],
68            shared_libs: [
69                "libziparchive",
70                "libbase",
71                "libbinder",
72                "liblog",
73                "libcutils",
74                "libgui",
75                "libutils",
76                "libz",
77            ],
78            static: {
79                enabled: false,
80            },
81        },
82        host: {
83            shared: {
84                enabled: false,
85            },
86            static_libs: [
87                "libziparchive",
88                "libbase",
89                "liblog",
90                "libcutils",
91                "libutils",
92            ],
93            shared_libs: [
94                "libz",
95            ],
96        },
97        windows: {
98            enabled: true,
99        },
100    },
101    sanitize: {
102        blacklist: "libandroidfw_blacklist.txt",
103    },
104}
105
106common_test_libs = [
107    "libandroidfw",
108    "libbase",
109    "libcutils",
110    "libutils",
111    "libziparchive",
112]
113
114cc_test {
115    name: "libandroidfw_tests",
116    host_supported: true,
117    defaults: ["libandroidfw_defaults"],
118    cppflags: [
119        // This is to suppress warnings/errors from gtest
120        "-Wno-unnamed-type-template-args",
121    ],
122    srcs: [
123        // Helpers/infra for testing.
124        "tests/CommonHelpers.cpp",
125        "tests/TestHelpers.cpp",
126        "tests/TestMain.cpp",
127
128        // Actual tests.
129        "tests/ApkAssets_test.cpp",
130        "tests/AppAsLib_test.cpp",
131        "tests/Asset_test.cpp",
132        "tests/AssetManager2_test.cpp",
133        "tests/AttributeFinder_test.cpp",
134        "tests/AttributeResolution_test.cpp",
135        "tests/ByteBucketArray_test.cpp",
136        "tests/Config_test.cpp",
137        "tests/ConfigLocale_test.cpp",
138        "tests/Idmap_test.cpp",
139        "tests/LoadedArsc_test.cpp",
140        "tests/ResourceUtils_test.cpp",
141        "tests/ResTable_test.cpp",
142        "tests/Split_test.cpp",
143        "tests/StringPiece_test.cpp",
144        "tests/Theme_test.cpp",
145        "tests/TypeWrappers_test.cpp",
146        "tests/ZipUtils_test.cpp",
147    ],
148    static_libs: ["libgmock"],
149    target: {
150        android: {
151            srcs: [
152                "tests/BackupData_test.cpp",
153                "tests/ObbFile_test.cpp",
154            ],
155            shared_libs: common_test_libs + ["libui"],
156        },
157        host: {
158            static_libs: common_test_libs + ["liblog", "libz"],
159        },
160    },
161    data: ["tests/data/**/*.apk"],
162}
163
164cc_benchmark {
165    name: "libandroidfw_benchmarks",
166    defaults: ["libandroidfw_defaults"],
167    srcs: [
168        // Helpers/infra for benchmarking.
169        "tests/BenchMain.cpp",
170        "tests/BenchmarkHelpers.cpp",
171        "tests/CommonHelpers.cpp",
172
173        // Actual benchmarks.
174        "tests/AssetManager2_bench.cpp",
175        "tests/AttributeResolution_bench.cpp",
176        "tests/SparseEntry_bench.cpp",
177        "tests/Theme_bench.cpp",
178    ],
179    shared_libs: common_test_libs,
180    data: ["tests/data/**/*.apk"],
181}
182
183