From 1b7f21a3e9cb6eb3ccd1a7c22a7813150466ed6c Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Mon, 21 Nov 2016 12:50:23 -0800 Subject: [PATCH] [post-build-checks] Add check about no lib files --- toolsrc/src/post_build_lint.cpp | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/toolsrc/src/post_build_lint.cpp b/toolsrc/src/post_build_lint.cpp index 1a5f22f0ac..1e7e87e6e7 100644 --- a/toolsrc/src/post_build_lint.cpp +++ b/toolsrc/src/post_build_lint.cpp @@ -7,6 +7,9 @@ #include "coff_file_reader.h" #include "BuildInfo.h" #include +#include +#include +#include "vcpkg_Maps.h" namespace fs = std::tr2::sys; @@ -417,6 +420,17 @@ namespace vcpkg return lint_status::ERROR_DETECTED; } + static lint_status check_lib_files_are_available_if_dlls_are_available(const size_t lib_count, const size_t dll_count, const fs::path& lib_dir) + { + if (lib_count == 0 && dll_count != 0) + { + System::println(System::color::warning, "Import libs were not present in %s", lib_dir.generic_string()); + return lint_status::ERROR_DETECTED; + } + + return lint_status::SUCCESS; + } + static lint_status check_no_subdirectories(const fs::path& dir) { const std::vector subdirectories = recursive_find_matching_paths_in_dir(dir, [&](const fs::path& current) @@ -602,8 +616,13 @@ namespace vcpkg error_count += check_for_copyright_file(spec, paths); error_count += check_for_exes(spec, paths); - const std::vector debug_libs = recursive_find_files_with_extension_in_dir(paths.packages / spec.dir() / "debug" / "lib", ".lib"); - const std::vector release_libs = recursive_find_files_with_extension_in_dir(paths.packages / spec.dir() / "lib", ".lib"); + const fs::path debug_lib_dir = paths.packages / spec.dir() / "debug" / "lib"; + const fs::path release_lib_dir = paths.packages / spec.dir() / "lib"; + const fs::path debug_bin_dir = paths.packages / spec.dir() / "debug" / "bin"; + const fs::path release_bin_dir = paths.packages / spec.dir() / "bin"; + + const std::vector debug_libs = recursive_find_files_with_extension_in_dir(debug_lib_dir, ".lib"); + const std::vector release_libs = recursive_find_files_with_extension_in_dir(release_lib_dir, ".lib"); error_count += check_matching_debug_and_release_binaries(debug_libs, release_libs); @@ -617,11 +636,14 @@ namespace vcpkg { case LinkageType::DYNAMIC: { - const std::vector debug_dlls = recursive_find_files_with_extension_in_dir(paths.packages / spec.dir() / "debug" / "bin", ".dll"); - const std::vector release_dlls = recursive_find_files_with_extension_in_dir(paths.packages / spec.dir() / "bin", ".dll"); + const std::vector debug_dlls = recursive_find_files_with_extension_in_dir(debug_bin_dir, ".dll"); + const std::vector release_dlls = recursive_find_files_with_extension_in_dir(release_bin_dir, ".dll"); error_count += check_matching_debug_and_release_binaries(debug_dlls, release_dlls); + error_count += check_lib_files_are_available_if_dlls_are_available(debug_libs.size(), debug_dlls.size(), debug_lib_dir); + error_count += check_lib_files_are_available_if_dlls_are_available(release_libs.size(), release_dlls.size(), release_lib_dir); + std::vector dlls; dlls.insert(dlls.cend(), debug_dlls.cbegin(), debug_dlls.cend()); dlls.insert(dlls.cend(), release_dlls.cbegin(), release_dlls.cend());