diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2016-10-22 20:00:59 -0700 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2016-10-22 20:02:46 -0700 |
| commit | 4fcdf15651690673e61c30f3b3a8b393569d9144 (patch) | |
| tree | 7e137e1250a1ef4b635614ad62cb6baa13bdd71b /toolsrc/src/post_build_lint.cpp | |
| parent | 7db7ea5ceb48d255ecc5d4822e45f24cb67ccf0b (diff) | |
| download | vcpkg-4fcdf15651690673e61c30f3b3a8b393569d9144.tar.gz vcpkg-4fcdf15651690673e61c30f3b3a8b393569d9144.zip | |
[post-build-checks] Add check for mismatching number of debug/release
binaries
Diffstat (limited to 'toolsrc/src/post_build_lint.cpp')
| -rw-r--r-- | toolsrc/src/post_build_lint.cpp | 56 |
1 files changed, 52 insertions, 4 deletions
diff --git a/toolsrc/src/post_build_lint.cpp b/toolsrc/src/post_build_lint.cpp index 33f1160f8..532b189cd 100644 --- a/toolsrc/src/post_build_lint.cpp +++ b/toolsrc/src/post_build_lint.cpp @@ -43,6 +43,13 @@ namespace vcpkg return !fs::is_directory(current) && current.extension() == extension; }, output); } + + std::vector<fs::path> recursive_find_files_with_extension_in_dir(const fs::path& dir, const std::string& extension) + { + std::vector<fs::path> v; + recursive_find_files_with_extension_in_dir(dir, extension, &v); + return v; + } } static lint_status check_for_files_in_include_directory(const package_spec& spec, const vcpkg_paths& paths) @@ -370,6 +377,36 @@ namespace vcpkg return lint_status::ERROR_DETECTED; } + static lint_status check_matching_debug_and_release_binaries(const std::vector<fs::path>& debug_binaries, const std::vector<fs::path>& release_binaries) + { + const size_t debug_count = debug_binaries.size(); + const size_t release_count = release_binaries.size(); + if (debug_count == release_count) + { + return lint_status::SUCCESS; + } + + System::println(System::color::warning, "Mismatching number of debug and release binaries. Found %d for debug but %d for release.", debug_count, release_count); + System::println("Debug binaries"); + print_vector_of_files(debug_binaries); + + System::println("Release binaries"); + print_vector_of_files(release_binaries); + + if (debug_count == 0) + { + System::println(System::color::warning, "Debug binaries were not built"); + } + if (release_count == 0) + { + System::println(System::color::warning, "Release binaries were not built"); + } + + System::println(""); + + return lint_status::ERROR_DETECTED; + } + static void operator +=(size_t& left, const lint_status& right) { left += static_cast<size_t>(right); @@ -394,9 +431,14 @@ namespace vcpkg { case triplet::BuildType::DYNAMIC: { + const std::vector<fs::path> debug_dlls = recursive_find_files_with_extension_in_dir(paths.packages / spec.dir() / "bin", ".dll"); + const std::vector<fs::path> release_dlls = recursive_find_files_with_extension_in_dir(paths.packages / spec.dir() / "debug" / "bin", ".dll"); + + error_count += check_matching_debug_and_release_binaries(debug_dlls, release_dlls); + std::vector<fs::path> dlls; - recursive_find_files_with_extension_in_dir(paths.packages / spec.dir() / "bin", ".dll", &dlls); - recursive_find_files_with_extension_in_dir(paths.packages / spec.dir() / "debug" / "bin", ".dll", &dlls); + dlls.insert(dlls.cend(), debug_dlls.cbegin(), debug_dlls.cend()); + dlls.insert(dlls.cend(), release_dlls.cbegin(), release_dlls.cend()); error_count += check_exports_of_dlls(dlls); error_count += check_uwp_bit_of_dlls(spec.target_triplet().system(), dlls); @@ -416,9 +458,15 @@ namespace vcpkg Checks::unreachable(); } + const std::vector<fs::path> debug_libs = recursive_find_files_with_extension_in_dir(paths.packages / spec.dir() / "lib", ".lib"); + const std::vector<fs::path> release_libs = recursive_find_files_with_extension_in_dir(paths.packages / spec.dir() / "debug" / "lib", ".lib"); + + error_count += check_matching_debug_and_release_binaries(debug_libs, release_libs); + std::vector<fs::path> libs; - recursive_find_files_with_extension_in_dir(paths.packages / spec.dir() / "lib", ".lib", &libs); - recursive_find_files_with_extension_in_dir(paths.packages / spec.dir() / "debug" / "lib", ".lib", &libs); + libs.insert(libs.cend(), debug_libs.cbegin(), debug_libs.cend()); + libs.insert(libs.cend(), release_libs.cbegin(), release_libs.cend()); + error_count += check_lib_architecture(spec.target_triplet().architecture(), libs); if (error_count != 0) |
