blob: f43cf521edf5dae56fda410c9193fb463418b0a1 [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",
Jing Mike13f5b382023-02-25 16:14:53 +080045 "-Wno-deprecated-declarations",
Fabien Sanglard19160202017-01-12 14:24:31 -050046 ],
47 target: {
48 windows: {
Diego Perez3467bcb2023-02-10 10:13:02 +000049 compile_multilib: "64",
Fabien Sanglard19160202017-01-12 14:24:31 -050050 enabled: true,
51 cflags: ["-Wno-maybe-uninitialized"],
Ryan Mitchell319fc022019-05-06 11:54:41 -070052 ldflags: ["-static"],
Fabien Sanglard19160202017-01-12 14:24:31 -050053 },
54 darwin: {
55 cflags: ["-D_DARWIN_UNLIMITED_STREAMS"],
Fabien Sanglard19160202017-01-12 14:24:31 -050056 },
57 },
Yurii Zubrytskyif51c1df2024-07-22 15:48:22 -070058 header_libs: [
59 "jni_headers",
60 "native_headers",
61 ],
Fabien Sanglard19160202017-01-12 14:24:31 -050062 static_libs: [
63 "libandroidfw",
64 "libutils",
65 "liblog",
66 "libcutils",
67 "libexpat",
68 "libziparchive",
69 "libpng",
70 "libbase",
Ryan Mitchell22ead1c2019-05-20 16:54:48 -070071 "libprotobuf-cpp-full",
Dan Willemsen85aee732017-09-08 21:26:31 -070072 "libz",
Ryan Mitchell34039b22019-03-18 08:57:47 -070073 "libbuildversion",
Winson62ac8b52019-12-04 08:36:48 -080074 "libidmap2_policies",
Fabien Sanglard19160202017-01-12 14:24:31 -050075 ],
Ryan Mitchell81bae2d2019-01-04 13:48:04 -080076 stl: "libc++_static",
Fabien Sanglard19160202017-01-12 14:24:31 -050077}
78
79// ==========================================================
80// NOTE: Do not add any shared libraries.
81// AAPT2 is built to run on many environments
82// that may not have the required dependencies.
83// ==========================================================
84
85// ==========================================================
86// Build the host static library: aapt2
87// ==========================================================
88cc_library_host_static {
89 name: "libaapt2",
90 srcs: [
91 "compile/IdAssigner.cpp",
92 "compile/InlineXmlFormatParser.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -050093 "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",
Fabien Sanglard19160202017-01-12 14:24:31 -0500109 "io/File.cpp",
110 "io/FileSystem.cpp",
Adam Lesinski00451162017-10-03 07:44:08 -0700111 "io/StringStream.cpp",
Adam Lesinskid0f492d2017-04-03 18:12:45 -0700112 "io/Util.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500113 "io/ZipArchive.cpp",
114 "link/AutoVersioner.cpp",
Mark Punzalandcc00c42023-11-03 13:40:40 -0700115 "link/FeatureFlagsFilter.cpp",
Jeremy Meyer423c0f52024-08-02 12:06:54 -0700116 "link/FlagDisabledResourceRemover.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500117 "link/ManifestFixer.cpp",
Adam Lesinski34a16872018-02-23 16:18:10 -0800118 "link/NoDefaultResourceRemover.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500119 "link/PrivateAttributeMover.cpp",
120 "link/ReferenceLinker.cpp",
Winson3c918b82019-01-25 14:25:37 -0800121 "link/ResourceExcluder.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500122 "link/TableMerger.cpp",
Adam Lesinskic744ae82017-05-17 19:28:38 -0700123 "link/XmlCompatVersioner.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500124 "link/XmlNamespaceRemover.cpp",
125 "link/XmlReferenceLinker.cpp",
Shane Farmer0a5b2012017-06-22 12:24:12 -0700126 "optimize/MultiApkGenerator.cpp",
Adam Lesinskid48944a2017-02-21 14:22:30 -0800127 "optimize/ResourceDeduper.cpp",
Mohamed Heikald3c5fb62018-01-12 11:37:26 -0500128 "optimize/ResourceFilter.cpp",
felkachang4bdd3ac2022-09-13 10:58:49 +0800129 "optimize/Obfuscator.cpp",
Adam Lesinskid48944a2017-02-21 14:22:30 -0800130 "optimize/VersionCollapser.cpp",
Inseob Kim5fe521e2023-09-15 16:38:50 +0900131 "process/ProductFilter.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500132 "process/SymbolTable.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500133 "split/TableSplitter.cpp",
Adam Lesinski93190b72017-11-03 15:20:17 -0700134 "text/Printer.cpp",
Adam Lesinski66ea8402017-06-28 11:44:11 -0700135 "text/Unicode.cpp",
136 "text/Utf8Iterator.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500137 "util/Files.cpp",
138 "util/Util.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500139 "Debug.cpp",
140 "DominatorTree.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500141 "java/AnnotationProcessor.cpp",
142 "java/ClassDefinition.cpp",
143 "java/JavaClassGenerator.cpp",
144 "java/ManifestClassGenerator.cpp",
145 "java/ProguardRules.cpp",
Pierre Lecesneff759e62017-02-01 00:29:25 +0000146 "LoadedApk.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500147 "Resource.cpp",
148 "ResourceParser.cpp",
149 "ResourceTable.cpp",
150 "ResourceUtils.cpp",
151 "ResourceValues.cpp",
152 "SdkConstants.cpp",
Fabien Sanglard2d34e762019-02-21 15:13:29 -0800153 "trace/TraceBuffer.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500154 "xml/XmlActionExecutor.cpp",
155 "xml/XmlDom.cpp",
156 "xml/XmlPullParser.cpp",
157 "xml/XmlUtil.cpp",
Iurii Makhno85875a82022-04-26 15:30:01 +0000158 "ApkInfo.proto",
Adam Lesinskib58c3ef2017-09-12 17:39:52 -0700159 "Configuration.proto",
Adam Lesinski4ffea042017-08-10 15:37:28 -0700160 "Resources.proto",
Donald Chaic0009622020-04-22 19:19:22 -0700161 "ResourceMetadata.proto",
Adam Lesinski4ffea042017-08-10 15:37:28 -0700162 "ResourcesInternal.proto",
Ryan Mitchellefcdb952021-04-14 17:31:37 -0700163 "ValueTransformer.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500164 ],
165 proto: {
166 export_proto_headers: true,
Liz Kammerba0a32c2022-03-22 13:39:40 -0400167 type: "full",
Fabien Sanglard19160202017-01-12 14:24:31 -0500168 },
Dan Willemsen7544b9c2017-09-08 22:44:51 -0700169 defaults: ["aapt2_defaults"],
Fabien Sanglard19160202017-01-12 14:24:31 -0500170}
171
172// ==========================================================
Fabien Sanglard19160202017-01-12 14:24:31 -0500173// Build the host tests: aapt2_tests
174// ==========================================================
175cc_test_host {
176 name: "aapt2_tests",
Adam Lesinskibab4ef52017-06-01 15:22:57 -0700177 srcs: [
Adam Lesinskiefeb7af2017-08-02 14:57:43 -0700178 "test/Builders.cpp",
Adam Lesinskibab4ef52017-06-01 15:22:57 -0700179 "test/Common.cpp",
Ryan Mitchell479fa392019-01-02 17:15:39 -0800180 "test/Fixture.cpp",
Adam Lesinskibab4ef52017-06-01 15:22:57 -0700181 "**/*_test.cpp",
Donald Chaib8f078c2017-10-18 23:51:18 -0700182 ] + toolSources,
Shane Farmer74cdea32017-05-12 16:22:36 -0700183 static_libs: [
184 "libaapt2",
185 "libgmock",
186 ],
Dan Willemsen7544b9c2017-09-08 22:44:51 -0700187 defaults: ["aapt2_defaults"],
Ryan Mitchell479fa392019-01-02 17:15:39 -0800188 data: [
Ryan Mitchell87d30dd2021-03-30 08:22:39 -0700189 "integration-tests/CompileTest/**/*",
190 "integration-tests/CommandTests/**/*",
191 "integration-tests/ConvertTest/**/*",
Iurii Makhnodcead622022-04-13 18:00:03 +0000192 "integration-tests/DumpTest/**/*",
Jeremy Meyer16c83af2024-07-26 16:21:49 -0700193 ":resource-flagging-test-app-apk",
Jeremy Meyer423c0f52024-08-02 12:06:54 -0700194 ":resource-flagging-test-app-r-java",
Ryan Mitchell479fa392019-01-02 17:15:39 -0800195 ],
Fabien Sanglard19160202017-01-12 14:24:31 -0500196}
197
198// ==========================================================
199// Build the host executable: aapt2
200// ==========================================================
201cc_binary_host {
202 name: "aapt2",
203 srcs: ["Main.cpp"] + toolSources,
Donald Chai2ee7cc62019-05-11 02:37:23 -0700204 use_version_lib: true,
Fabien Sanglard19160202017-01-12 14:24:31 -0500205 static_libs: ["libaapt2"],
Dan Willemsen7544b9c2017-09-08 22:44:51 -0700206 defaults: ["aapt2_defaults"],
Ryan Mitchell655b9362020-04-06 16:16:14 -0700207 dist: {
208 targets: ["aapt2_artifacts"],
209 },
Fabien Sanglard19160202017-01-12 14:24:31 -0500210}
Colin Cross0b28a922019-03-18 22:18:27 -0700211
212// ==========================================================
213// Dist the protos
214// ==========================================================
215genrule {
216 name: "aapt2-protos",
217 tools: [":soong_zip"],
218 srcs: [
Iurii Makhno2d3b2ae2023-10-06 15:30:58 +0000219 "ApkInfo.proto",
Colin Cross0b28a922019-03-18 22:18:27 -0700220 "Configuration.proto",
Izabela Orlowskaf53b67c2019-11-07 11:53:54 +0000221 "ResourcesInternal.proto",
Donald Chaic0009622020-04-22 19:19:22 -0700222 "ResourceMetadata.proto",
Colin Cross0b28a922019-03-18 22:18:27 -0700223 "Resources.proto",
224 ],
225 out: ["aapt2-protos.zip"],
226 cmd: "mkdir $(genDir)/protos && " +
227 "cp $(in) $(genDir)/protos && " +
228 "$(location :soong_zip) -o $(out) -C $(genDir)/protos -D $(genDir)/protos",
229 dist: {
Ryan Mitchell87d30dd2021-03-30 08:22:39 -0700230 targets: [
231 "sdk_repo",
232 "aapt2_artifacts",
233 ],
Colin Cross0b28a922019-03-18 22:18:27 -0700234 },
235}