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