Merge "Simplify the error message for ABI check" am: acccadc399
Original change: https://android-review.googlesource.com/c/platform/development/+/2238114 Change-Id: Ic8d6a65e6231a934428ab5a33c5899734a7956fa Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -66,8 +66,7 @@ static llvm::cl::opt<bool> advice_only(
|
|||||||
|
|
||||||
static llvm::cl::opt<bool> elf_unreferenced_symbol_errors(
|
static llvm::cl::opt<bool> elf_unreferenced_symbol_errors(
|
||||||
"elf-unreferenced-symbol-errors",
|
"elf-unreferenced-symbol-errors",
|
||||||
llvm::cl::desc("Display erors on removal of elf symbols, unreferenced by"
|
llvm::cl::desc("This option is deprecated and has no effect."),
|
||||||
"metadata in exported headers."),
|
|
||||||
llvm::cl::Optional, llvm::cl::cat(header_checker_category));
|
llvm::cl::Optional, llvm::cl::cat(header_checker_category));
|
||||||
|
|
||||||
static llvm::cl::opt<bool> check_all_apis(
|
static llvm::cl::opt<bool> check_all_apis(
|
||||||
@@ -205,17 +204,24 @@ static void ReadConfigFile(const std::string &config_file_path) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char kWarn[] = "\033[36;1mwarning: \033[0m";
|
static std::string GetErrorMessage(CompatibilityStatusIR status) {
|
||||||
static const char kError[] = "\033[31;1merror: \033[0m";
|
if (status & CompatibilityStatusIR::Incompatible) {
|
||||||
|
return "INCOMPATIBLE CHANGES";
|
||||||
bool ShouldEmitWarningMessage(CompatibilityStatusIR status) {
|
}
|
||||||
return ((!allow_extensions &&
|
if (!allow_unreferenced_elf_symbol_changes &&
|
||||||
(status & CompatibilityStatusIR::Extension)) ||
|
(status & CompatibilityStatusIR::ElfIncompatible)) {
|
||||||
(!allow_unreferenced_changes &&
|
return "ELF Symbols not referenced by exported headers removed";
|
||||||
(status & CompatibilityStatusIR::UnreferencedChanges)) ||
|
}
|
||||||
(!allow_unreferenced_elf_symbol_changes &&
|
if (!allow_extensions && (status & CompatibilityStatusIR::Extension)) {
|
||||||
(status & CompatibilityStatusIR::ElfIncompatible)) ||
|
return "EXTENDING CHANGES";
|
||||||
(status & CompatibilityStatusIR::Incompatible));
|
}
|
||||||
|
if (!allow_unreferenced_changes &&
|
||||||
|
(status & CompatibilityStatusIR::UnreferencedChanges)) {
|
||||||
|
return "changes in exported headers, which are not directly referenced "
|
||||||
|
"by exported symbols. This MIGHT be an ABI breaking change due to "
|
||||||
|
"internal typecasts";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, const char **argv) {
|
int main(int argc, const char **argv) {
|
||||||
@@ -244,55 +250,18 @@ int main(int argc, const char **argv) {
|
|||||||
|
|
||||||
CompatibilityStatusIR status = judge.GenerateCompatibilityReport();
|
CompatibilityStatusIR status = judge.GenerateCompatibilityReport();
|
||||||
|
|
||||||
std::string status_str = "";
|
std::string status_str = GetErrorMessage(status);
|
||||||
std::string unreferenced_change_str = "";
|
if (!status_str.empty()) {
|
||||||
std::string error_or_warning_str = kWarn;
|
|
||||||
|
|
||||||
switch (status) {
|
|
||||||
case CompatibilityStatusIR::Incompatible:
|
|
||||||
error_or_warning_str = kError;
|
|
||||||
status_str = "INCOMPATIBLE CHANGES";
|
|
||||||
break;
|
|
||||||
case CompatibilityStatusIR::ElfIncompatible:
|
|
||||||
if (elf_unreferenced_symbol_errors) {
|
|
||||||
error_or_warning_str = kError;
|
|
||||||
}
|
|
||||||
status_str = "ELF Symbols not referenced by exported headers removed";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (status & CompatibilityStatusIR::Extension) {
|
|
||||||
if (!allow_extensions) {
|
|
||||||
error_or_warning_str = kError;
|
|
||||||
}
|
|
||||||
status_str = "EXTENDING CHANGES";
|
|
||||||
}
|
|
||||||
if (status & CompatibilityStatusIR::UnreferencedChanges) {
|
|
||||||
unreferenced_change_str = ", changes in exported headers, which are";
|
|
||||||
unreferenced_change_str += " not directly referenced by exported symbols.";
|
|
||||||
unreferenced_change_str += " This MIGHT be an ABI breaking change due to";
|
|
||||||
unreferenced_change_str += " internal typecasts.";
|
|
||||||
}
|
|
||||||
|
|
||||||
bool should_emit_warning_message = ShouldEmitWarningMessage(status);
|
|
||||||
|
|
||||||
if (should_emit_warning_message) {
|
|
||||||
llvm::errs() << "******************************************************\n"
|
llvm::errs() << "******************************************************\n"
|
||||||
<< error_or_warning_str
|
<< "\033[31;1merror: \033[0m"
|
||||||
<< "VNDK library: "
|
|
||||||
<< lib_name
|
<< lib_name
|
||||||
<< "'s ABI has "
|
<< "'s ABI has "
|
||||||
<< status_str
|
<< status_str
|
||||||
<< unreferenced_change_str
|
<< ". Please check compatibility report at: "
|
||||||
<< " Please check compatibility report at: "
|
|
||||||
<< compatibility_report << "\n"
|
<< compatibility_report << "\n"
|
||||||
<< "******************************************************\n";
|
<< "******************************************************\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!advice_only && should_emit_warning_message) {
|
return (advice_only || status_str.empty()) ? CompatibilityStatusIR::Compatible
|
||||||
return status;
|
: status;
|
||||||
}
|
|
||||||
|
|
||||||
return CompatibilityStatusIR::Compatible;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user