Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | |
Ryan Mitchell | 833a1a6 | 2018-07-10 13:51:36 -0700 | [diff] [blame] | 17 | #include "Dump.h" |
| 18 | |
Adam Lesinski | 93190b7 | 2017-11-03 15:20:17 -0700 | [diff] [blame] | 19 | #include <cinttypes> |
Adam Lesinski | ce5e56e | 2016-10-21 17:56:45 -0700 | [diff] [blame] | 20 | #include <vector> |
| 21 | |
Adam Lesinski | 93190b7 | 2017-11-03 15:20:17 -0700 | [diff] [blame] | 22 | #include "android-base/stringprintf.h" |
Adam Lesinski | d5083f6 | 2017-01-16 15:07:21 -0800 | [diff] [blame] | 23 | #include "androidfw/StringPiece.h" |
| 24 | |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 25 | #include "Debug.h" |
| 26 | #include "Diagnostics.h" |
Adam Lesinski | 0045116 | 2017-10-03 07:44:08 -0700 | [diff] [blame] | 27 | #include "format/Container.h" |
Adam Lesinski | 4670805 | 2017-09-29 14:49:15 -0700 | [diff] [blame] | 28 | #include "format/binary/BinaryResourceParser.h" |
| 29 | #include "format/proto/ProtoDeserialize.h" |
Adam Lesinski | 0045116 | 2017-10-03 07:44:08 -0700 | [diff] [blame] | 30 | #include "io/FileStream.h" |
Adam Lesinski | 64587af | 2016-02-18 18:33:06 -0800 | [diff] [blame] | 31 | #include "io/ZipArchive.h" |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 32 | #include "process/IResourceTableConsumer.h" |
Adam Lesinski | 93190b7 | 2017-11-03 15:20:17 -0700 | [diff] [blame] | 33 | #include "text/Printer.h" |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 34 | #include "util/Files.h" |
Adam Lesinski | d5083f6 | 2017-01-16 15:07:21 -0800 | [diff] [blame] | 35 | |
Adam Lesinski | 93190b7 | 2017-11-03 15:20:17 -0700 | [diff] [blame] | 36 | using ::aapt::text::Printer; |
Adam Lesinski | 4ffea04 | 2017-08-10 15:37:28 -0700 | [diff] [blame] | 37 | using ::android::StringPiece; |
Adam Lesinski | 93190b7 | 2017-11-03 15:20:17 -0700 | [diff] [blame] | 38 | using ::android::base::StringPrintf; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 39 | |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 40 | namespace aapt { |
| 41 | |
Adam Lesinski | 0045116 | 2017-10-03 07:44:08 -0700 | [diff] [blame] | 42 | static const char* ResourceFileTypeToString(const ResourceFile::Type& type) { |
| 43 | switch (type) { |
| 44 | case ResourceFile::Type::kPng: |
| 45 | return "PNG"; |
| 46 | case ResourceFile::Type::kBinaryXml: |
| 47 | return "BINARY_XML"; |
| 48 | case ResourceFile::Type::kProtoXml: |
| 49 | return "PROTO_XML"; |
| 50 | default: |
| 51 | break; |
Adam Lesinski | cacb28f | 2016-10-19 12:18:14 -0700 | [diff] [blame] | 52 | } |
Adam Lesinski | 0045116 | 2017-10-03 07:44:08 -0700 | [diff] [blame] | 53 | return "UNKNOWN"; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 54 | } |
| 55 | |
Adam Lesinski | 0045116 | 2017-10-03 07:44:08 -0700 | [diff] [blame] | 56 | static void DumpCompiledFile(const ResourceFile& file, const Source& source, off64_t offset, |
Adam Lesinski | 93190b7 | 2017-11-03 15:20:17 -0700 | [diff] [blame] | 57 | size_t len, Printer* printer) { |
| 58 | printer->Print("Resource: "); |
| 59 | printer->Println(file.name.to_string()); |
| 60 | |
| 61 | printer->Print("Config: "); |
| 62 | printer->Println(file.config.to_string()); |
| 63 | |
| 64 | printer->Print("Source: "); |
| 65 | printer->Println(file.source.to_string()); |
| 66 | |
| 67 | printer->Print("Type: "); |
| 68 | printer->Println(ResourceFileTypeToString(file.type)); |
| 69 | |
| 70 | printer->Println(StringPrintf("Data: offset=%" PRIi64 " length=%zd", offset, len)); |
Adam Lesinski | 0045116 | 2017-10-03 07:44:08 -0700 | [diff] [blame] | 71 | } |
| 72 | |
Adam Lesinski | da9eba3 | 2018-02-13 16:44:10 -0800 | [diff] [blame] | 73 | static bool DumpXmlFile(IAaptContext* context, io::IFile* file, bool proto, |
| 74 | text::Printer* printer) { |
| 75 | std::unique_ptr<xml::XmlResource> doc; |
| 76 | if (proto) { |
| 77 | std::unique_ptr<io::InputStream> in = file->OpenInputStream(); |
| 78 | if (in == nullptr) { |
| 79 | context->GetDiagnostics()->Error(DiagMessage() << "failed to open file"); |
| 80 | return false; |
| 81 | } |
| 82 | |
| 83 | io::ZeroCopyInputAdaptor adaptor(in.get()); |
| 84 | pb::XmlNode pb_node; |
| 85 | if (!pb_node.ParseFromZeroCopyStream(&adaptor)) { |
| 86 | context->GetDiagnostics()->Error(DiagMessage() << "failed to parse file as proto XML"); |
| 87 | return false; |
| 88 | } |
| 89 | |
| 90 | std::string err; |
| 91 | doc = DeserializeXmlResourceFromPb(pb_node, &err); |
| 92 | if (doc == nullptr) { |
| 93 | context->GetDiagnostics()->Error(DiagMessage() << "failed to deserialize proto XML"); |
| 94 | return false; |
| 95 | } |
| 96 | printer->Println("Proto XML"); |
| 97 | } else { |
| 98 | std::unique_ptr<io::IData> data = file->OpenAsData(); |
| 99 | if (data == nullptr) { |
| 100 | context->GetDiagnostics()->Error(DiagMessage() << "failed to open file"); |
| 101 | return false; |
| 102 | } |
| 103 | |
| 104 | std::string err; |
| 105 | doc = xml::Inflate(data->data(), data->size(), &err); |
| 106 | if (doc == nullptr) { |
| 107 | context->GetDiagnostics()->Error(DiagMessage() << "failed to parse file as binary XML"); |
| 108 | return false; |
| 109 | } |
| 110 | printer->Println("Binary XML"); |
| 111 | } |
| 112 | |
| 113 | Debug::DumpXml(*doc, printer); |
| 114 | return true; |
| 115 | } |
| 116 | |
Adam Lesinski | 71be705 | 2017-12-12 16:48:07 -0800 | [diff] [blame] | 117 | static bool TryDumpFile(IAaptContext* context, const std::string& file_path, |
Adam Lesinski | da9eba3 | 2018-02-13 16:44:10 -0800 | [diff] [blame] | 118 | const DumpOptions& options) { |
Adam Lesinski | 93190b7 | 2017-11-03 15:20:17 -0700 | [diff] [blame] | 119 | // Use a smaller buffer so that there is less latency for dumping to stdout. |
| 120 | constexpr size_t kStdOutBufferSize = 1024u; |
| 121 | io::FileOutputStream fout(STDOUT_FILENO, kStdOutBufferSize); |
| 122 | Printer printer(&fout); |
| 123 | |
Adam Lesinski | cacb28f | 2016-10-19 12:18:14 -0700 | [diff] [blame] | 124 | std::string err; |
Adam Lesinski | d0f492d | 2017-04-03 18:12:45 -0700 | [diff] [blame] | 125 | std::unique_ptr<io::ZipFileCollection> zip = io::ZipFileCollection::Create(file_path, &err); |
Adam Lesinski | cacb28f | 2016-10-19 12:18:14 -0700 | [diff] [blame] | 126 | if (zip) { |
Ryan Mitchell | 83a37ad | 2018-08-06 16:32:24 -0700 | [diff] [blame] | 127 | ResourceTable table(/** validate_resources **/ false); |
Adam Lesinski | da9eba3 | 2018-02-13 16:44:10 -0800 | [diff] [blame] | 128 | bool proto = false; |
Adam Lesinski | e59f0d8 | 2017-10-13 09:36:53 -0700 | [diff] [blame] | 129 | if (io::IFile* file = zip->FindFile("resources.pb")) { |
Adam Lesinski | da9eba3 | 2018-02-13 16:44:10 -0800 | [diff] [blame] | 130 | proto = true; |
| 131 | |
Adam Lesinski | ce5e56e | 2016-10-21 17:56:45 -0700 | [diff] [blame] | 132 | std::unique_ptr<io::IData> data = file->OpenAsData(); |
Adam Lesinski | 8cdca1b | 2017-09-28 15:50:03 -0700 | [diff] [blame] | 133 | if (data == nullptr) { |
Adam Lesinski | e59f0d8 | 2017-10-13 09:36:53 -0700 | [diff] [blame] | 134 | context->GetDiagnostics()->Error(DiagMessage(file_path) << "failed to open resources.pb"); |
Pierre Lecesne | aadf27e | 2017-05-05 14:58:21 +0100 | [diff] [blame] | 135 | return false; |
Adam Lesinski | cacb28f | 2016-10-19 12:18:14 -0700 | [diff] [blame] | 136 | } |
Adam Lesinski | 64587af | 2016-02-18 18:33:06 -0800 | [diff] [blame] | 137 | |
Adam Lesinski | ce5e56e | 2016-10-21 17:56:45 -0700 | [diff] [blame] | 138 | pb::ResourceTable pb_table; |
| 139 | if (!pb_table.ParseFromArray(data->data(), data->size())) { |
Adam Lesinski | e59f0d8 | 2017-10-13 09:36:53 -0700 | [diff] [blame] | 140 | context->GetDiagnostics()->Error(DiagMessage(file_path) << "invalid resources.pb"); |
Pierre Lecesne | aadf27e | 2017-05-05 14:58:21 +0100 | [diff] [blame] | 141 | return false; |
Adam Lesinski | cacb28f | 2016-10-19 12:18:14 -0700 | [diff] [blame] | 142 | } |
Adam Lesinski | 64587af | 2016-02-18 18:33:06 -0800 | [diff] [blame] | 143 | |
Adam Lesinski | 8780eb6 | 2017-10-31 17:44:39 -0700 | [diff] [blame] | 144 | if (!DeserializeTableFromPb(pb_table, zip.get(), &table, &err)) { |
Adam Lesinski | 8cdca1b | 2017-09-28 15:50:03 -0700 | [diff] [blame] | 145 | context->GetDiagnostics()->Error(DiagMessage(file_path) |
| 146 | << "failed to parse table: " << err); |
| 147 | return false; |
| 148 | } |
| 149 | } else if (io::IFile* file = zip->FindFile("resources.arsc")) { |
| 150 | std::unique_ptr<io::IData> data = file->OpenAsData(); |
| 151 | if (!data) { |
| 152 | context->GetDiagnostics()->Error(DiagMessage(file_path) << "failed to open resources.arsc"); |
| 153 | return false; |
| 154 | } |
| 155 | |
Adam Lesinski | 8780eb6 | 2017-10-31 17:44:39 -0700 | [diff] [blame] | 156 | BinaryResourceParser parser(context->GetDiagnostics(), &table, Source(file_path), |
| 157 | data->data(), data->size()); |
Adam Lesinski | 8cdca1b | 2017-09-28 15:50:03 -0700 | [diff] [blame] | 158 | if (!parser.Parse()) { |
Pierre Lecesne | aadf27e | 2017-05-05 14:58:21 +0100 | [diff] [blame] | 159 | return false; |
Adam Lesinski | cacb28f | 2016-10-19 12:18:14 -0700 | [diff] [blame] | 160 | } |
Adam Lesinski | 64587af | 2016-02-18 18:33:06 -0800 | [diff] [blame] | 161 | } |
| 162 | |
Adam Lesinski | da9eba3 | 2018-02-13 16:44:10 -0800 | [diff] [blame] | 163 | if (!options.file_to_dump_path) { |
| 164 | if (proto) { |
| 165 | printer.Println("Proto APK"); |
| 166 | } else { |
| 167 | printer.Println("Binary APK"); |
| 168 | } |
| 169 | Debug::PrintTable(table, options.print_options, &printer); |
| 170 | return true; |
| 171 | } |
| 172 | |
| 173 | io::IFile* file = zip->FindFile(options.file_to_dump_path.value()); |
| 174 | if (file == nullptr) { |
| 175 | context->GetDiagnostics()->Error(DiagMessage(file_path) |
| 176 | << "file '" << options.file_to_dump_path.value() |
| 177 | << "' not found in APK"); |
| 178 | return false; |
| 179 | } |
| 180 | return DumpXmlFile(context, file, proto, &printer); |
Adam Lesinski | 8cdca1b | 2017-09-28 15:50:03 -0700 | [diff] [blame] | 181 | } |
Adam Lesinski | 5e8fa3a | 2016-06-27 16:21:42 -0700 | [diff] [blame] | 182 | |
Adam Lesinski | 8cdca1b | 2017-09-28 15:50:03 -0700 | [diff] [blame] | 183 | err.clear(); |
| 184 | |
Adam Lesinski | 0045116 | 2017-10-03 07:44:08 -0700 | [diff] [blame] | 185 | io::FileInputStream input(file_path); |
| 186 | if (input.HadError()) { |
| 187 | context->GetDiagnostics()->Error(DiagMessage(file_path) |
| 188 | << "failed to open file: " << input.GetError()); |
Adam Lesinski | 8cdca1b | 2017-09-28 15:50:03 -0700 | [diff] [blame] | 189 | return false; |
| 190 | } |
| 191 | |
Adam Lesinski | 8cdca1b | 2017-09-28 15:50:03 -0700 | [diff] [blame] | 192 | // Try as a compiled file. |
Adam Lesinski | 0045116 | 2017-10-03 07:44:08 -0700 | [diff] [blame] | 193 | ContainerReader reader(&input); |
| 194 | if (reader.HadError()) { |
| 195 | context->GetDiagnostics()->Error(DiagMessage(file_path) |
| 196 | << "failed to read container: " << reader.GetError()); |
Adam Lesinski | 8cdca1b | 2017-09-28 15:50:03 -0700 | [diff] [blame] | 197 | return false; |
| 198 | } |
| 199 | |
Adam Lesinski | 93190b7 | 2017-11-03 15:20:17 -0700 | [diff] [blame] | 200 | printer.Println("AAPT2 Container (APC)"); |
Adam Lesinski | 0045116 | 2017-10-03 07:44:08 -0700 | [diff] [blame] | 201 | ContainerReaderEntry* entry; |
| 202 | while ((entry = reader.Next()) != nullptr) { |
| 203 | if (entry->Type() == ContainerEntryType::kResTable) { |
Adam Lesinski | 93190b7 | 2017-11-03 15:20:17 -0700 | [diff] [blame] | 204 | printer.Println("kResTable"); |
| 205 | |
Adam Lesinski | 0045116 | 2017-10-03 07:44:08 -0700 | [diff] [blame] | 206 | pb::ResourceTable pb_table; |
| 207 | if (!entry->GetResTable(&pb_table)) { |
| 208 | context->GetDiagnostics()->Error(DiagMessage(file_path) |
| 209 | << "failed to parse proto table: " << entry->GetError()); |
| 210 | continue; |
| 211 | } |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 212 | |
Adam Lesinski | 0045116 | 2017-10-03 07:44:08 -0700 | [diff] [blame] | 213 | ResourceTable table; |
| 214 | err.clear(); |
Adam Lesinski | 8780eb6 | 2017-10-31 17:44:39 -0700 | [diff] [blame] | 215 | if (!DeserializeTableFromPb(pb_table, nullptr /*files*/, &table, &err)) { |
Adam Lesinski | 0045116 | 2017-10-03 07:44:08 -0700 | [diff] [blame] | 216 | context->GetDiagnostics()->Error(DiagMessage(file_path) |
| 217 | << "failed to parse table: " << err); |
| 218 | continue; |
| 219 | } |
Adam Lesinski | cacb28f | 2016-10-19 12:18:14 -0700 | [diff] [blame] | 220 | |
Adam Lesinski | 93190b7 | 2017-11-03 15:20:17 -0700 | [diff] [blame] | 221 | printer.Indent(); |
Adam Lesinski | da9eba3 | 2018-02-13 16:44:10 -0800 | [diff] [blame] | 222 | Debug::PrintTable(table, options.print_options, &printer); |
Adam Lesinski | 93190b7 | 2017-11-03 15:20:17 -0700 | [diff] [blame] | 223 | printer.Undent(); |
Adam Lesinski | 0045116 | 2017-10-03 07:44:08 -0700 | [diff] [blame] | 224 | } else if (entry->Type() == ContainerEntryType::kResFile) { |
Adam Lesinski | 93190b7 | 2017-11-03 15:20:17 -0700 | [diff] [blame] | 225 | printer.Println("kResFile"); |
Adam Lesinski | 0045116 | 2017-10-03 07:44:08 -0700 | [diff] [blame] | 226 | pb::internal::CompiledFile pb_compiled_file; |
| 227 | off64_t offset; |
| 228 | size_t length; |
| 229 | if (!entry->GetResFileOffsets(&pb_compiled_file, &offset, &length)) { |
| 230 | context->GetDiagnostics()->Error( |
| 231 | DiagMessage(file_path) << "failed to parse compiled proto file: " << entry->GetError()); |
| 232 | continue; |
| 233 | } |
| 234 | |
| 235 | ResourceFile file; |
| 236 | std::string error; |
| 237 | if (!DeserializeCompiledFileFromPb(pb_compiled_file, &file, &error)) { |
| 238 | context->GetDiagnostics()->Warn(DiagMessage(file_path) |
| 239 | << "failed to parse compiled file: " << error); |
| 240 | continue; |
| 241 | } |
| 242 | |
Adam Lesinski | 93190b7 | 2017-11-03 15:20:17 -0700 | [diff] [blame] | 243 | printer.Indent(); |
| 244 | DumpCompiledFile(file, Source(file_path), offset, length, &printer); |
| 245 | printer.Undent(); |
Adam Lesinski | cacb28f | 2016-10-19 12:18:14 -0700 | [diff] [blame] | 246 | } |
| 247 | } |
Pierre Lecesne | aadf27e | 2017-05-05 14:58:21 +0100 | [diff] [blame] | 248 | return true; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 249 | } |
| 250 | |
Adam Lesinski | 0045116 | 2017-10-03 07:44:08 -0700 | [diff] [blame] | 251 | namespace { |
| 252 | |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 253 | class DumpContext : public IAaptContext { |
Adam Lesinski | cacb28f | 2016-10-19 12:18:14 -0700 | [diff] [blame] | 254 | public: |
Adam Lesinski | b522f04 | 2017-04-21 16:57:59 -0700 | [diff] [blame] | 255 | PackageType GetPackageType() override { |
| 256 | // Doesn't matter. |
| 257 | return PackageType::kApp; |
| 258 | } |
| 259 | |
Adam Lesinski | d0f492d | 2017-04-03 18:12:45 -0700 | [diff] [blame] | 260 | IDiagnostics* GetDiagnostics() override { |
| 261 | return &diagnostics_; |
| 262 | } |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 263 | |
Adam Lesinski | ce5e56e | 2016-10-21 17:56:45 -0700 | [diff] [blame] | 264 | NameMangler* GetNameMangler() override { |
Adam Lesinski | 0045116 | 2017-10-03 07:44:08 -0700 | [diff] [blame] | 265 | UNIMPLEMENTED(FATAL); |
Adam Lesinski | cacb28f | 2016-10-19 12:18:14 -0700 | [diff] [blame] | 266 | return nullptr; |
| 267 | } |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 268 | |
Adam Lesinski | ce5e56e | 2016-10-21 17:56:45 -0700 | [diff] [blame] | 269 | const std::string& GetCompilationPackage() override { |
Adam Lesinski | cacb28f | 2016-10-19 12:18:14 -0700 | [diff] [blame] | 270 | static std::string empty; |
| 271 | return empty; |
| 272 | } |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 273 | |
Adam Lesinski | d0f492d | 2017-04-03 18:12:45 -0700 | [diff] [blame] | 274 | uint8_t GetPackageId() override { |
| 275 | return 0; |
| 276 | } |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 277 | |
Adam Lesinski | ce5e56e | 2016-10-21 17:56:45 -0700 | [diff] [blame] | 278 | SymbolTable* GetExternalSymbols() override { |
Adam Lesinski | 0045116 | 2017-10-03 07:44:08 -0700 | [diff] [blame] | 279 | UNIMPLEMENTED(FATAL); |
Adam Lesinski | cacb28f | 2016-10-19 12:18:14 -0700 | [diff] [blame] | 280 | return nullptr; |
| 281 | } |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 282 | |
Adam Lesinski | d0f492d | 2017-04-03 18:12:45 -0700 | [diff] [blame] | 283 | bool IsVerbose() override { |
| 284 | return verbose_; |
| 285 | } |
Adam Lesinski | 355f285 | 2016-02-13 20:26:45 -0800 | [diff] [blame] | 286 | |
Adam Lesinski | d0f492d | 2017-04-03 18:12:45 -0700 | [diff] [blame] | 287 | void SetVerbose(bool val) { |
| 288 | verbose_ = val; |
| 289 | } |
Adam Lesinski | 355f285 | 2016-02-13 20:26:45 -0800 | [diff] [blame] | 290 | |
Adam Lesinski | d0f492d | 2017-04-03 18:12:45 -0700 | [diff] [blame] | 291 | int GetMinSdkVersion() override { |
| 292 | return 0; |
| 293 | } |
Adam Lesinski | fb6312f | 2016-06-28 14:40:32 -0700 | [diff] [blame] | 294 | |
Adam Lesinski | cacb28f | 2016-10-19 12:18:14 -0700 | [diff] [blame] | 295 | private: |
Adam Lesinski | ce5e56e | 2016-10-21 17:56:45 -0700 | [diff] [blame] | 296 | StdErrDiagnostics diagnostics_; |
| 297 | bool verbose_ = false; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 298 | }; |
| 299 | |
Adam Lesinski | 0045116 | 2017-10-03 07:44:08 -0700 | [diff] [blame] | 300 | } // namespace |
| 301 | |
Ryan Mitchell | 833a1a6 | 2018-07-10 13:51:36 -0700 | [diff] [blame] | 302 | int DumpCommand::Action(const std::vector<std::string>& args) { |
Adam Lesinski | cacb28f | 2016-10-19 12:18:14 -0700 | [diff] [blame] | 303 | DumpContext context; |
Ryan Mitchell | 833a1a6 | 2018-07-10 13:51:36 -0700 | [diff] [blame] | 304 | context.SetVerbose(verbose_); |
| 305 | options_.print_options.show_sources = true; |
| 306 | options_.print_options.show_values = !no_values_; |
| 307 | for (const std::string& arg : args) { |
| 308 | if (!TryDumpFile(&context, arg, options_)) { |
Pierre Lecesne | aadf27e | 2017-05-05 14:58:21 +0100 | [diff] [blame] | 309 | return 1; |
| 310 | } |
Adam Lesinski | cacb28f | 2016-10-19 12:18:14 -0700 | [diff] [blame] | 311 | } |
| 312 | return 0; |
Adam Lesinski | 59e04c6 | 2016-02-04 15:59:23 -0800 | [diff] [blame] | 313 | } |
| 314 | |
Adam Lesinski | cacb28f | 2016-10-19 12:18:14 -0700 | [diff] [blame] | 315 | } // namespace aapt |