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 // 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 26toolSources = [ 27 "cmd/Command.cpp", 28 "cmd/Compile.cpp", 29 "cmd/Convert.cpp", 30 "cmd/Diff.cpp", 31 "cmd/Dump.cpp", 32 "cmd/Link.cpp", 33 "cmd/Optimize.cpp", 34 "cmd/Util.cpp", 35] 36 37cc_defaults { 38 name: "aapt2_defaults", 39 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"], 53 ldflags: ["-static"], 54 }, 55 darwin: { 56 cflags: ["-D_DARWIN_UNLIMITED_STREAMS"], 57 }, 58 }, 59 header_libs: ["jni_headers"], 60 static_libs: [ 61 "libandroidfw", 62 "libutils", 63 "liblog", 64 "libcutils", 65 "libexpat", 66 "libziparchive", 67 "libpng", 68 "libbase", 69 "libprotobuf-cpp-full", 70 "libz", 71 "libbuildversion", 72 "libidmap2_policies", 73 ], 74 stl: "libc++_static", 75 group_static_libs: true, 76} 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", 99 "configuration/ConfigurationParser.cpp", 100 "dump/DumpManifest.cpp", 101 "filter/AbiFilter.cpp", 102 "filter/ConfigFilter.cpp", 103 "format/Archive.cpp", 104 "format/Container.cpp", 105 "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", 111 "io/BigBufferStream.cpp", 112 "io/File.cpp", 113 "io/FileStream.cpp", 114 "io/FileSystem.cpp", 115 "io/StringStream.cpp", 116 "io/Util.cpp", 117 "io/ZipArchive.cpp", 118 "link/AutoVersioner.cpp", 119 "link/ManifestFixer.cpp", 120 "link/NoDefaultResourceRemover.cpp", 121 "link/ProductFilter.cpp", 122 "link/PrivateAttributeMover.cpp", 123 "link/ReferenceLinker.cpp", 124 "link/ResourceExcluder.cpp", 125 "link/TableMerger.cpp", 126 "link/XmlCompatVersioner.cpp", 127 "link/XmlNamespaceRemover.cpp", 128 "link/XmlReferenceLinker.cpp", 129 "optimize/MultiApkGenerator.cpp", 130 "optimize/ResourceDeduper.cpp", 131 "optimize/ResourceFilter.cpp", 132 "optimize/ResourcePathShortener.cpp", 133 "optimize/VersionCollapser.cpp", 134 "process/SymbolTable.cpp", 135 "split/TableSplitter.cpp", 136 "text/Printer.cpp", 137 "text/Unicode.cpp", 138 "text/Utf8Iterator.cpp", 139 "util/BigBuffer.cpp", 140 "util/Files.cpp", 141 "util/Util.cpp", 142 "Debug.cpp", 143 "DominatorTree.cpp", 144 "java/AnnotationProcessor.cpp", 145 "java/ClassDefinition.cpp", 146 "java/JavaClassGenerator.cpp", 147 "java/ManifestClassGenerator.cpp", 148 "java/ProguardRules.cpp", 149 "LoadedApk.cpp", 150 "Resource.cpp", 151 "ResourceParser.cpp", 152 "ResourceTable.cpp", 153 "ResourceUtils.cpp", 154 "ResourceValues.cpp", 155 "SdkConstants.cpp", 156 "StringPool.cpp", 157 "trace/TraceBuffer.cpp", 158 "xml/XmlActionExecutor.cpp", 159 "xml/XmlDom.cpp", 160 "xml/XmlPullParser.cpp", 161 "xml/XmlUtil.cpp", 162 "Configuration.proto", 163 "Resources.proto", 164 "ResourcesInternal.proto", 165 "ValueTransformer.cpp", 166 ], 167 proto: { 168 export_proto_headers: true, 169 }, 170 defaults: ["aapt2_defaults"], 171} 172 173// ========================================================== 174// Build the host shared library: aapt2_jni 175// ========================================================== 176cc_library_host_shared { 177 name: "libaapt2_jni", 178 srcs: toolSources + ["jni/aapt2_jni.cpp"], 179 static_libs: ["libaapt2"], 180 defaults: ["aapt2_defaults"], 181} 182 183// ========================================================== 184// Build the host tests: aapt2_tests 185// ========================================================== 186cc_test_host { 187 name: "aapt2_tests", 188 srcs: [ 189 "test/Builders.cpp", 190 "test/Common.cpp", 191 "test/Fixture.cpp", 192 "**/*_test.cpp", 193 ] + toolSources, 194 static_libs: [ 195 "libaapt2", 196 "libgmock", 197 ], 198 defaults: ["aapt2_defaults"], 199 data: [ 200 "integration-tests/CompileTest/**/*", 201 "integration-tests/CommandTests/**/*", 202 "integration-tests/ConvertTest/**/*", 203 ], 204} 205 206// ========================================================== 207// Build the host executable: aapt2 208// ========================================================== 209cc_binary_host { 210 name: "aapt2", 211 srcs: ["Main.cpp"] + toolSources, 212 use_version_lib: true, 213 static_libs: ["libaapt2"], 214 defaults: ["aapt2_defaults"], 215 dist: { 216 targets: ["aapt2_artifacts"], 217 }, 218} 219 220// ========================================================== 221// Dist the protos 222// ========================================================== 223genrule { 224 name: "aapt2-protos", 225 tools: [":soong_zip"], 226 srcs: [ 227 "Configuration.proto", 228 "ResourcesInternal.proto", 229 "Resources.proto", 230 ], 231 out: ["aapt2-protos.zip"], 232 cmd: "mkdir $(genDir)/protos && " + 233 "cp $(in) $(genDir)/protos && " + 234 "$(location :soong_zip) -o $(out) -C $(genDir)/protos -D $(genDir)/protos", 235 dist: { 236 targets: [ 237 "sdk_repo", 238 "aapt2_artifacts", 239 ], 240 }, 241} 242