diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2016-09-28 13:15:33 -0700 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2016-10-05 17:44:02 -0700 |
| commit | bf6ddeb01806337309eafb87503c698808fbb853 (patch) | |
| tree | 00373c74120b228bf5526831453d63433d0bc09c /toolsrc/src/post_build_lint.cpp | |
| parent | 52b7630c86cda1fce144d3bddfc27d434ed3011e (diff) | |
| download | vcpkg-bf6ddeb01806337309eafb87503c698808fbb853.tar.gz vcpkg-bf6ddeb01806337309eafb87503c698808fbb853.zip | |
Add post build checks for the presence of dlls in static builds
Diffstat (limited to 'toolsrc/src/post_build_lint.cpp')
| -rw-r--r-- | toolsrc/src/post_build_lint.cpp | 44 |
1 files changed, 37 insertions, 7 deletions
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<fs::path>& 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<size_t>(right); @@ -328,13 +340,31 @@ namespace vcpkg error_count += check_for_copyright_file(spec, paths); error_count += check_for_exes(spec, paths); - 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); - - 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<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); + + 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<fs::path> 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<fs::path> libs; recursive_find_files_with_extension_in_dir(paths.packages / spec.dir() / "lib", ".lib", libs); |
