blob: aa337e5f9691cb88da3eefb5a20f880c641546ea [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 = [
Iurii Makhnof2480742022-04-26 14:51:24 +000027 "cmd/ApkInfo.cpp",
Ryan Mitchell833a1a62018-07-10 13:51:36 -070028 "cmd/Command.cpp",
Adam Lesinskid0f492d2017-04-03 18:12:45 -070029 "cmd/Compile.cpp",
Adam Lesinski8780eb62017-10-31 17:44:39 -070030 "cmd/Convert.cpp",
Adam Lesinskid0f492d2017-04-03 18:12:45 -070031 "cmd/Diff.cpp",
32 "cmd/Dump.cpp",
33 "cmd/Link.cpp",
34 "cmd/Optimize.cpp",
35 "cmd/Util.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -050036]
37
38cc_defaults {
Dan Willemsen7544b9c2017-09-08 22:44:51 -070039 name: "aapt2_defaults",
Yurii Zubrytskyiba6f8a32022-02-16 17:00:42 -080040 cpp_std: "gnu++2b",
Fabien Sanglard19160202017-01-12 14:24:31 -050041 cflags: [
42 "-Wall",
43 "-Werror",
44 "-Wno-unused-parameter",
45 ],
46 cppflags: [
47 "-Wno-missing-field-initializers",
48 "-fno-exceptions",
49 "-fno-rtti",
50 ],
51 target: {
52 windows: {
53 enabled: true,
54 cflags: ["-Wno-maybe-uninitialized"],
Ryan Mitchell319fc022019-05-06 11:54:41 -070055 ldflags: ["-static"],
Fabien Sanglard19160202017-01-12 14:24:31 -050056 },
57 darwin: {
58 cflags: ["-D_DARWIN_UNLIMITED_STREAMS"],
Fabien Sanglard19160202017-01-12 14:24:31 -050059 },
60 },
Orion Hodson63f06b72020-04-03 09:42:03 +010061 header_libs: ["jni_headers"],
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",
93 "compile/NinePatch.cpp",
94 "compile/Png.cpp",
95 "compile/PngChunkFilter.cpp",
96 "compile/PngCrunch.cpp",
97 "compile/PseudolocaleGenerator.cpp",
98 "compile/Pseudolocalizer.cpp",
99 "compile/XmlIdCollector.cpp",
Shane Farmer74cdea32017-05-12 16:22:36 -0700100 "configuration/ConfigurationParser.cpp",
Ryan Mitchellfc225b22018-08-21 14:52:51 -0700101 "dump/DumpManifest.cpp",
Shane Farmer57669432017-06-19 12:52:04 -0700102 "filter/AbiFilter.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500103 "filter/ConfigFilter.cpp",
Adam Lesinski46708052017-09-29 14:49:15 -0700104 "format/Archive.cpp",
Adam Lesinski00451162017-10-03 07:44:08 -0700105 "format/Container.cpp",
Adam Lesinski46708052017-09-29 14:49:15 -0700106 "format/binary/BinaryResourceParser.cpp",
107 "format/binary/ResChunkPullParser.cpp",
Iurii Makhnocf844a32022-09-29 16:45:51 +0000108 "format/binary/ResEntryWriter.cpp",
Adam Lesinski46708052017-09-29 14:49:15 -0700109 "format/binary/TableFlattener.cpp",
110 "format/binary/XmlFlattener.cpp",
111 "format/proto/ProtoDeserialize.cpp",
112 "format/proto/ProtoSerialize.cpp",
Adam Lesinski00451162017-10-03 07:44:08 -0700113 "io/BigBufferStream.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500114 "io/File.cpp",
Adam Lesinski00451162017-10-03 07:44:08 -0700115 "io/FileStream.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500116 "io/FileSystem.cpp",
Adam Lesinski00451162017-10-03 07:44:08 -0700117 "io/StringStream.cpp",
Adam Lesinskid0f492d2017-04-03 18:12:45 -0700118 "io/Util.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500119 "io/ZipArchive.cpp",
120 "link/AutoVersioner.cpp",
121 "link/ManifestFixer.cpp",
Adam Lesinski34a16872018-02-23 16:18:10 -0800122 "link/NoDefaultResourceRemover.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500123 "link/ProductFilter.cpp",
124 "link/PrivateAttributeMover.cpp",
125 "link/ReferenceLinker.cpp",
Winson3c918b82019-01-25 14:25:37 -0800126 "link/ResourceExcluder.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500127 "link/TableMerger.cpp",
Adam Lesinskic744ae82017-05-17 19:28:38 -0700128 "link/XmlCompatVersioner.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500129 "link/XmlNamespaceRemover.cpp",
130 "link/XmlReferenceLinker.cpp",
Shane Farmer0a5b2012017-06-22 12:24:12 -0700131 "optimize/MultiApkGenerator.cpp",
Adam Lesinskid48944a2017-02-21 14:22:30 -0800132 "optimize/ResourceDeduper.cpp",
Mohamed Heikald3c5fb62018-01-12 11:37:26 -0500133 "optimize/ResourceFilter.cpp",
felkachang4bdd3ac2022-09-13 10:58:49 +0800134 "optimize/Obfuscator.cpp",
Adam Lesinskid48944a2017-02-21 14:22:30 -0800135 "optimize/VersionCollapser.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500136 "process/SymbolTable.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500137 "split/TableSplitter.cpp",
Adam Lesinski93190b72017-11-03 15:20:17 -0700138 "text/Printer.cpp",
Adam Lesinski66ea8402017-06-28 11:44:11 -0700139 "text/Unicode.cpp",
140 "text/Utf8Iterator.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500141 "util/Files.cpp",
142 "util/Util.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500143 "Debug.cpp",
144 "DominatorTree.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500145 "java/AnnotationProcessor.cpp",
146 "java/ClassDefinition.cpp",
147 "java/JavaClassGenerator.cpp",
148 "java/ManifestClassGenerator.cpp",
149 "java/ProguardRules.cpp",
Pierre Lecesneff759e62017-02-01 00:29:25 +0000150 "LoadedApk.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500151 "Resource.cpp",
152 "ResourceParser.cpp",
153 "ResourceTable.cpp",
154 "ResourceUtils.cpp",
155 "ResourceValues.cpp",
156 "SdkConstants.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",
Iurii Makhno85875a82022-04-26 15:30:01 +0000162 "ApkInfo.proto",
Adam Lesinskib58c3ef2017-09-12 17:39:52 -0700163 "Configuration.proto",
Adam Lesinski4ffea042017-08-10 15:37:28 -0700164 "Resources.proto",
Donald Chaic0009622020-04-22 19:19:22 -0700165 "ResourceMetadata.proto",
Adam Lesinski4ffea042017-08-10 15:37:28 -0700166 "ResourcesInternal.proto",
Ryan Mitchellefcdb952021-04-14 17:31:37 -0700167 "ValueTransformer.cpp",
Fabien Sanglard19160202017-01-12 14:24:31 -0500168 ],
169 proto: {
170 export_proto_headers: true,
Liz Kammerba0a32c2022-03-22 13:39:40 -0400171 type: "full",
Fabien Sanglard19160202017-01-12 14:24:31 -0500172 },
Dan Willemsen7544b9c2017-09-08 22:44:51 -0700173 defaults: ["aapt2_defaults"],
Fabien Sanglard19160202017-01-12 14:24:31 -0500174}
175
176// ==========================================================
Fabien Sanglard19160202017-01-12 14:24:31 -0500177// Build the host tests: aapt2_tests
178// ==========================================================
179cc_test_host {
180 name: "aapt2_tests",
Adam Lesinskibab4ef52017-06-01 15:22:57 -0700181 srcs: [
Adam Lesinskiefeb7af2017-08-02 14:57:43 -0700182 "test/Builders.cpp",
Adam Lesinskibab4ef52017-06-01 15:22:57 -0700183 "test/Common.cpp",
Ryan Mitchell479fa392019-01-02 17:15:39 -0800184 "test/Fixture.cpp",
Adam Lesinskibab4ef52017-06-01 15:22:57 -0700185 "**/*_test.cpp",
Donald Chaib8f078c2017-10-18 23:51:18 -0700186 ] + toolSources,
Shane Farmer74cdea32017-05-12 16:22:36 -0700187 static_libs: [
188 "libaapt2",
189 "libgmock",
190 ],
Dan Willemsen7544b9c2017-09-08 22:44:51 -0700191 defaults: ["aapt2_defaults"],
Ryan Mitchell479fa392019-01-02 17:15:39 -0800192 data: [
Ryan Mitchell87d30dd2021-03-30 08:22:39 -0700193 "integration-tests/CompileTest/**/*",
194 "integration-tests/CommandTests/**/*",
195 "integration-tests/ConvertTest/**/*",
Iurii Makhnodcead622022-04-13 18:00:03 +0000196 "integration-tests/DumpTest/**/*",
Ryan Mitchell479fa392019-01-02 17:15:39 -0800197 ],
Fabien Sanglard19160202017-01-12 14:24:31 -0500198}
199
200// ==========================================================
201// Build the host executable: aapt2
202// ==========================================================
203cc_binary_host {
204 name: "aapt2",
205 srcs: ["Main.cpp"] + toolSources,
Donald Chai2ee7cc62019-05-11 02:37:23 -0700206 use_version_lib: true,
Fabien Sanglard19160202017-01-12 14:24:31 -0500207 static_libs: ["libaapt2"],
Dan Willemsen7544b9c2017-09-08 22:44:51 -0700208 defaults: ["aapt2_defaults"],
Ryan Mitchell655b9362020-04-06 16:16:14 -0700209 dist: {
210 targets: ["aapt2_artifacts"],
211 },
Fabien Sanglard19160202017-01-12 14:24:31 -0500212}
Colin Cross0b28a922019-03-18 22:18:27 -0700213
214// ==========================================================
215// Dist the protos
216// ==========================================================
217genrule {
218 name: "aapt2-protos",
219 tools: [":soong_zip"],
220 srcs: [
221 "Configuration.proto",
Izabela Orlowskaf53b67c2019-11-07 11:53:54 +0000222 "ResourcesInternal.proto",
Donald Chaic0009622020-04-22 19:19:22 -0700223 "ResourceMetadata.proto",
Colin Cross0b28a922019-03-18 22:18:27 -0700224 "Resources.proto",
225 ],
226 out: ["aapt2-protos.zip"],
227 cmd: "mkdir $(genDir)/protos && " +
228 "cp $(in) $(genDir)/protos && " +
229 "$(location :soong_zip) -o $(out) -C $(genDir)/protos -D $(genDir)/protos",
230 dist: {
Ryan Mitchell87d30dd2021-03-30 08:22:39 -0700231 targets: [
232 "sdk_repo",
233 "aapt2_artifacts",
234 ],
Colin Cross0b28a922019-03-18 22:18:27 -0700235 },
236}