• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//
2// Copyright (C) 2017 The Android Open Source Project
3//
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
17package {
18    default_applicable_licenses: ["Android-Apache-2.0"],
19}
20
21toolSources = [
22    "cmd/ApkInfo.cpp",
23    "cmd/Command.cpp",
24    "cmd/Compile.cpp",
25    "cmd/Convert.cpp",
26    "cmd/Diff.cpp",
27    "cmd/Dump.cpp",
28    "cmd/Link.cpp",
29    "cmd/Optimize.cpp",
30    "cmd/Util.cpp",
31]
32
33cc_defaults {
34    name: "aapt2_defaults",
35    cpp_std: "gnu++2b",
36    cflags: [
37        "-Wall",
38        "-Werror",
39        "-Wno-unused-parameter",
40    ],
41    cppflags: [
42        "-Wno-missing-field-initializers",
43        "-fno-exceptions",
44        "-fno-rtti",
45        "-Wno-deprecated-declarations",
46    ],
47    target: {
48        windows: {
49            compile_multilib: "64",
50            enabled: true,
51            cflags: ["-Wno-maybe-uninitialized"],
52            ldflags: ["-static"],
53        },
54        darwin: {
55            cflags: ["-D_DARWIN_UNLIMITED_STREAMS"],
56        },
57    },
58    header_libs: ["jni_headers"],
59    static_libs: [
60        "libandroidfw",
61        "libutils",
62        "liblog",
63        "libcutils",
64        "libexpat",
65        "libziparchive",
66        "libpng",
67        "libbase",
68        "libprotobuf-cpp-full",
69        "libz",
70        "libbuildversion",
71        "libidmap2_policies",
72    ],
73    stl: "libc++_static",
74}
75
76// ==========================================================
77// NOTE: Do not add any shared libraries.
78// AAPT2 is built to run on many environments
79// that may not have the required dependencies.
80// ==========================================================
81
82// ==========================================================
83// Build the host static library: aapt2
84// ==========================================================
85cc_library_host_static {
86    name: "libaapt2",
87    srcs: [
88        "compile/IdAssigner.cpp",
89        "compile/InlineXmlFormatParser.cpp",
90        "compile/PseudolocaleGenerator.cpp",
91        "compile/Pseudolocalizer.cpp",
92        "compile/XmlIdCollector.cpp",
93        "configuration/ConfigurationParser.cpp",
94        "dump/DumpManifest.cpp",
95        "filter/AbiFilter.cpp",
96        "filter/ConfigFilter.cpp",
97        "format/Archive.cpp",
98        "format/Container.cpp",
99        "format/binary/BinaryResourceParser.cpp",
100        "format/binary/ResChunkPullParser.cpp",
101        "format/binary/ResEntryWriter.cpp",
102        "format/binary/TableFlattener.cpp",
103        "format/binary/XmlFlattener.cpp",
104        "format/proto/ProtoDeserialize.cpp",
105        "format/proto/ProtoSerialize.cpp",
106        "io/File.cpp",
107        "io/FileSystem.cpp",
108        "io/StringStream.cpp",
109        "io/Util.cpp",
110        "io/ZipArchive.cpp",
111        "link/AutoVersioner.cpp",
112        "link/FeatureFlagsFilter.cpp",
113        "link/ManifestFixer.cpp",
114        "link/NoDefaultResourceRemover.cpp",
115        "link/PrivateAttributeMover.cpp",
116        "link/ReferenceLinker.cpp",
117        "link/ResourceExcluder.cpp",
118        "link/TableMerger.cpp",
119        "link/XmlCompatVersioner.cpp",
120        "link/XmlNamespaceRemover.cpp",
121        "link/XmlReferenceLinker.cpp",
122        "optimize/MultiApkGenerator.cpp",
123        "optimize/ResourceDeduper.cpp",
124        "optimize/ResourceFilter.cpp",
125        "optimize/Obfuscator.cpp",
126        "optimize/VersionCollapser.cpp",
127        "process/ProductFilter.cpp",
128        "process/SymbolTable.cpp",
129        "split/TableSplitter.cpp",
130        "text/Printer.cpp",
131        "text/Unicode.cpp",
132        "text/Utf8Iterator.cpp",
133        "util/Files.cpp",
134        "util/Util.cpp",
135        "Debug.cpp",
136        "DominatorTree.cpp",
137        "java/AnnotationProcessor.cpp",
138        "java/ClassDefinition.cpp",
139        "java/JavaClassGenerator.cpp",
140        "java/ManifestClassGenerator.cpp",
141        "java/ProguardRules.cpp",
142        "LoadedApk.cpp",
143        "Resource.cpp",
144        "ResourceParser.cpp",
145        "ResourceTable.cpp",
146        "ResourceUtils.cpp",
147        "ResourceValues.cpp",
148        "SdkConstants.cpp",
149        "trace/TraceBuffer.cpp",
150        "xml/XmlActionExecutor.cpp",
151        "xml/XmlDom.cpp",
152        "xml/XmlPullParser.cpp",
153        "xml/XmlUtil.cpp",
154        "ApkInfo.proto",
155        "Configuration.proto",
156        "Resources.proto",
157        "ResourceMetadata.proto",
158        "ResourcesInternal.proto",
159        "ValueTransformer.cpp",
160    ],
161    proto: {
162        export_proto_headers: true,
163        type: "full",
164    },
165    defaults: ["aapt2_defaults"],
166}
167
168// ==========================================================
169// Build the host tests: aapt2_tests
170// ==========================================================
171cc_test_host {
172    name: "aapt2_tests",
173    srcs: [
174        "test/Builders.cpp",
175        "test/Common.cpp",
176        "test/Fixture.cpp",
177        "**/*_test.cpp",
178    ] + toolSources,
179    static_libs: [
180        "libaapt2",
181        "libgmock",
182    ],
183    defaults: ["aapt2_defaults"],
184    data: [
185        "integration-tests/CompileTest/**/*",
186        "integration-tests/CommandTests/**/*",
187        "integration-tests/ConvertTest/**/*",
188        "integration-tests/DumpTest/**/*",
189    ],
190}
191
192// ==========================================================
193// Build the host executable: aapt2
194// ==========================================================
195cc_binary_host {
196    name: "aapt2",
197    srcs: ["Main.cpp"] + toolSources,
198    use_version_lib: true,
199    static_libs: ["libaapt2"],
200    defaults: ["aapt2_defaults"],
201    dist: {
202        targets: ["aapt2_artifacts"],
203    },
204}
205
206// ==========================================================
207// Dist the protos
208// ==========================================================
209genrule {
210    name: "aapt2-protos",
211    tools: [":soong_zip"],
212    srcs: [
213        "ApkInfo.proto",
214        "Configuration.proto",
215        "ResourcesInternal.proto",
216        "ResourceMetadata.proto",
217        "Resources.proto",
218    ],
219    out: ["aapt2-protos.zip"],
220    cmd: "mkdir $(genDir)/protos && " +
221        "cp $(in) $(genDir)/protos && " +
222        "$(location :soong_zip) -o $(out) -C $(genDir)/protos -D $(genDir)/protos",
223    dist: {
224        targets: [
225            "sdk_repo",
226            "aapt2_artifacts",
227        ],
228    },
229}
230