diff options
Diffstat (limited to 'toolsrc/src')
| -rw-r--r-- | toolsrc/src/post_build_lint.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/toolsrc/src/post_build_lint.cpp b/toolsrc/src/post_build_lint.cpp index 40ddef3bb..8301e74cc 100644 --- a/toolsrc/src/post_build_lint.cpp +++ b/toolsrc/src/post_build_lint.cpp @@ -464,6 +464,29 @@ namespace vcpkg return lint_status::ERROR_DETECTED; } + static lint_status check_no_empty_folders(const fs::path& dir) + { + const std::vector<fs::path> empty_directories = recursive_find_matching_paths_in_dir(dir, [](const fs::path& current) + { + return fs::is_directory(current) && fs::is_empty(current); + }); + + if (!empty_directories.empty()) + { + System::println(System::color::warning, "There should be no empty directories in %s", dir.generic_string()); + System::println("The following empty directories were found: "); + print_vector_of_files(empty_directories); + System::println(System::color::warning, "If a directory should be populated but is not, this might indicate an error in the portfile.\n" + "If the directories are not needed and their creation cannot be disabled, use something like this in the portfile to remove them)\n" + "\n" + R"###( file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/a/dir ${CURRENT_PACKAGES_DIR}/some/other/dir))###""\n" + "\n"); + return lint_status::ERROR_DETECTED; + } + + return lint_status::SUCCESS; + } + static void operator +=(size_t& left, const lint_status& right) { left += static_cast<size_t>(right); @@ -530,6 +553,8 @@ namespace vcpkg error_count += check_lib_architecture(spec.target_triplet().architecture(), libs); + error_count += check_no_empty_folders(paths.packages / spec.dir()); + if (error_count != 0) { const fs::path portfile = paths.ports / spec.name() / "portfile.cmake"; |
