diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2016-11-02 14:57:50 -0700 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2016-11-02 14:57:50 -0700 |
| commit | e695f92dec6177ea28554638deb294aa0be2d2e6 (patch) | |
| tree | 45a1549d8bc6664e1d3f4a6c5bf22281a38c3125 /toolsrc/src/post_build_lint.cpp | |
| parent | 4bf461c9cd136df6aa12a02d7f6ec09b91f8acb7 (diff) | |
| download | vcpkg-e695f92dec6177ea28554638deb294aa0be2d2e6.tar.gz vcpkg-e695f92dec6177ea28554638deb294aa0be2d2e6.zip | |
[post-build-checks] Add check for empty directories
Diffstat (limited to 'toolsrc/src/post_build_lint.cpp')
| -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"; |
