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