blob: bfb32854a374e1eecdfd2091f802eb5d6c0c1e01 [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",
Fabien Sanglard19160202017-01-12 14:24:31 -050039 cflags: [
40 "-Wall",
41 "-Werror",
42 "-Wno-unused-parameter",
43 ],
44 cppflags: [
45 "-Wno-missing-field-initializers",
46 "-fno-exceptions",
47 "-fno-rtti",
48 ],
49 target: {
50 windows: {
51 enabled: true,
52 cflags: ["-Wno-maybe-uninitialized"],
Ryan Mitchell319fc022019-05-06 11:54:41 -070053 ldflags: ["-static"],
Fabien Sanglard19160202017-01-12 14:24:31 -050054 },
55 darwin: {
56 cflags: ["-D_DARWIN_UNLIMITED_STREAMS"],
Fabien Sanglard19160202017-01-12 14:24:31 -050057 },
58 },
Orion Hodson63f06b72020-04-03 09:42:03 +010059 header_libs: ["jni_headers"],
Fabien Sanglard19160202017-01-12 14:24:31 -050060 static_libs: [
61 "libandroidfw",
62 "libutils",
63 "liblog",
64 "libcutils",
65 "libexpat",
66 "libziparchive",
67 "libpng",
68 "libbase",
Ryan Mitchell22ead1c2019-05-20 16:54:48 -070069 "libprotobuf-cpp-full",
Dan Willemsen85aee732017-09-08 21:26:31 -070070 "libz",
Ryan Mitchell34039b22019-03-18 08:57:47 -070071 "libbuildversion",
Winson62ac8b52019-12-04 08:36:48 -080072 "libidmap2_policies",
Fabien Sanglard19160202017-01-12 14:24:31 -050073 ],
Ryan Mitchell81bae2d2019-01-04 13:48:04 -080074 stl: "libc++_static",
Fabien Sanglard19160202017-01-12 14:24:31 -050075}
76
77// ==========================================================
78// NOTE: Do not add any shared libraries.
79// AAPT2 is built to run on many environments
80// that may not have the required dependencies.
81// ==========================================================
82
83// ==========================================================
84// Build the host static library: aapt2
85// ==========================================================
86cc_library_host_static {
87 name: "libaapt2",
88 srcs: [
89 "compile/IdAssigner.cpp",
90 "compile/InlineXmlFormatParser.cpp",
91 "compile/NinePatch.cpp",
92 "compile/Png.cpp",
93 "compile/PngChunkFilter.cpp",
94 "compile/PngCrunch.cpp",
95 "compile/PseudolocaleGenerator.cpp",
96 "compile/Pseudolocalizer.cpp",
97 "compile/XmlIdCollector.cpp",
Shane Farmer74cdea32017-05-12 16:22:36 -070098 "configuration/ConfigurationParser.cpp",
Ryan Mitchellfc225b22018-08-21 14:52:51 -070099 "dump/DumpManifest.cpp",
Shane Farmer57669432017-06-19 12:52:04 -0700100 "filter/AbiFilter.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500101 "filter/ConfigFilter.cpp",
Adam Lesinski46708052017-09-29 14:49:15 -0700102 "format/Archive.cpp",
Adam Lesinski00451162017-10-03 07:44:08 -0700103 "format/Container.cpp",
Adam Lesinski46708052017-09-29 14:49:15 -0700104 "format/binary/BinaryResourceParser.cpp",
105 "format/binary/ResChunkPullParser.cpp",
106 "format/binary/TableFlattener.cpp",
107 "format/binary/XmlFlattener.cpp",
108 "format/proto/ProtoDeserialize.cpp",
109 "format/proto/ProtoSerialize.cpp",
Adam Lesinski00451162017-10-03 07:44:08 -0700110 "io/BigBufferStream.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500111 "io/File.cpp",
Adam Lesinski00451162017-10-03 07:44:08 -0700112 "io/FileStream.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500113 "io/FileSystem.cpp",
Adam Lesinski00451162017-10-03 07:44:08 -0700114 "io/StringStream.cpp",
Adam Lesinskid0f492d2017-04-03 18:12:45 -0700115 "io/Util.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500116 "io/ZipArchive.cpp",
117 "link/AutoVersioner.cpp",
118 "link/ManifestFixer.cpp",
Adam Lesinski34a16872018-02-23 16:18:10 -0800119 "link/NoDefaultResourceRemover.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500120 "link/ProductFilter.cpp",
121 "link/PrivateAttributeMover.cpp",
122 "link/ReferenceLinker.cpp",
Winson3c918b82019-01-25 14:25:37 -0800123 "link/ResourceExcluder.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500124 "link/TableMerger.cpp",
Adam Lesinskic744ae82017-05-17 19:28:38 -0700125 "link/XmlCompatVersioner.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500126 "link/XmlNamespaceRemover.cpp",
127 "link/XmlReferenceLinker.cpp",
Shane Farmer0a5b2012017-06-22 12:24:12 -0700128 "optimize/MultiApkGenerator.cpp",
Adam Lesinskid48944a2017-02-21 14:22:30 -0800129 "optimize/ResourceDeduper.cpp",
Mohamed Heikald3c5fb62018-01-12 11:37:26 -0500130 "optimize/ResourceFilter.cpp",
Mohamed Heikalc7694032018-11-07 16:49:02 -0500131 "optimize/ResourcePathShortener.cpp",
Adam Lesinskid48944a2017-02-21 14:22:30 -0800132 "optimize/VersionCollapser.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/BigBuffer.cpp",
139 "util/Files.cpp",
140 "util/Util.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500141 "Debug.cpp",
142 "DominatorTree.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500143 "java/AnnotationProcessor.cpp",
144 "java/ClassDefinition.cpp",
145 "java/JavaClassGenerator.cpp",
146 "java/ManifestClassGenerator.cpp",
147 "java/ProguardRules.cpp",
Pierre Lecesneff759e62017-02-01 00:29:25 +0000148 "LoadedApk.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500149 "Resource.cpp",
150 "ResourceParser.cpp",
151 "ResourceTable.cpp",
152 "ResourceUtils.cpp",
153 "ResourceValues.cpp",
154 "SdkConstants.cpp",
155 "StringPool.cpp",
Fabien Sanglard2d34e762019-02-21 15:13:29 -0800156 "trace/TraceBuffer.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500157 "xml/XmlActionExecutor.cpp",
158 "xml/XmlDom.cpp",
159 "xml/XmlPullParser.cpp",
160 "xml/XmlUtil.cpp",
Adam Lesinskib58c3ef2017-09-12 17:39:52 -0700161 "Configuration.proto",
Adam Lesinski4ffea042017-08-10 15:37:28 -0700162 "Resources.proto",
163 "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/**/*",
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 Mitchell87d30dd2021-03-30 08:22:39 -0700226 targets: [
227 "sdk_repo",
228 "aapt2_artifacts",
229 ],
Colin Cross0b28a922019-03-18 22:18:27 -0700230 },
231}