From bf6ddeb01806337309eafb87503c698808fbb853 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Wed, 28 Sep 2016 13:15:33 -0700 Subject: Add post build checks for the presence of dlls in static builds --- toolsrc/src/post_build_lint.cpp | 44 ++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) (limited to 'toolsrc/src') diff --git a/toolsrc/src/post_build_lint.cpp b/toolsrc/src/post_build_lint.cpp index 27f89d86b..2b2812d73 100644 --- a/toolsrc/src/post_build_lint.cpp +++ b/toolsrc/src/post_build_lint.cpp @@ -309,6 +309,18 @@ namespace vcpkg return lint_status::SUCCESS; } + static lint_status check_no_dlls_present(const std::vector& dlls) + { + if (dlls.empty()) + { + return lint_status::SUCCESS; + } + + System::println(System::color::warning, "DLLs should not be present in a static build, but the following DLLs were found:"); + print_vector_of_files(dlls); + return lint_status::ERROR; + } + static void operator +=(size_t& left, const lint_status& right) { left += static_cast(right); @@ -328,13 +340,31 @@ namespace vcpkg error_count += check_for_copyright_file(spec, paths); error_count += check_for_exes(spec, paths); - std::vector 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); - - error_count += check_exports_of_dlls(dlls); - error_count += check_uwp_bit_of_dlls(spec.target_triplet().system(), dlls); - error_count += check_architecture(spec.target_triplet().architecture(), dlls); + triplet::BuildType build_type = spec.target_triplet().build_type(); + switch (build_type) + { + case triplet::BuildType::DYNAMIC: + { + std::vector 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); + + error_count += check_exports_of_dlls(dlls); + error_count += check_uwp_bit_of_dlls(spec.target_triplet().system(), dlls); + error_count += check_architecture(spec.target_triplet().architecture(), dlls); + break; + } + case triplet::BuildType::STATIC: + { + std::vector dlls; + recursive_find_files_with_extension_in_dir(paths.packages / spec.dir(), ".dll", dlls); + error_count += check_no_dlls_present(dlls); + break; + } + + default: + Checks::unreachable(); + } std::vector libs; recursive_find_files_with_extension_in_dir(paths.packages / spec.dir() / "lib", ".lib", libs); -- cgit v1.2.3