From a3ab21f04ac976ced7933af04e8f8cb593571a03 Mon Sep 17 00:00:00 2001 From: Izabela Orlowska Date: Thu, 17 Jan 2019 12:09:59 +0000 Subject: [PATCH] AAPT2: always say which file failed to compile Sometimes AAPT2 doesn't include the path of the file in the error message, or just outputs a warning where an error should be printed (but the overall build still fails without an error message). Let's always include the file path to make it easier for the users to find out the source of the failure. Fixes: 122856772 Test: manual Change-Id: Ibbbfd21b372792e5eaa40278186eb64cdfb0f60e --- tools/aapt2/ResourceParser.cpp | 3 ++- tools/aapt2/cmd/Compile.cpp | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/aapt2/ResourceParser.cpp b/tools/aapt2/ResourceParser.cpp index 58702dc465cc4..133cc849a4e83 100644 --- a/tools/aapt2/ResourceParser.cpp +++ b/tools/aapt2/ResourceParser.cpp @@ -714,7 +714,8 @@ bool ResourceParser::ParseResource(xml::XmlPullParser* parser, } } - diag_->Warn(DiagMessage(out_resource->source) + // If the resource type was not recognized, write the error and return false. + diag_->Error(DiagMessage(out_resource->source) << "unknown resource type '" << parser->element_name() << "'"); return false; } diff --git a/tools/aapt2/cmd/Compile.cpp b/tools/aapt2/cmd/Compile.cpp index 52375a39b93f7..92beb4eb7ce46 100644 --- a/tools/aapt2/cmd/Compile.cpp +++ b/tools/aapt2/cmd/Compile.cpp @@ -701,7 +701,10 @@ int Compile(IAaptContext* context, io::IFileCollection* inputs, IArchiveWriter* } const std::string out_path = BuildIntermediateContainerFilename(path_data); - error |= !compile_func(context, options, path_data, file, output_writer, out_path); + if (!compile_func(context, options, path_data, file, output_writer, out_path)) { + context->GetDiagnostics()->Error(DiagMessage(file->GetSource()) << "file failed to compile"); + error = true; + } } return error ? 1 : 0;