blob: c78670fbc20d75ece2d7839476eb62649cf49104 [file] [log] [blame]
Adam Lesinski1ab598f2015-08-14 14:26:04 -07001/*
2 * Copyright (C) 2015 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#include "ConfigDescription.h"
18#include "Diagnostics.h"
19#include "Flags.h"
20#include "ResourceParser.h"
21#include "ResourceTable.h"
Adam Lesinski1ab598f2015-08-14 14:26:04 -070022#include "compile/IdAssigner.h"
23#include "compile/Png.h"
Adam Lesinski393b5f02015-12-17 13:03:11 -080024#include "compile/PseudolocaleGenerator.h"
Adam Lesinski1ab598f2015-08-14 14:26:04 -070025#include "compile/XmlIdCollector.h"
Adam Lesinskia40e9722015-11-24 19:11:46 -080026#include "flatten/Archive.h"
Adam Lesinski1ab598f2015-08-14 14:26:04 -070027#include "flatten/FileExportWriter.h"
28#include "flatten/TableFlattener.h"
29#include "flatten/XmlFlattener.h"
30#include "util/Files.h"
31#include "util/Maybe.h"
32#include "util/Util.h"
Adam Lesinski467f1712015-11-16 17:35:44 -080033#include "xml/XmlDom.h"
34#include "xml/XmlPullParser.h"
Adam Lesinski1ab598f2015-08-14 14:26:04 -070035
Adam Lesinskia40e9722015-11-24 19:11:46 -080036#include <dirent.h>
Adam Lesinski1ab598f2015-08-14 14:26:04 -070037#include <fstream>
38#include <string>
39
40namespace aapt {
41
42struct ResourcePathData {
43 Source source;
44 std::u16string resourceDir;
45 std::u16string name;
46 std::string extension;
47
48 // Original config str. We keep this because when we parse the config, we may add on
49 // version qualifiers. We want to preserve the original input so the output is easily
50 // computed before hand.
51 std::string configStr;
52 ConfigDescription config;
53};
54
55/**
56 * Resource file paths are expected to look like:
57 * [--/res/]type[-config]/name
58 */
59static Maybe<ResourcePathData> extractResourcePathData(const std::string& path,
60 std::string* outError) {
61 std::vector<std::string> parts = util::split(path, file::sDirSep);
62 if (parts.size() < 2) {
63 if (outError) *outError = "bad resource path";
64 return {};
65 }
66
67 std::string& dir = parts[parts.size() - 2];
68 StringPiece dirStr = dir;
69
70 StringPiece configStr;
71 ConfigDescription config;
72 size_t dashPos = dir.find('-');
73 if (dashPos != std::string::npos) {
74 configStr = dirStr.substr(dashPos + 1, dir.size() - (dashPos + 1));
75 if (!ConfigDescription::parse(configStr, &config)) {
76 if (outError) {
77 std::stringstream errStr;
78 errStr << "invalid configuration '" << configStr << "'";
79 *outError = errStr.str();
80 }
81 return {};
82 }
83 dirStr = dirStr.substr(0, dashPos);
84 }
85
86 std::string& filename = parts[parts.size() - 1];
87 StringPiece name = filename;
88 StringPiece extension;
89 size_t dotPos = filename.find('.');
90 if (dotPos != std::string::npos) {
91 extension = name.substr(dotPos + 1, filename.size() - (dotPos + 1));
92 name = name.substr(0, dotPos);
93 }
94
95 return ResourcePathData{
Adam Lesinskia40e9722015-11-24 19:11:46 -080096 Source(path),
Adam Lesinski1ab598f2015-08-14 14:26:04 -070097 util::utf8ToUtf16(dirStr),
98 util::utf8ToUtf16(name),
99 extension.toString(),
100 configStr.toString(),
101 config
102 };
103}
104
105struct CompileOptions {
106 std::string outputPath;
Adam Lesinskia40e9722015-11-24 19:11:46 -0800107 Maybe<std::string> resDir;
Adam Lesinski7751afc2016-01-06 15:45:28 -0800108 std::vector<std::u16string> products;
Adam Lesinski393b5f02015-12-17 13:03:11 -0800109 bool pseudolocalize = false;
Adam Lesinski979ccb22016-01-11 10:42:19 -0800110 bool legacyMode = false;
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700111 bool verbose = false;
112};
113
Adam Lesinskia40e9722015-11-24 19:11:46 -0800114static std::string buildIntermediateFilename(const ResourcePathData& data) {
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700115 std::stringstream name;
116 name << data.resourceDir;
117 if (!data.configStr.empty()) {
118 name << "-" << data.configStr;
119 }
120 name << "_" << data.name << "." << data.extension << ".flat";
Adam Lesinskia40e9722015-11-24 19:11:46 -0800121 return name.str();
122}
123
124static bool isHidden(const StringPiece& filename) {
125 return util::stringStartsWith<char>(filename, ".");
126}
127
128/**
129 * Walks the res directory structure, looking for resource files.
130 */
131static bool loadInputFilesFromDir(IAaptContext* context, const CompileOptions& options,
132 std::vector<ResourcePathData>* outPathData) {
133 const std::string& rootDir = options.resDir.value();
134 std::unique_ptr<DIR, decltype(closedir)*> d(opendir(rootDir.data()), closedir);
135 if (!d) {
136 context->getDiagnostics()->error(DiagMessage() << strerror(errno));
137 return false;
138 }
139
140 while (struct dirent* entry = readdir(d.get())) {
141 if (isHidden(entry->d_name)) {
142 continue;
143 }
144
145 std::string prefixPath = rootDir;
146 file::appendPath(&prefixPath, entry->d_name);
147
148 if (file::getFileType(prefixPath) != file::FileType::kDirectory) {
149 continue;
150 }
151
152 std::unique_ptr<DIR, decltype(closedir)*> subDir(opendir(prefixPath.data()), closedir);
153 if (!subDir) {
154 context->getDiagnostics()->error(DiagMessage() << strerror(errno));
155 return false;
156 }
157
158 while (struct dirent* leafEntry = readdir(subDir.get())) {
159 if (isHidden(leafEntry->d_name)) {
160 continue;
161 }
162
163 std::string fullPath = prefixPath;
164 file::appendPath(&fullPath, leafEntry->d_name);
165
166 std::string errStr;
167 Maybe<ResourcePathData> pathData = extractResourcePathData(fullPath, &errStr);
168 if (!pathData) {
169 context->getDiagnostics()->error(DiagMessage() << errStr);
170 return false;
171 }
172
173 outPathData->push_back(std::move(pathData.value()));
174 }
175 }
176 return true;
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700177}
178
179static bool compileTable(IAaptContext* context, const CompileOptions& options,
Adam Lesinskia40e9722015-11-24 19:11:46 -0800180 const ResourcePathData& pathData, IArchiveWriter* writer,
181 const std::string& outputPath) {
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700182 ResourceTable table;
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700183 {
184 std::ifstream fin(pathData.source.path, std::ifstream::binary);
185 if (!fin) {
186 context->getDiagnostics()->error(DiagMessage(pathData.source) << strerror(errno));
187 return false;
188 }
189
190
191 // Parse the values file from XML.
Adam Lesinski467f1712015-11-16 17:35:44 -0800192 xml::XmlPullParser xmlParser(fin);
Adam Lesinski9f222042015-11-04 13:51:45 -0800193
194 ResourceParserOptions parserOptions;
Adam Lesinski7751afc2016-01-06 15:45:28 -0800195 parserOptions.products = options.products;
Adam Lesinski979ccb22016-01-11 10:42:19 -0800196 parserOptions.errorOnPositionalArguments = !options.legacyMode;
Adam Lesinski9f222042015-11-04 13:51:45 -0800197
198 // If the filename includes donottranslate, then the default translatable is false.
199 parserOptions.translatable = pathData.name.find(u"donottranslate") == std::string::npos;
200
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700201 ResourceParser resParser(context->getDiagnostics(), &table, pathData.source,
Adam Lesinski9f222042015-11-04 13:51:45 -0800202 pathData.config, parserOptions);
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700203 if (!resParser.parse(&xmlParser)) {
204 return false;
205 }
206
207 fin.close();
208 }
209
Adam Lesinski393b5f02015-12-17 13:03:11 -0800210 if (options.pseudolocalize) {
211 // Generate pseudo-localized strings (en-XA and ar-XB).
212 // These are created as weak symbols, and are only generated from default configuration
213 // strings and plurals.
214 PseudolocaleGenerator pseudolocaleGenerator;
215 if (!pseudolocaleGenerator.consume(context, &table)) {
216 return false;
217 }
218 }
219
Adam Lesinski83f22552015-11-07 11:51:23 -0800220 // Ensure we have the compilation package at least.
221 table.createPackage(context->getCompilationPackage());
222
Adam Lesinskia40e9722015-11-24 19:11:46 -0800223 // Assign an ID to any package that has resources.
Adam Lesinski83f22552015-11-07 11:51:23 -0800224 for (auto& pkg : table.packages) {
225 if (!pkg->id) {
226 // If no package ID was set while parsing (public identifiers), auto assign an ID.
227 pkg->id = context->getPackageId();
228 }
Adam Lesinski9ba47d82015-10-13 11:37:10 -0700229 }
230
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700231 // Assign IDs to prepare the table for flattening.
232 IdAssigner idAssigner;
233 if (!idAssigner.consume(context, &table)) {
234 return false;
235 }
236
237 // Flatten the table.
238 BigBuffer buffer(1024);
239 TableFlattenerOptions tableFlattenerOptions;
240 tableFlattenerOptions.useExtendedChunks = true;
241 TableFlattener flattener(&buffer, tableFlattenerOptions);
242 if (!flattener.consume(context, &table)) {
243 return false;
244 }
245
Adam Lesinskia40e9722015-11-24 19:11:46 -0800246 if (!writer->startEntry(outputPath, 0)) {
247 context->getDiagnostics()->error(DiagMessage(outputPath) << "failed to open");
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700248 return false;
249 }
250
Adam Lesinskia40e9722015-11-24 19:11:46 -0800251 if (writer->writeEntry(buffer)) {
252 if (writer->finishEntry()) {
253 return true;
254 }
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700255 }
Adam Lesinskia40e9722015-11-24 19:11:46 -0800256
257 context->getDiagnostics()->error(DiagMessage(outputPath) << "failed to write");
258 return false;
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700259}
260
261static bool compileXml(IAaptContext* context, const CompileOptions& options,
Adam Lesinskia40e9722015-11-24 19:11:46 -0800262 const ResourcePathData& pathData, IArchiveWriter* writer,
263 const std::string& outputPath) {
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700264
Adam Lesinski467f1712015-11-16 17:35:44 -0800265 std::unique_ptr<xml::XmlResource> xmlRes;
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700266
267 {
268 std::ifstream fin(pathData.source.path, std::ifstream::binary);
269 if (!fin) {
270 context->getDiagnostics()->error(DiagMessage(pathData.source) << strerror(errno));
271 return false;
272 }
273
274 xmlRes = xml::inflate(&fin, context->getDiagnostics(), pathData.source);
275
276 fin.close();
277 }
278
279 if (!xmlRes) {
280 return false;
281 }
282
283 // Collect IDs that are defined here.
284 XmlIdCollector collector;
285 if (!collector.consume(context, xmlRes.get())) {
286 return false;
287 }
288
Adam Lesinskia40e9722015-11-24 19:11:46 -0800289 xmlRes->file.name = ResourceName({}, *parseResourceType(pathData.resourceDir), pathData.name);
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700290 xmlRes->file.config = pathData.config;
291 xmlRes->file.source = pathData.source;
292
293 BigBuffer buffer(1024);
294 ChunkWriter fileExportWriter = wrapBufferWithFileExportHeader(&buffer, &xmlRes->file);
295
296 XmlFlattenerOptions xmlFlattenerOptions;
297 xmlFlattenerOptions.keepRawValues = true;
298 XmlFlattener flattener(fileExportWriter.getBuffer(), xmlFlattenerOptions);
299 if (!flattener.consume(context, xmlRes.get())) {
300 return false;
301 }
302
303 fileExportWriter.finish();
304
Adam Lesinskia40e9722015-11-24 19:11:46 -0800305 if (!writer->startEntry(outputPath, 0)) {
306 context->getDiagnostics()->error(DiagMessage(outputPath) << "failed to open");
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700307 return false;
308 }
309
Adam Lesinskia40e9722015-11-24 19:11:46 -0800310 if (writer->writeEntry(buffer)) {
311 if (writer->finishEntry()) {
312 return true;
313 }
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700314 }
Adam Lesinskia40e9722015-11-24 19:11:46 -0800315
316 context->getDiagnostics()->error(DiagMessage(outputPath) << "failed to write");
317 return false;
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700318}
319
320static bool compilePng(IAaptContext* context, const CompileOptions& options,
Adam Lesinskia40e9722015-11-24 19:11:46 -0800321 const ResourcePathData& pathData, IArchiveWriter* writer,
322 const std::string& outputPath) {
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700323 BigBuffer buffer(4096);
324 ResourceFile resFile;
Adam Lesinskia40e9722015-11-24 19:11:46 -0800325 resFile.name = ResourceName({}, *parseResourceType(pathData.resourceDir), pathData.name);
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700326 resFile.config = pathData.config;
327 resFile.source = pathData.source;
328
329 ChunkWriter fileExportWriter = wrapBufferWithFileExportHeader(&buffer, &resFile);
330
331 {
332 std::ifstream fin(pathData.source.path, std::ifstream::binary);
333 if (!fin) {
334 context->getDiagnostics()->error(DiagMessage(pathData.source) << strerror(errno));
335 return false;
336 }
337
338 Png png(context->getDiagnostics());
339 if (!png.process(pathData.source, &fin, fileExportWriter.getBuffer(), {})) {
340 return false;
341 }
342 }
343
344 fileExportWriter.finish();
345
Adam Lesinskia40e9722015-11-24 19:11:46 -0800346 if (!writer->startEntry(outputPath, 0)) {
347 context->getDiagnostics()->error(DiagMessage(outputPath) << "failed to open");
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700348 return false;
349 }
350
Adam Lesinskia40e9722015-11-24 19:11:46 -0800351 if (writer->writeEntry(buffer)) {
352 if (writer->finishEntry()) {
353 return true;
354 }
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700355 }
Adam Lesinskia40e9722015-11-24 19:11:46 -0800356
357 context->getDiagnostics()->error(DiagMessage(outputPath) << "failed to write");
358 return false;
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700359}
360
361static bool compileFile(IAaptContext* context, const CompileOptions& options,
Adam Lesinskia40e9722015-11-24 19:11:46 -0800362 const ResourcePathData& pathData, IArchiveWriter* writer,
363 const std::string& outputPath) {
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700364 BigBuffer buffer(256);
365 ResourceFile resFile;
Adam Lesinskia40e9722015-11-24 19:11:46 -0800366 resFile.name = ResourceName({}, *parseResourceType(pathData.resourceDir), pathData.name);
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700367 resFile.config = pathData.config;
368 resFile.source = pathData.source;
369
370 ChunkWriter fileExportWriter = wrapBufferWithFileExportHeader(&buffer, &resFile);
371
372 std::string errorStr;
373 Maybe<android::FileMap> f = file::mmapPath(pathData.source.path, &errorStr);
374 if (!f) {
375 context->getDiagnostics()->error(DiagMessage(pathData.source) << errorStr);
376 return false;
377 }
378
Adam Lesinskia40e9722015-11-24 19:11:46 -0800379 if (!writer->startEntry(outputPath, 0)) {
380 context->getDiagnostics()->error(DiagMessage(outputPath) << "failed to open");
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700381 return false;
382 }
383
384 // Manually set the size and don't call finish(). This is because we are not copying from
385 // the buffer the entire file.
386 fileExportWriter.getChunkHeader()->size =
387 util::hostToDevice32(buffer.size() + f.value().getDataLength());
Adam Lesinskia40e9722015-11-24 19:11:46 -0800388
389 if (writer->writeEntry(buffer)) {
390 if (writer->writeEntry(f.value().getDataPtr(), f.value().getDataLength())) {
391 if (writer->finishEntry()) {
392 return true;
393 }
394 }
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700395 }
396
Adam Lesinskia40e9722015-11-24 19:11:46 -0800397 context->getDiagnostics()->error(DiagMessage(outputPath) << "failed to write");
398 return false;
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700399}
400
401class CompileContext : public IAaptContext {
402private:
403 StdErrDiagnostics mDiagnostics;
404
405public:
406 IDiagnostics* getDiagnostics() override {
407 return &mDiagnostics;
408 }
409
410 NameMangler* getNameMangler() override {
411 abort();
412 return nullptr;
413 }
414
415 StringPiece16 getCompilationPackage() override {
416 return {};
417 }
418
419 uint8_t getPackageId() override {
Adam Lesinski9ba47d82015-10-13 11:37:10 -0700420 return 0x0;
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700421 }
422
423 ISymbolTable* getExternalSymbols() override {
424 abort();
425 return nullptr;
426 }
427};
428
429/**
430 * Entry point for compilation phase. Parses arguments and dispatches to the correct steps.
431 */
432int compile(const std::vector<StringPiece>& args) {
433 CompileOptions options;
434
Adam Lesinski7751afc2016-01-06 15:45:28 -0800435 Maybe<std::string> productList;
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700436 Flags flags = Flags()
437 .requiredFlag("-o", "Output path", &options.outputPath)
Adam Lesinski7751afc2016-01-06 15:45:28 -0800438 .optionalFlag("--product", "Comma separated list of product types to compile",
439 &productList)
Adam Lesinskia40e9722015-11-24 19:11:46 -0800440 .optionalFlag("--dir", "Directory to scan for resources", &options.resDir)
Adam Lesinski393b5f02015-12-17 13:03:11 -0800441 .optionalSwitch("--pseudo-localize", "Generate resources for pseudo-locales "
442 "(en-XA and ar-XB)", &options.pseudolocalize)
Adam Lesinski979ccb22016-01-11 10:42:19 -0800443 .optionalSwitch("--legacy", "Treat errors that used to be valid in AAPT as warnings",
444 &options.legacyMode)
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700445 .optionalSwitch("-v", "Enables verbose logging", &options.verbose);
446 if (!flags.parse("aapt2 compile", args, &std::cerr)) {
447 return 1;
448 }
449
Adam Lesinski7751afc2016-01-06 15:45:28 -0800450 if (productList) {
451 for (StringPiece part : util::tokenize<char>(productList.value(), ',')) {
452 options.products.push_back(util::utf8ToUtf16(part));
453 }
Adam Lesinski9ba47d82015-10-13 11:37:10 -0700454 }
455
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700456 CompileContext context;
Adam Lesinskia40e9722015-11-24 19:11:46 -0800457 std::unique_ptr<IArchiveWriter> archiveWriter;
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700458
459 std::vector<ResourcePathData> inputData;
Adam Lesinskia40e9722015-11-24 19:11:46 -0800460 if (options.resDir) {
461 if (!flags.getArgs().empty()) {
462 // Can't have both files and a resource directory.
463 context.getDiagnostics()->error(DiagMessage() << "files given but --dir specified");
464 flags.usage("aapt2 compile", &std::cerr);
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700465 return 1;
466 }
Adam Lesinskia40e9722015-11-24 19:11:46 -0800467
468 if (!loadInputFilesFromDir(&context, options, &inputData)) {
469 return 1;
470 }
471
472 archiveWriter = createZipFileArchiveWriter(context.getDiagnostics(), options.outputPath);
473
474 } else {
475 inputData.reserve(flags.getArgs().size());
476
477 // Collect data from the path for each input file.
478 for (const std::string& arg : flags.getArgs()) {
479 std::string errorStr;
480 if (Maybe<ResourcePathData> pathData = extractResourcePathData(arg, &errorStr)) {
481 inputData.push_back(std::move(pathData.value()));
482 } else {
483 context.getDiagnostics()->error(DiagMessage() << errorStr << " (" << arg << ")");
484 return 1;
485 }
486 }
487
488 archiveWriter = createDirectoryArchiveWriter(context.getDiagnostics(), options.outputPath);
489 }
490
491 if (!archiveWriter) {
492 return false;
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700493 }
494
495 bool error = false;
496 for (ResourcePathData& pathData : inputData) {
497 if (options.verbose) {
498 context.getDiagnostics()->note(DiagMessage(pathData.source) << "processing");
499 }
500
501 if (pathData.resourceDir == u"values") {
502 // Overwrite the extension.
503 pathData.extension = "arsc";
504
Adam Lesinskia40e9722015-11-24 19:11:46 -0800505 const std::string outputFilename = buildIntermediateFilename(pathData);
506 if (!compileTable(&context, options, pathData, archiveWriter.get(), outputFilename)) {
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700507 error = true;
508 }
509
510 } else {
Adam Lesinskia40e9722015-11-24 19:11:46 -0800511 const std::string outputFilename = buildIntermediateFilename(pathData);
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700512 if (const ResourceType* type = parseResourceType(pathData.resourceDir)) {
513 if (*type != ResourceType::kRaw) {
514 if (pathData.extension == "xml") {
Adam Lesinskia40e9722015-11-24 19:11:46 -0800515 if (!compileXml(&context, options, pathData, archiveWriter.get(),
516 outputFilename)) {
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700517 error = true;
518 }
519 } else if (pathData.extension == "png" || pathData.extension == "9.png") {
Adam Lesinskia40e9722015-11-24 19:11:46 -0800520 if (!compilePng(&context, options, pathData, archiveWriter.get(),
521 outputFilename)) {
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700522 error = true;
523 }
524 } else {
Adam Lesinskia40e9722015-11-24 19:11:46 -0800525 if (!compileFile(&context, options, pathData, archiveWriter.get(),
526 outputFilename)) {
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700527 error = true;
528 }
529 }
530 } else {
Adam Lesinskia40e9722015-11-24 19:11:46 -0800531 if (!compileFile(&context, options, pathData, archiveWriter.get(),
532 outputFilename)) {
Adam Lesinski1ab598f2015-08-14 14:26:04 -0700533 error = true;
534 }
535 }
536 } else {
537 context.getDiagnostics()->error(
538 DiagMessage() << "invalid file path '" << pathData.source << "'");
539 error = true;
540 }
541 }
542 }
543
544 if (error) {
545 return 1;
546 }
547 return 0;
548}
549
550} // namespace aapt