blob: 46ae2ecd9406971abe74d7301ec3cc74c5c64dea [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
17toolSources = [
Ryan Mitchell833a1a62018-07-10 13:51:36 -070018 "cmd/Command.cpp",
Adam Lesinskid0f492d2017-04-03 18:12:45 -070019 "cmd/Compile.cpp",
Adam Lesinski8780eb62017-10-31 17:44:39 -070020 "cmd/Convert.cpp",
Adam Lesinskid0f492d2017-04-03 18:12:45 -070021 "cmd/Diff.cpp",
22 "cmd/Dump.cpp",
23 "cmd/Link.cpp",
24 "cmd/Optimize.cpp",
25 "cmd/Util.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -050026]
27
28cc_defaults {
Dan Willemsen7544b9c2017-09-08 22:44:51 -070029 name: "aapt2_defaults",
Fabien Sanglard19160202017-01-12 14:24:31 -050030 cflags: [
31 "-Wall",
32 "-Werror",
33 "-Wno-unused-parameter",
34 ],
35 cppflags: [
36 "-Wno-missing-field-initializers",
37 "-fno-exceptions",
38 "-fno-rtti",
39 ],
40 target: {
41 windows: {
42 enabled: true,
43 cflags: ["-Wno-maybe-uninitialized"],
Ryan Mitchell319fc022019-05-06 11:54:41 -070044 ldflags: ["-static"],
Fabien Sanglard19160202017-01-12 14:24:31 -050045 },
46 darwin: {
47 cflags: ["-D_DARWIN_UNLIMITED_STREAMS"],
Fabien Sanglard19160202017-01-12 14:24:31 -050048 },
49 },
Orion Hodson63f06b72020-04-03 09:42:03 +010050 header_libs: ["jni_headers"],
Fabien Sanglard19160202017-01-12 14:24:31 -050051 static_libs: [
52 "libandroidfw",
53 "libutils",
54 "liblog",
55 "libcutils",
56 "libexpat",
57 "libziparchive",
58 "libpng",
59 "libbase",
Ryan Mitchell22ead1c2019-05-20 16:54:48 -070060 "libprotobuf-cpp-full",
Dan Willemsen85aee732017-09-08 21:26:31 -070061 "libz",
Ryan Mitchell34039b22019-03-18 08:57:47 -070062 "libbuildversion",
Winson62ac8b52019-12-04 08:36:48 -080063 "libidmap2_policies",
Fabien Sanglard19160202017-01-12 14:24:31 -050064 ],
Ryan Mitchell81bae2d2019-01-04 13:48:04 -080065 stl: "libc++_static",
Fabien Sanglard19160202017-01-12 14:24:31 -050066 group_static_libs: true,
67}
68
69// ==========================================================
70// NOTE: Do not add any shared libraries.
71// AAPT2 is built to run on many environments
72// that may not have the required dependencies.
73// ==========================================================
74
75// ==========================================================
76// Build the host static library: aapt2
77// ==========================================================
78cc_library_host_static {
79 name: "libaapt2",
80 srcs: [
81 "compile/IdAssigner.cpp",
82 "compile/InlineXmlFormatParser.cpp",
83 "compile/NinePatch.cpp",
84 "compile/Png.cpp",
85 "compile/PngChunkFilter.cpp",
86 "compile/PngCrunch.cpp",
87 "compile/PseudolocaleGenerator.cpp",
88 "compile/Pseudolocalizer.cpp",
89 "compile/XmlIdCollector.cpp",
Shane Farmer74cdea32017-05-12 16:22:36 -070090 "configuration/ConfigurationParser.cpp",
Ryan Mitchellfc225b22018-08-21 14:52:51 -070091 "dump/DumpManifest.cpp",
Shane Farmer57669432017-06-19 12:52:04 -070092 "filter/AbiFilter.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -050093 "filter/ConfigFilter.cpp",
Adam Lesinski46708052017-09-29 14:49:15 -070094 "format/Archive.cpp",
Adam Lesinski00451162017-10-03 07:44:08 -070095 "format/Container.cpp",
Adam Lesinski46708052017-09-29 14:49:15 -070096 "format/binary/BinaryResourceParser.cpp",
97 "format/binary/ResChunkPullParser.cpp",
98 "format/binary/TableFlattener.cpp",
99 "format/binary/XmlFlattener.cpp",
100 "format/proto/ProtoDeserialize.cpp",
101 "format/proto/ProtoSerialize.cpp",
Adam Lesinski00451162017-10-03 07:44:08 -0700102 "io/BigBufferStream.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500103 "io/File.cpp",
Adam Lesinski00451162017-10-03 07:44:08 -0700104 "io/FileStream.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500105 "io/FileSystem.cpp",
Adam Lesinski00451162017-10-03 07:44:08 -0700106 "io/StringStream.cpp",
Adam Lesinskid0f492d2017-04-03 18:12:45 -0700107 "io/Util.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500108 "io/ZipArchive.cpp",
109 "link/AutoVersioner.cpp",
110 "link/ManifestFixer.cpp",
Adam Lesinski34a16872018-02-23 16:18:10 -0800111 "link/NoDefaultResourceRemover.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500112 "link/ProductFilter.cpp",
113 "link/PrivateAttributeMover.cpp",
114 "link/ReferenceLinker.cpp",
Winson3c918b82019-01-25 14:25:37 -0800115 "link/ResourceExcluder.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500116 "link/TableMerger.cpp",
Adam Lesinskic744ae82017-05-17 19:28:38 -0700117 "link/XmlCompatVersioner.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500118 "link/XmlNamespaceRemover.cpp",
119 "link/XmlReferenceLinker.cpp",
Shane Farmer0a5b2012017-06-22 12:24:12 -0700120 "optimize/MultiApkGenerator.cpp",
Adam Lesinskid48944a2017-02-21 14:22:30 -0800121 "optimize/ResourceDeduper.cpp",
Mohamed Heikald3c5fb62018-01-12 11:37:26 -0500122 "optimize/ResourceFilter.cpp",
Mohamed Heikalc7694032018-11-07 16:49:02 -0500123 "optimize/ResourcePathShortener.cpp",
Adam Lesinskid48944a2017-02-21 14:22:30 -0800124 "optimize/VersionCollapser.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500125 "process/SymbolTable.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500126 "split/TableSplitter.cpp",
Adam Lesinski93190b72017-11-03 15:20:17 -0700127 "text/Printer.cpp",
Adam Lesinski66ea8402017-06-28 11:44:11 -0700128 "text/Unicode.cpp",
129 "text/Utf8Iterator.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500130 "util/BigBuffer.cpp",
131 "util/Files.cpp",
132 "util/Util.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500133 "Debug.cpp",
134 "DominatorTree.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500135 "java/AnnotationProcessor.cpp",
136 "java/ClassDefinition.cpp",
137 "java/JavaClassGenerator.cpp",
138 "java/ManifestClassGenerator.cpp",
139 "java/ProguardRules.cpp",
Pierre Lecesneff759e62017-02-01 00:29:25 +0000140 "LoadedApk.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500141 "Resource.cpp",
142 "ResourceParser.cpp",
143 "ResourceTable.cpp",
144 "ResourceUtils.cpp",
145 "ResourceValues.cpp",
146 "SdkConstants.cpp",
147 "StringPool.cpp",
Fabien Sanglard2d34e762019-02-21 15:13:29 -0800148 "trace/TraceBuffer.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500149 "xml/XmlActionExecutor.cpp",
150 "xml/XmlDom.cpp",
151 "xml/XmlPullParser.cpp",
152 "xml/XmlUtil.cpp",
Adam Lesinskib58c3ef2017-09-12 17:39:52 -0700153 "Configuration.proto",
Adam Lesinski4ffea042017-08-10 15:37:28 -0700154 "Resources.proto",
155 "ResourcesInternal.proto",
Fabien Sanglard19160202017-01-12 14:24:31 -0500156 ],
157 proto: {
158 export_proto_headers: true,
159 },
Dan Willemsen7544b9c2017-09-08 22:44:51 -0700160 defaults: ["aapt2_defaults"],
Fabien Sanglard19160202017-01-12 14:24:31 -0500161}
162
163// ==========================================================
164// Build the host shared library: aapt2_jni
165// ==========================================================
166cc_library_host_shared {
167 name: "libaapt2_jni",
168 srcs: toolSources + ["jni/aapt2_jni.cpp"],
169 static_libs: ["libaapt2"],
Dan Willemsen7544b9c2017-09-08 22:44:51 -0700170 defaults: ["aapt2_defaults"],
Fabien Sanglard19160202017-01-12 14:24:31 -0500171}
172
173// ==========================================================
174// 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: [
190 "integration-tests/CompileTest/**/*",
Winsonf54c9a12019-01-23 12:39:40 -0800191 "integration-tests/CommandTests/**/*",
192 "integration-tests/ConvertTest/**/*"
Ryan Mitchell479fa392019-01-02 17:15:39 -0800193 ],
Fabien Sanglard19160202017-01-12 14:24:31 -0500194}
195
196// ==========================================================
197// Build the host executable: aapt2
198// ==========================================================
199cc_binary_host {
200 name: "aapt2",
201 srcs: ["Main.cpp"] + toolSources,
Donald Chai2ee7cc62019-05-11 02:37:23 -0700202 use_version_lib: true,
Fabien Sanglard19160202017-01-12 14:24:31 -0500203 static_libs: ["libaapt2"],
Dan Willemsen7544b9c2017-09-08 22:44:51 -0700204 defaults: ["aapt2_defaults"],
Ryan Mitchell655b9362020-04-06 16:16:14 -0700205 dist: {
206 targets: ["aapt2_artifacts"],
207 },
Fabien Sanglard19160202017-01-12 14:24:31 -0500208}
Colin Cross0b28a922019-03-18 22:18:27 -0700209
210// ==========================================================
211// Dist the protos
212// ==========================================================
213genrule {
214 name: "aapt2-protos",
215 tools: [":soong_zip"],
216 srcs: [
217 "Configuration.proto",
Izabela Orlowskaf53b67c2019-11-07 11:53:54 +0000218 "ResourcesInternal.proto",
Colin Cross0b28a922019-03-18 22:18:27 -0700219 "Resources.proto",
220 ],
221 out: ["aapt2-protos.zip"],
222 cmd: "mkdir $(genDir)/protos && " +
223 "cp $(in) $(genDir)/protos && " +
224 "$(location :soong_zip) -o $(out) -C $(genDir)/protos -D $(genDir)/protos",
225 dist: {
Ryan Mitchell655b9362020-04-06 16:16:14 -0700226 targets: ["sdk_repo", "aapt2_artifacts"],
Colin Cross0b28a922019-03-18 22:18:27 -0700227 },
228}