From 5df4bfb6f7762a2ceb438352461f59c8a74ee6cf Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 29 Dec 2022 20:30:10 +0200 Subject: [PATCH] If a binary package is not found, briefly describe what was missing --- source/lib/binarypackage.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/source/lib/binarypackage.cpp b/source/lib/binarypackage.cpp index adfca1a..a366878 100644 --- a/source/lib/binarypackage.cpp +++ b/source/lib/binarypackage.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -71,6 +72,8 @@ void BinaryPackage::do_prepare() bases.push_back(FS::Path()); bool system = false; + unsigned least_missing = numeric_limits::max(); + string missing_name; for(const FS::Path &b: bases) { FS::Path prefix = b; @@ -89,9 +92,12 @@ void BinaryPackage::do_prepare() for(FS::Path &p: libpath) p = prefix/p; - bool all_found = true; + unsigned missing_count = 0; + string first_missing; for(const string &l: export_binfo.libs) - all_found &= (builder.get_vfs().find_library(l, libpath, export_binfo.libmode, system)!=0); + if(!builder.get_vfs().find_library(l, libpath, export_binfo.libmode, system)) + if(!missing_count++) + first_missing = format("library %s", l); VirtualFileSystem::SearchPath incpath = export_binfo.incpath; if(!system && incpath.empty()) @@ -100,21 +106,28 @@ void BinaryPackage::do_prepare() p = prefix/p; for(const string &h: headers) - all_found &= (builder.get_vfs().find_header(h, 0, incpath, system)!=0); + if(!builder.get_vfs().find_header(h, 0, incpath, system)) + if(!missing_count++) + first_missing = h; - if(all_found) + if(!missing_count) { base_path = prefix; builder.get_logger().log("configure", "%s found in %s", name, ((system && use_pkgconfig) ? "system" : base_path.str())); break; } + else if(missing_count1 ? format("%s and %d other files", missing_name, least_missing-1) : missing_name); + builder.get_logger().log("problems", "Cannot locate %s for %s", missing_descr, name); + problems.push_back(format("Cannot locate %s", missing_descr)); return; } -- 2.45.2