blob: 7063b89a4156463c68215ac65c93d17957916f99 [file] [log] [blame]
Fabien Sanglard19160202017-01-12 14:24:31 -05001//
Adam Lesinskid48944a2017-02-21 14:22:30 -08002// Copyright (C) 2017 The Android Open Source Project
Fabien Sanglard19160202017-01-12 14:24:31 -05003//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
Bob Badour8a6a2bc2021-02-12 17:07:05 -080017package {
Wei Li1a20c122024-02-27 18:00:13 -080018 default_applicable_licenses: ["Android-Apache-2.0"],
Bob Badour8a6a2bc2021-02-12 17:07:05 -080019}
20
Fabien Sanglard19160202017-01-12 14:24:31 -050021toolSources = [
Iurii Makhnof2480742022-04-26 14:51:24 +000022 "cmd/ApkInfo.cpp",
Ryan Mitchell833a1a62018-07-10 13:51:36 -070023 "cmd/Command.cpp",
Adam Lesinskid0f492d2017-04-03 18:12:45 -070024 "cmd/Compile.cpp",
Adam Lesinski8780eb62017-10-31 17:44:39 -070025 "cmd/Convert.cpp",
Adam Lesinskid0f492d2017-04-03 18:12:45 -070026 "cmd/Diff.cpp",
27 "cmd/Dump.cpp",
28 "cmd/Link.cpp",
29 "cmd/Optimize.cpp",
30 "cmd/Util.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -050031]
32
33cc_defaults {
Dan Willemsen7544b9c2017-09-08 22:44:51 -070034 name: "aapt2_defaults",
Yurii Zubrytskyiba6f8a32022-02-16 17:00:42 -080035 cpp_std: "gnu++2b",
Fabien Sanglard19160202017-01-12 14:24:31 -050036 cflags: [
37 "-Wall",
38 "-Werror",
39 "-Wno-unused-parameter",
40 ],
41 cppflags: [
42 "-Wno-missing-field-initializers",
43 "-fno-exceptions",
44 "-fno-rtti",
45 ],
46 target: {
47 windows: {
Diego Perez3467bcb2023-02-10 10:13:02 +000048 compile_multilib: "64",
Fabien Sanglard19160202017-01-12 14:24:31 -050049 enabled: true,
50 cflags: ["-Wno-maybe-uninitialized"],
Ryan Mitchell319fc022019-05-06 11:54:41 -070051 ldflags: ["-static"],
Fabien Sanglard19160202017-01-12 14:24:31 -050052 },
53 darwin: {
54 cflags: ["-D_DARWIN_UNLIMITED_STREAMS"],
Fabien Sanglard19160202017-01-12 14:24:31 -050055 },
56 },
Orion Hodson63f06b72020-04-03 09:42:03 +010057 header_libs: ["jni_headers"],
Fabien Sanglard19160202017-01-12 14:24:31 -050058 static_libs: [
59 "libandroidfw",
60 "libutils",
61 "liblog",
62 "libcutils",
63 "libexpat",
64 "libziparchive",
65 "libpng",
66 "libbase",
Ryan Mitchell22ead1c2019-05-20 16:54:48 -070067 "libprotobuf-cpp-full",
Dan Willemsen85aee732017-09-08 21:26:31 -070068 "libz",
Ryan Mitchell34039b22019-03-18 08:57:47 -070069 "libbuildversion",
Winson62ac8b52019-12-04 08:36:48 -080070 "libidmap2_policies",
Fabien Sanglard19160202017-01-12 14:24:31 -050071 ],
Ryan Mitchell81bae2d2019-01-04 13:48:04 -080072 stl: "libc++_static",
Fabien Sanglard19160202017-01-12 14:24:31 -050073}
74
75// ==========================================================
76// NOTE: Do not add any shared libraries.
77// AAPT2 is built to run on many environments
78// that may not have the required dependencies.
79// ==========================================================
80
81// ==========================================================
82// Build the host static library: aapt2
83// ==========================================================
84cc_library_host_static {
85 name: "libaapt2",
86 srcs: [
87 "compile/IdAssigner.cpp",
88 "compile/InlineXmlFormatParser.cpp",
89 "compile/NinePatch.cpp",
90 "compile/Png.cpp",
91 "compile/PngChunkFilter.cpp",
92 "compile/PngCrunch.cpp",
93 "compile/PseudolocaleGenerator.cpp",
94 "compile/Pseudolocalizer.cpp",
95 "compile/XmlIdCollector.cpp",
Shane Farmer74cdea32017-05-12 16:22:36 -070096 "configuration/ConfigurationParser.cpp",
Ryan Mitchellfc225b22018-08-21 14:52:51 -070097 "dump/DumpManifest.cpp",
Shane Farmer57669432017-06-19 12:52:04 -070098 "filter/AbiFilter.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -050099 "filter/ConfigFilter.cpp",
Adam Lesinski46708052017-09-29 14:49:15 -0700100 "format/Archive.cpp",
Adam Lesinski00451162017-10-03 07:44:08 -0700101 "format/Container.cpp",
Adam Lesinski46708052017-09-29 14:49:15 -0700102 "format/binary/BinaryResourceParser.cpp",
103 "format/binary/ResChunkPullParser.cpp",
Iurii Makhnocf844a32022-09-29 16:45:51 +0000104 "format/binary/ResEntryWriter.cpp",
Adam Lesinski46708052017-09-29 14:49:15 -0700105 "format/binary/TableFlattener.cpp",
106 "format/binary/XmlFlattener.cpp",
107 "format/proto/ProtoDeserialize.cpp",
108 "format/proto/ProtoSerialize.cpp",
Adam Lesinski00451162017-10-03 07:44:08 -0700109 "io/BigBufferStream.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500110 "io/File.cpp",
Adam Lesinski00451162017-10-03 07:44:08 -0700111 "io/FileStream.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500112 "io/FileSystem.cpp",
Adam Lesinski00451162017-10-03 07:44:08 -0700113 "io/StringStream.cpp",
Adam Lesinskid0f492d2017-04-03 18:12:45 -0700114 "io/Util.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500115 "io/ZipArchive.cpp",
116 "link/AutoVersioner.cpp",
Mark Punzalandcc00c42023-11-03 13:40:40 -0700117 "link/FeatureFlagsFilter.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500118 "link/ManifestFixer.cpp",
Adam Lesinski34a16872018-02-23 16:18:10 -0800119 "link/NoDefaultResourceRemover.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500120 "link/PrivateAttributeMover.cpp",
121 "link/ReferenceLinker.cpp",
Winson3c918b82019-01-25 14:25:37 -0800122 "link/ResourceExcluder.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500123 "link/TableMerger.cpp",
Adam Lesinskic744ae82017-05-17 19:28:38 -0700124 "link/XmlCompatVersioner.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500125 "link/XmlNamespaceRemover.cpp",
126 "link/XmlReferenceLinker.cpp",
Shane Farmer0a5b2012017-06-22 12:24:12 -0700127 "optimize/MultiApkGenerator.cpp",
Adam Lesinskid48944a2017-02-21 14:22:30 -0800128 "optimize/ResourceDeduper.cpp",
Mohamed Heikald3c5fb62018-01-12 11:37:26 -0500129 "optimize/ResourceFilter.cpp",
felkachang4bdd3ac2022-09-13 10:58:49 +0800130 "optimize/Obfuscator.cpp",
Adam Lesinskid48944a2017-02-21 14:22:30 -0800131 "optimize/VersionCollapser.cpp",
Inseob Kim2738abb2023-09-15 16:38:50 +0900132 "process/ProductFilter.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500133 "process/SymbolTable.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500134 "split/TableSplitter.cpp",
Adam Lesinski93190b72017-11-03 15:20:17 -0700135 "text/Printer.cpp",
Adam Lesinski66ea8402017-06-28 11:44:11 -0700136 "text/Unicode.cpp",
137 "text/Utf8Iterator.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500138 "util/Files.cpp",
139 "util/Util.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500140 "Debug.cpp",
141 "DominatorTree.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500142 "java/AnnotationProcessor.cpp",
143 "java/ClassDefinition.cpp",
144 "java/JavaClassGenerator.cpp",
145 "java/ManifestClassGenerator.cpp",
146 "java/ProguardRules.cpp",
Pierre Lecesneff759e62017-02-01 00:29:25 +0000147 "LoadedApk.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500148 "Resource.cpp",
149 "ResourceParser.cpp",
150 "ResourceTable.cpp",
151 "ResourceUtils.cpp",
152 "ResourceValues.cpp",
153 "SdkConstants.cpp",
Fabien Sanglard2d34e762019-02-21 15:13:29 -0800154 "trace/TraceBuffer.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500155 "xml/XmlActionExecutor.cpp",
156 "xml/XmlDom.cpp",
157 "xml/XmlPullParser.cpp",
158 "xml/XmlUtil.cpp",
Iurii Makhno85875a82022-04-26 15:30:01 +0000159 "ApkInfo.proto",
Adam Lesinskib58c3ef2017-09-12 17:39:52 -0700160 "Configuration.proto",
Adam Lesinski4ffea042017-08-10 15:37:28 -0700161 "Resources.proto",
Donald Chaic0009622020-04-22 19:19:22 -0700162 "ResourceMetadata.proto",
Adam Lesinski4ffea042017-08-10 15:37:28 -0700163 "ResourcesInternal.proto",
Ryan Mitchellefcdb952021-04-14 17:31:37 -0700164 "ValueTransformer.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500165 ],
166 proto: {
167 export_proto_headers: true,
Liz Kammerba0a32c2022-03-22 13:39:40 -0400168 type: "full",
Fabien Sanglard19160202017-01-12 14:24:31 -0500169 },
Dan Willemsen7544b9c2017-09-08 22:44:51 -0700170 defaults: ["aapt2_defaults"],
Fabien Sanglard19160202017-01-12 14:24:31 -0500171}
172
173// ==========================================================
Fabien Sanglard19160202017-01-12 14:24:31 -0500174// Build the host tests: aapt2_tests
175// ==========================================================
176cc_test_host {
177 name: "aapt2_tests",
Adam Lesinskibab4ef52017-06-01 15:22:57 -0700178 srcs: [
Adam Lesinskiefeb7af2017-08-02 14:57:43 -0700179 "test/Builders.cpp",
Adam Lesinskibab4ef52017-06-01 15:22:57 -0700180 "test/Common.cpp",
Ryan Mitchell479fa392019-01-02 17:15:39 -0800181 "test/Fixture.cpp",
Adam Lesinskibab4ef52017-06-01 15:22:57 -0700182 "**/*_test.cpp",
Donald Chaib8f078c2017-10-18 23:51:18 -0700183 ] + toolSources,
Shane Farmer74cdea32017-05-12 16:22:36 -0700184 static_libs: [
185 "libaapt2",
186 "libgmock",
187 ],
Dan Willemsen7544b9c2017-09-08 22:44:51 -0700188 defaults: ["aapt2_defaults"],
Ryan Mitchell479fa392019-01-02 17:15:39 -0800189 data: [
Ryan Mitchell87d30dd2021-03-30 08:22:39 -0700190 "integration-tests/CompileTest/**/*",
191 "integration-tests/CommandTests/**/*",
192 "integration-tests/ConvertTest/**/*",
Iurii Makhnodcead622022-04-13 18:00:03 +0000193 "integration-tests/DumpTest/**/*",
Ryan Mitchell479fa392019-01-02 17:15:39 -0800194 ],
Fabien Sanglard19160202017-01-12 14:24:31 -0500195}
196
197// ==========================================================
198// Build the host executable: aapt2
199// ==========================================================
200cc_binary_host {
201 name: "aapt2",
202 srcs: ["Main.cpp"] + toolSources,
Donald Chai2ee7cc62019-05-11 02:37:23 -0700203 use_version_lib: true,
Fabien Sanglard19160202017-01-12 14:24:31 -0500204 static_libs: ["libaapt2"],
Dan Willemsen7544b9c2017-09-08 22:44:51 -0700205 defaults: ["aapt2_defaults"],
Ryan Mitchell655b9362020-04-06 16:16:14 -0700206 dist: {
207 targets: ["aapt2_artifacts"],
208 },
Fabien Sanglard19160202017-01-12 14:24:31 -0500209}
Colin Cross0b28a922019-03-18 22:18:27 -0700210
211// ==========================================================
212// Dist the protos
213// ==========================================================
214genrule {
215 name: "aapt2-protos",
216 tools: [":soong_zip"],
217 srcs: [
218 "Configuration.proto",
Izabela Orlowskaf53b67c2019-11-07 11:53:54 +0000219 "ResourcesInternal.proto",
Donald Chaic0009622020-04-22 19:19:22 -0700220 "ResourceMetadata.proto",
Colin Cross0b28a922019-03-18 22:18:27 -0700221 "Resources.proto",
222 ],
223 out: ["aapt2-protos.zip"],
224 cmd: "mkdir $(genDir)/protos && " +
225 "cp $(in) $(genDir)/protos && " +
226 "$(location :soong_zip) -o $(out) -C $(genDir)/protos -D $(genDir)/protos",
227 dist: {
Ryan Mitchell87d30dd2021-03-30 08:22:39 -0700228 targets: [
229 "sdk_repo",
230 "aapt2_artifacts",
231 ],
Colin Cross0b28a922019-03-18 22:18:27 -0700232 },
233}
Nelson Li08b87e42024-01-30 08:46:02 +0000234
235cc_genrule {
236 name: "aapt2_results",
237 srcs: [
238 ":aapt2_tests",
239 "integration-tests/CompileTest/**/*",
240 "integration-tests/CommandTests/**/*",
241 "integration-tests/ConvertTest/**/*",
242 "integration-tests/DumpTest/**/*",
243 ],
244 host_supported: true,
245 device_supported: false,
246 target: {
247 windows: {
248 compile_multilib: "64",
249 },
250 },
251 out: ["result.xml"],
252 cmd: "mkdir -p $(genDir)/integration-tests/CompileTest/ && " +
253 "cp $(locations integration-tests/CompileTest/**/*) $(genDir)/integration-tests/CompileTest/ && " +
254 "mkdir -p $(genDir)/integration-tests/CommandTests/ && " +
255 "cp $(locations integration-tests/CommandTests/**/*) $(genDir)/integration-tests/CompileTest/ && " +
256 "mkdir -p $(genDir)/integration-tests/ConvertTest/ && " +
257 "cp $(locations integration-tests/ConvertTest/**/*) $(genDir)/integration-tests/ConvertTest/ && " +
258 "mkdir -p $(genDir)/integration-tests/DumpTest/ && " +
259 "cp $(locations integration-tests/DumpTest/**/*) $(genDir)/integration-tests/DumpTest/ && " +
260 "cp $(locations :aapt2_tests) $(genDir)/ && " +
261 "$(genDir)/aapt2_tests " +
262 "--gtest_output=xml:$(out) " +
263 ">/dev/null 2>&1 ; true",
Nelson Liffe60232024-02-02 07:22:56 +0000264 dist: {
265 targets: ["aapt2_run_host_unit_tests"],
266 dir: "gtest",
267 dest: "aapt2_host_unit_tests_result.xml",
268 },
269 arch: {
270 x86: {
271 dist: {
272 suffix: "_x86",
273 },
274 },
275 x86_64: {
276 dist: {
277 suffix: "_x86_64",
278 },
279 },
280 },
Nelson Li08b87e42024-01-30 08:46:02 +0000281}
282
283phony_rule {
284 name: "aapt2_run_host_unit_tests",
285 phony_deps: ["aapt2_results"],
286}