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