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