blob: 3dc550e855eca1b1407acd0bb092104a13e51738 [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 {
18 // See: http://go/android-license-faq
19 // A large-scale-change added 'default_applicable_licenses' to import
20 // all of the 'license_kinds' from "frameworks_base_license"
21 // to get the below license kinds:
22 // SPDX-license-identifier-Apache-2.0
23 default_applicable_licenses: ["frameworks_base_license"],
24}
25
Fabien Sanglard19160202017-01-12 14:24:31 -050026toolSources = [
Ryan Mitchell833a1a62018-07-10 13:51:36 -070027 "cmd/Command.cpp",
Adam Lesinskid0f492d2017-04-03 18:12:45 -070028 "cmd/Compile.cpp",
Adam Lesinski8780eb62017-10-31 17:44:39 -070029 "cmd/Convert.cpp",
Adam Lesinskid0f492d2017-04-03 18:12:45 -070030 "cmd/Diff.cpp",
31 "cmd/Dump.cpp",
32 "cmd/Link.cpp",
33 "cmd/Optimize.cpp",
34 "cmd/Util.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -050035]
36
37cc_defaults {
Dan Willemsen7544b9c2017-09-08 22:44:51 -070038 name: "aapt2_defaults",
Yurii Zubrytskyiba6f8a32022-02-16 17:00:42 -080039 cpp_std: "gnu++2b",
Fabien Sanglard19160202017-01-12 14:24:31 -050040 cflags: [
41 "-Wall",
42 "-Werror",
43 "-Wno-unused-parameter",
44 ],
45 cppflags: [
46 "-Wno-missing-field-initializers",
47 "-fno-exceptions",
48 "-fno-rtti",
49 ],
50 target: {
51 windows: {
52 enabled: true,
53 cflags: ["-Wno-maybe-uninitialized"],
Ryan Mitchell319fc022019-05-06 11:54:41 -070054 ldflags: ["-static"],
Fabien Sanglard19160202017-01-12 14:24:31 -050055 },
56 darwin: {
57 cflags: ["-D_DARWIN_UNLIMITED_STREAMS"],
Fabien Sanglard19160202017-01-12 14:24:31 -050058 },
59 },
Orion Hodson63f06b72020-04-03 09:42:03 +010060 header_libs: ["jni_headers"],
Fabien Sanglard19160202017-01-12 14:24:31 -050061 static_libs: [
62 "libandroidfw",
63 "libutils",
64 "liblog",
65 "libcutils",
66 "libexpat",
67 "libziparchive",
68 "libpng",
69 "libbase",
Ryan Mitchell22ead1c2019-05-20 16:54:48 -070070 "libprotobuf-cpp-full",
Dan Willemsen85aee732017-09-08 21:26:31 -070071 "libz",
Ryan Mitchell34039b22019-03-18 08:57:47 -070072 "libbuildversion",
Winson62ac8b52019-12-04 08:36:48 -080073 "libidmap2_policies",
Fabien Sanglard19160202017-01-12 14:24:31 -050074 ],
Ryan Mitchell81bae2d2019-01-04 13:48:04 -080075 stl: "libc++_static",
Fabien Sanglard19160202017-01-12 14:24:31 -050076}
77
78// ==========================================================
79// NOTE: Do not add any shared libraries.
80// AAPT2 is built to run on many environments
81// that may not have the required dependencies.
82// ==========================================================
83
84// ==========================================================
85// Build the host static library: aapt2
86// ==========================================================
87cc_library_host_static {
88 name: "libaapt2",
89 srcs: [
90 "compile/IdAssigner.cpp",
91 "compile/InlineXmlFormatParser.cpp",
92 "compile/NinePatch.cpp",
93 "compile/Png.cpp",
94 "compile/PngChunkFilter.cpp",
95 "compile/PngCrunch.cpp",
96 "compile/PseudolocaleGenerator.cpp",
97 "compile/Pseudolocalizer.cpp",
98 "compile/XmlIdCollector.cpp",
Shane Farmer74cdea32017-05-12 16:22:36 -070099 "configuration/ConfigurationParser.cpp",
Ryan Mitchellfc225b22018-08-21 14:52:51 -0700100 "dump/DumpManifest.cpp",
Shane Farmer57669432017-06-19 12:52:04 -0700101 "filter/AbiFilter.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500102 "filter/ConfigFilter.cpp",
Adam Lesinski46708052017-09-29 14:49:15 -0700103 "format/Archive.cpp",
Adam Lesinski00451162017-10-03 07:44:08 -0700104 "format/Container.cpp",
Adam Lesinski46708052017-09-29 14:49:15 -0700105 "format/binary/BinaryResourceParser.cpp",
106 "format/binary/ResChunkPullParser.cpp",
107 "format/binary/TableFlattener.cpp",
108 "format/binary/XmlFlattener.cpp",
109 "format/proto/ProtoDeserialize.cpp",
110 "format/proto/ProtoSerialize.cpp",
Adam Lesinski00451162017-10-03 07:44:08 -0700111 "io/BigBufferStream.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500112 "io/File.cpp",
Adam Lesinski00451162017-10-03 07:44:08 -0700113 "io/FileStream.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500114 "io/FileSystem.cpp",
Adam Lesinski00451162017-10-03 07:44:08 -0700115 "io/StringStream.cpp",
Adam Lesinskid0f492d2017-04-03 18:12:45 -0700116 "io/Util.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500117 "io/ZipArchive.cpp",
118 "link/AutoVersioner.cpp",
119 "link/ManifestFixer.cpp",
Adam Lesinski34a16872018-02-23 16:18:10 -0800120 "link/NoDefaultResourceRemover.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500121 "link/ProductFilter.cpp",
122 "link/PrivateAttributeMover.cpp",
123 "link/ReferenceLinker.cpp",
Winson3c918b82019-01-25 14:25:37 -0800124 "link/ResourceExcluder.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500125 "link/TableMerger.cpp",
Adam Lesinskic744ae82017-05-17 19:28:38 -0700126 "link/XmlCompatVersioner.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500127 "link/XmlNamespaceRemover.cpp",
128 "link/XmlReferenceLinker.cpp",
Shane Farmer0a5b2012017-06-22 12:24:12 -0700129 "optimize/MultiApkGenerator.cpp",
Adam Lesinskid48944a2017-02-21 14:22:30 -0800130 "optimize/ResourceDeduper.cpp",
Mohamed Heikald3c5fb62018-01-12 11:37:26 -0500131 "optimize/ResourceFilter.cpp",
Mohamed Heikalc7694032018-11-07 16:49:02 -0500132 "optimize/ResourcePathShortener.cpp",
Adam Lesinskid48944a2017-02-21 14:22:30 -0800133 "optimize/VersionCollapser.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500134 "process/SymbolTable.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500135 "split/TableSplitter.cpp",
Adam Lesinski93190b72017-11-03 15:20:17 -0700136 "text/Printer.cpp",
Adam Lesinski66ea8402017-06-28 11:44:11 -0700137 "text/Unicode.cpp",
138 "text/Utf8Iterator.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500139 "util/BigBuffer.cpp",
140 "util/Files.cpp",
141 "util/Util.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500142 "Debug.cpp",
143 "DominatorTree.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500144 "java/AnnotationProcessor.cpp",
145 "java/ClassDefinition.cpp",
146 "java/JavaClassGenerator.cpp",
147 "java/ManifestClassGenerator.cpp",
148 "java/ProguardRules.cpp",
Pierre Lecesneff759e62017-02-01 00:29:25 +0000149 "LoadedApk.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500150 "Resource.cpp",
151 "ResourceParser.cpp",
152 "ResourceTable.cpp",
153 "ResourceUtils.cpp",
154 "ResourceValues.cpp",
155 "SdkConstants.cpp",
156 "StringPool.cpp",
Fabien Sanglard2d34e762019-02-21 15:13:29 -0800157 "trace/TraceBuffer.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500158 "xml/XmlActionExecutor.cpp",
159 "xml/XmlDom.cpp",
160 "xml/XmlPullParser.cpp",
161 "xml/XmlUtil.cpp",
Adam Lesinskib58c3ef2017-09-12 17:39:52 -0700162 "Configuration.proto",
Adam Lesinski4ffea042017-08-10 15:37:28 -0700163 "Resources.proto",
164 "ResourcesInternal.proto",
Ryan Mitchellefcdb952021-04-14 17:31:37 -0700165 "ValueTransformer.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500166 ],
167 proto: {
168 export_proto_headers: true,
Liz Kammerba0a32c2022-03-22 13:39:40 -0400169 type: "full",
Fabien Sanglard19160202017-01-12 14:24:31 -0500170 },
Dan Willemsen7544b9c2017-09-08 22:44:51 -0700171 defaults: ["aapt2_defaults"],
Fabien Sanglard19160202017-01-12 14:24:31 -0500172}
173
174// ==========================================================
Fabien Sanglard19160202017-01-12 14:24:31 -0500175// Build the host tests: aapt2_tests
176// ==========================================================
177cc_test_host {
178 name: "aapt2_tests",
Adam Lesinskibab4ef52017-06-01 15:22:57 -0700179 srcs: [
Adam Lesinskiefeb7af2017-08-02 14:57:43 -0700180 "test/Builders.cpp",
Adam Lesinskibab4ef52017-06-01 15:22:57 -0700181 "test/Common.cpp",
Ryan Mitchell479fa392019-01-02 17:15:39 -0800182 "test/Fixture.cpp",
Adam Lesinskibab4ef52017-06-01 15:22:57 -0700183 "**/*_test.cpp",
Donald Chaib8f078c2017-10-18 23:51:18 -0700184 ] + toolSources,
Shane Farmer74cdea32017-05-12 16:22:36 -0700185 static_libs: [
186 "libaapt2",
187 "libgmock",
188 ],
Dan Willemsen7544b9c2017-09-08 22:44:51 -0700189 defaults: ["aapt2_defaults"],
Ryan Mitchell479fa392019-01-02 17:15:39 -0800190 data: [
Ryan Mitchell87d30dd2021-03-30 08:22:39 -0700191 "integration-tests/CompileTest/**/*",
192 "integration-tests/CommandTests/**/*",
193 "integration-tests/ConvertTest/**/*",
Iurii Makhnodcead622022-04-13 18:00:03 +0000194 "integration-tests/DumpTest/**/*",
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: [
219 "Configuration.proto",
Izabela Orlowskaf53b67c2019-11-07 11:53:54 +0000220 "ResourcesInternal.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}