diff options
| author | Alexander Kaspar <alexander.kaspar@gmail.com> | 2016-12-01 08:59:01 +0100 |
|---|---|---|
| committer | Alexander Kaspar <alexander.kaspar@gmail.com> | 2016-12-01 08:59:01 +0100 |
| commit | 7f9353dd9541ca15ebefa66e531e4bac4ad7c871 (patch) | |
| tree | d1775b00285b0583c71163b3d219f9c539536399 | |
| parent | 5a04753a4a99a6210990b25e8773b86ccbffec0b (diff) | |
| parent | 223e7f970d30d3d97e64af3d1970d52cc0ddaaf5 (diff) | |
| download | vcpkg-7f9353dd9541ca15ebefa66e531e4bac4ad7c871.tar.gz vcpkg-7f9353dd9541ca15ebefa66e531e4bac4ad7c871.zip | |
Merge branch 'master' of https://github.com/Microsoft/vcpkg into qca
| -rw-r--r-- | ports/yaml-cpp/CONTROL | 3 | ||||
| -rw-r--r-- | ports/yaml-cpp/portfile.cmake | 38 | ||||
| -rw-r--r-- | toolsrc/include/BuildInfo.h | 6 | ||||
| -rw-r--r-- | toolsrc/include/Paragraphs.h | 3 | ||||
| -rw-r--r-- | toolsrc/include/coff_file_reader.h | 4 | ||||
| -rw-r--r-- | toolsrc/include/filesystem_fs.h | 5 | ||||
| -rw-r--r-- | toolsrc/include/post_build_lint.h | 4 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg.h | 3 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_Files.h | 43 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_System.h | 5 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_paths.h | 4 | ||||
| -rw-r--r-- | toolsrc/src/BuildInfo.cpp | 6 | ||||
| -rw-r--r-- | toolsrc/src/commands_hash.cpp | 2 | ||||
| -rw-r--r-- | toolsrc/src/commands_installation.cpp | 4 | ||||
| -rw-r--r-- | toolsrc/src/commands_search.cpp | 2 | ||||
| -rw-r--r-- | toolsrc/src/metrics.cpp | 4 | ||||
| -rw-r--r-- | toolsrc/src/post_build_lint.cpp | 151 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg.cpp | 1 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_Files.cpp | 59 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_System.cpp | 2 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_metrics_uploader.cpp | 2 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_paths.cpp | 1 | ||||
| -rw-r--r-- | toolsrc/vcpkg/vcpkg.vcxproj | 1 | ||||
| -rw-r--r-- | toolsrc/vcpkg/vcpkg.vcxproj.filters | 3 |
24 files changed, 208 insertions, 148 deletions
diff --git a/ports/yaml-cpp/CONTROL b/ports/yaml-cpp/CONTROL new file mode 100644 index 000000000..f55ccfc4f --- /dev/null +++ b/ports/yaml-cpp/CONTROL @@ -0,0 +1,3 @@ +Source: yaml-cpp +Version: 0.5.4 candidate +Description: yaml-cpp is a YAML parser and emitter in C++ matching the YAML 1.2 spec. diff --git a/ports/yaml-cpp/portfile.cmake b/ports/yaml-cpp/portfile.cmake new file mode 100644 index 000000000..69f838884 --- /dev/null +++ b/ports/yaml-cpp/portfile.cmake @@ -0,0 +1,38 @@ +# Common Ambient Variables: +# VCPKG_ROOT_DIR = <C:\path\to\current\vcpkg> +# TARGET_TRIPLET is the current triplet (x86-windows, etc) +# PORT is the current port name (zlib, etc) +# CURRENT_BUILDTREES_DIR = ${VCPKG_ROOT_DIR}\buildtrees\${PORT} +# CURRENT_PACKAGES_DIR = ${VCPKG_ROOT_DIR}\packages\${PORT}_${TARGET_TRIPLET} +# + +include(vcpkg_common_functions) +set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/yaml-cpp-380ecb404ef99ba132154ed43dd2b84136b30b14) +vcpkg_download_distfile(ARCHIVE + URLS "https://github.com/jbeder/yaml-cpp/archive/380ecb404ef99ba132154ed43dd2b84136b30b14.zip" + FILENAME "380ecb404ef99ba132154ed43dd2b84136b30b14.zip" + SHA512 7e090b53ba760f4f9a44701359fe2c30c05f1bbcd2cba78a8f9a88c651b09be6d592e65826fbacb9dd7317afbe3cd968be531b89f83e79f15cd97e9c27d17232 +) +vcpkg_extract_source_archive(${ARCHIVE}) + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH} + # OPTIONS -DUSE_THIS_IN_ALL_BUILDS=1 -DUSE_THIS_TOO=2 + # OPTIONS_RELEASE -DOPTIMIZE=1 + # OPTIONS_DEBUG -DDEBUGGABLE=1 +) + +vcpkg_install_cmake() + +vcpkg_copy_pdbs() + +# Remove debug include files +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) +# Remove cmake files +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/CMake) +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/CMake) + +# Handle copyright +file(COPY ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/yaml-cpp) +file(RENAME ${CURRENT_PACKAGES_DIR}/share/yaml-cpp/LICENSE ${CURRENT_PACKAGES_DIR}/share/yaml-cpp/copyright) + diff --git a/toolsrc/include/BuildInfo.h b/toolsrc/include/BuildInfo.h index ccf40abbf..9f872385e 100644 --- a/toolsrc/include/BuildInfo.h +++ b/toolsrc/include/BuildInfo.h @@ -4,9 +4,7 @@ #include "Paragraphs.h" #include <regex> -namespace fs = std::tr2::sys; - -namespace vcpkg +namespace vcpkg { namespace PostBuildLint { enum class LinkageType { @@ -128,4 +126,4 @@ namespace vcpkg }; BuildInfo read_build_info(const fs::path& filepath); -} +}} diff --git a/toolsrc/include/Paragraphs.h b/toolsrc/include/Paragraphs.h index 22aaefe98..9e9fafe49 100644 --- a/toolsrc/include/Paragraphs.h +++ b/toolsrc/include/Paragraphs.h @@ -1,11 +1,10 @@ #pragma once -#include <filesystem> +#include "filesystem_fs.h" #include <unordered_map> namespace vcpkg { namespace Paragraphs { - namespace fs = std::tr2::sys; std::vector<std::unordered_map<std::string, std::string>> get_paragraphs(const fs::path& control_path); std::vector<std::unordered_map<std::string, std::string>> parse_paragraphs(const std::string& str); }} diff --git a/toolsrc/include/coff_file_reader.h b/toolsrc/include/coff_file_reader.h index 81f107f10..1a9a071ef 100644 --- a/toolsrc/include/coff_file_reader.h +++ b/toolsrc/include/coff_file_reader.h @@ -1,12 +1,10 @@ #pragma once #include <vector> #include "MachineType.h" -#include <filesystem> +#include "filesystem_fs.h" namespace vcpkg {namespace COFFFileReader { - namespace fs = std::tr2::sys; - struct dll_info { MachineType machine_type; diff --git a/toolsrc/include/filesystem_fs.h b/toolsrc/include/filesystem_fs.h new file mode 100644 index 000000000..ece485c23 --- /dev/null +++ b/toolsrc/include/filesystem_fs.h @@ -0,0 +1,5 @@ +#pragma once + +#include <filesystem> + +namespace fs = std::tr2::sys;
\ No newline at end of file diff --git a/toolsrc/include/post_build_lint.h b/toolsrc/include/post_build_lint.h index bc916a7af..a5fb9149f 100644 --- a/toolsrc/include/post_build_lint.h +++ b/toolsrc/include/post_build_lint.h @@ -2,7 +2,7 @@ #include "package_spec.h" #include "vcpkg_paths.h" -namespace vcpkg +namespace vcpkg {namespace PostBuildLint { void perform_all_checks(const package_spec& spec, const vcpkg_paths& paths); -} +}} diff --git a/toolsrc/include/vcpkg.h b/toolsrc/include/vcpkg.h index 81b4d45ba..832fb1920 100644 --- a/toolsrc/include/vcpkg.h +++ b/toolsrc/include/vcpkg.h @@ -1,6 +1,5 @@ #pragma once -#include <filesystem> #include "package_spec.h" #include "BinaryParagraph.h" #include "StatusParagraphs.h" @@ -8,8 +7,6 @@ namespace vcpkg { - namespace fs = std::tr2::sys; - extern bool g_do_dry_run; StatusParagraphs database_load_check(const vcpkg_paths& paths); diff --git a/toolsrc/include/vcpkg_Files.h b/toolsrc/include/vcpkg_Files.h index 445713965..8b320303d 100644 --- a/toolsrc/include/vcpkg_Files.h +++ b/toolsrc/include/vcpkg_Files.h @@ -1,17 +1,52 @@ #pragma once #include "expected.h" -#include <filesystem> +#include "filesystem_fs.h" +#include <iterator> namespace vcpkg {namespace Files { static const char* FILESYSTEM_INVALID_CHARACTERS = R"(\/:*?"<>|)"; - void check_is_directory(const std::tr2::sys::path& dirpath); + void check_is_directory(const fs::path& dirpath); bool has_invalid_chars_for_filesystem(const std::string s); - expected<std::string> get_contents(const std::tr2::sys::path& file_path) noexcept; + expected<std::string> get_contents(const fs::path& file_path) noexcept; - std::tr2::sys::path find_file_recursively_up(const std::tr2::sys::path& starting_dir, const std::string& filename); + fs::path find_file_recursively_up(const fs::path& starting_dir, const std::string& filename); + + template <class Pred> + void non_recursive_find_matching_paths_in_dir(const fs::path& dir, const Pred predicate, std::vector<fs::path>* output) + { + std::copy_if(fs::directory_iterator(dir), fs::directory_iterator(), std::back_inserter(*output), predicate); + } + + template <class Pred> + void recursive_find_matching_paths_in_dir(const fs::path& dir, const Pred predicate, std::vector<fs::path>* output) + { + std::copy_if(fs::recursive_directory_iterator(dir), fs::recursive_directory_iterator(), std::back_inserter(*output), predicate); + } + + template <class Pred> + std::vector<fs::path> recursive_find_matching_paths_in_dir(const fs::path& dir, const Pred predicate) + { + std::vector<fs::path> v; + recursive_find_matching_paths_in_dir(dir, predicate, &v); + return v; + } + + void recursive_find_files_with_extension_in_dir(const fs::path& dir, const std::string& extension, std::vector<fs::path>* output); + + std::vector<fs::path> recursive_find_files_with_extension_in_dir(const fs::path& dir, const std::string& extension); + + void recursive_find_all_files_in_dir(const fs::path& dir, std::vector<fs::path>* output); + + std::vector<fs::path> recursive_find_all_files_in_dir(const fs::path& dir); + + void non_recursive_find_all_files_in_dir(const fs::path& dir, std::vector<fs::path>* output); + + std::vector<fs::path> non_recursive_find_all_files_in_dir(const fs::path& dir); + + void print_paths(const std::vector<fs::path>& paths); }} diff --git a/toolsrc/include/vcpkg_System.h b/toolsrc/include/vcpkg_System.h index c420464c1..e059bde0a 100644 --- a/toolsrc/include/vcpkg_System.h +++ b/toolsrc/include/vcpkg_System.h @@ -1,12 +1,11 @@ #pragma once #include "vcpkg_Strings.h" - -#include <filesystem> +#include "filesystem_fs.h" namespace vcpkg {namespace System { - std::tr2::sys::path get_exe_path_of_current_process(); + fs::path get_exe_path_of_current_process(); struct exit_code_and_output { diff --git a/toolsrc/include/vcpkg_paths.h b/toolsrc/include/vcpkg_paths.h index 2dc9c7636..a2932070d 100644 --- a/toolsrc/include/vcpkg_paths.h +++ b/toolsrc/include/vcpkg_paths.h @@ -1,13 +1,11 @@ #pragma once -#include <filesystem> +#include "filesystem_fs.h" #include "expected.h" #include "package_spec.h" #include "BinaryParagraph.h" namespace vcpkg { - namespace fs = std::tr2::sys; - struct vcpkg_paths { static expected<vcpkg_paths> create(const fs::path& vcpkg_root_dir); diff --git a/toolsrc/src/BuildInfo.cpp b/toolsrc/src/BuildInfo.cpp index 44c7fdcf0..ddd44a1e6 100644 --- a/toolsrc/src/BuildInfo.cpp +++ b/toolsrc/src/BuildInfo.cpp @@ -2,7 +2,7 @@ #include "vcpkg_Checks.h" #include "vcpkglib_helpers.h" -namespace vcpkg +namespace vcpkg { namespace PostBuildLint { const ConfigurationType& BuildType::config() const { @@ -127,7 +127,7 @@ namespace vcpkg BuildInfo read_build_info(const fs::path& filepath) { const std::vector<std::unordered_map<std::string, std::string>> pghs = Paragraphs::get_paragraphs(filepath); - Checks::check_throw(pghs.size() == 1, "Invalid BUILD_INFO file for package"); + Checks::check_exit(pghs.size() == 1, "Invalid BUILD_INFO file for package"); return BuildInfo::create(pghs[0]); } @@ -161,4 +161,4 @@ namespace vcpkg { return this->m_dll_name; } -} +}} diff --git a/toolsrc/src/commands_hash.cpp b/toolsrc/src/commands_hash.cpp index 4b89f2894..17c191b78 100644 --- a/toolsrc/src/commands_hash.cpp +++ b/toolsrc/src/commands_hash.cpp @@ -1,8 +1,6 @@ #include "vcpkg_Commands.h" #include "vcpkg_System.h" -namespace fs = std::tr2::sys; - namespace vcpkg { static void do_file_hash(fs::path const& path, std::wstring const& hashType) diff --git a/toolsrc/src/commands_installation.cpp b/toolsrc/src/commands_installation.cpp index f7af2ef7c..93335220d 100644 --- a/toolsrc/src/commands_installation.cpp +++ b/toolsrc/src/commands_installation.cpp @@ -59,7 +59,7 @@ namespace vcpkg exit(EXIT_FAILURE); } - perform_all_checks(spec, paths); + PostBuildLint::perform_all_checks(spec, paths); create_binary_control_file(paths, source_paragraph, target_triplet); @@ -140,7 +140,7 @@ namespace vcpkg const std::unordered_set<std::string> options = args.check_and_get_optional_command_arguments({OPTION_CHECKS_ONLY}); if (options.find(OPTION_CHECKS_ONLY) != options.end()) { - perform_all_checks(spec, paths); + PostBuildLint::perform_all_checks(spec, paths); exit(EXIT_SUCCESS); } diff --git a/toolsrc/src/commands_search.cpp b/toolsrc/src/commands_search.cpp index 923368252..a604c5383 100644 --- a/toolsrc/src/commands_search.cpp +++ b/toolsrc/src/commands_search.cpp @@ -4,8 +4,6 @@ #include "vcpkglib_helpers.h" #include "SourceParagraph.h" -namespace fs = std::tr2::sys; - namespace vcpkg { static std::vector<SourceParagraph> read_all_source_paragraphs(const vcpkg_paths& paths) diff --git a/toolsrc/src/metrics.cpp b/toolsrc/src/metrics.cpp index ada065fd6..23962bcfe 100644 --- a/toolsrc/src/metrics.cpp +++ b/toolsrc/src/metrics.cpp @@ -10,12 +10,10 @@ #include <Windows.h> #include <winhttp.h> #include <fstream> -#include <filesystem> +#include "filesystem_fs.h" #include "vcpkg_Strings.h" #include "vcpkg_System.h" -namespace fs = std::tr2::sys; - namespace vcpkg { static std::string GetCurrentDateTime() diff --git a/toolsrc/src/post_build_lint.cpp b/toolsrc/src/post_build_lint.cpp index d358cca45..3043bd4fa 100644 --- a/toolsrc/src/post_build_lint.cpp +++ b/toolsrc/src/post_build_lint.cpp @@ -1,16 +1,13 @@ -#include <filesystem> #include "vcpkg_paths.h" #include "package_spec.h" -#include <iterator> +#include "vcpkg_Files.h" #include <functional> #include "vcpkg_System.h" #include "coff_file_reader.h" #include "BuildInfo.h" #include <regex> -namespace fs = std::tr2::sys; - -namespace vcpkg +namespace vcpkg { namespace PostBuildLint { enum class lint_status { @@ -20,54 +17,6 @@ namespace vcpkg static const fs::path DUMPBIN_EXE = R"(%VS140COMNTOOLS%\..\..\VC\bin\dumpbin.exe)"; - namespace - { - void print_vector_of_files(const std::vector<fs::path>& paths) - { - System::println(""); - for (const fs::path& p : paths) - { - System::println(" %s", p.generic_string()); - } - System::println(""); - } - - template <class Pred> - void non_recursive_find_matching_paths_in_dir(const fs::path& dir, const Pred predicate, std::vector<fs::path>* output) - { - std::copy_if(fs::directory_iterator(dir), fs::directory_iterator(), std::back_inserter(*output), predicate); - } - - template <class Pred> - void recursive_find_matching_paths_in_dir(const fs::path& dir, const Pred predicate, std::vector<fs::path>* output) - { - std::copy_if(fs::recursive_directory_iterator(dir), fs::recursive_directory_iterator(), std::back_inserter(*output), predicate); - } - - template <class Pred> - std::vector<fs::path> recursive_find_matching_paths_in_dir(const fs::path& dir, const Pred predicate) - { - std::vector<fs::path> v; - recursive_find_matching_paths_in_dir(dir, predicate, &v); - return v; - } - - void recursive_find_files_with_extension_in_dir(const fs::path& dir, const std::string& extension, std::vector<fs::path>* output) - { - recursive_find_matching_paths_in_dir(dir, [&extension](const fs::path& current) - { - 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 fs::path& package_dir) { const fs::path include_dir = package_dir / "include"; @@ -85,10 +34,10 @@ namespace vcpkg const fs::path debug_include_dir = package_dir / "debug" / "include"; std::vector<fs::path> files_found; - recursive_find_matching_paths_in_dir(debug_include_dir, [&](const fs::path& current) - { - return !fs::is_directory(current) && current.extension() != ".ifc"; - }, &files_found); + Files::recursive_find_matching_paths_in_dir(debug_include_dir, [&](const fs::path& current) + { + return !fs::is_directory(current) && current.extension() != ".ifc"; + }, &files_found); if (!files_found.empty()) { @@ -129,15 +78,15 @@ namespace vcpkg static lint_status check_for_misplaced_cmake_files(const fs::path& package_dir, const package_spec& spec) { std::vector<fs::path> misplaced_cmake_files; - recursive_find_files_with_extension_in_dir(package_dir / "cmake", ".cmake", &misplaced_cmake_files); - recursive_find_files_with_extension_in_dir(package_dir / "debug" / "cmake", ".cmake", &misplaced_cmake_files); - recursive_find_files_with_extension_in_dir(package_dir / "lib" / "cmake", ".cmake", &misplaced_cmake_files); - recursive_find_files_with_extension_in_dir(package_dir / "debug" / "lib" / "cmake", ".cmake", &misplaced_cmake_files); + Files::recursive_find_files_with_extension_in_dir(package_dir / "cmake", ".cmake", &misplaced_cmake_files); + Files::recursive_find_files_with_extension_in_dir(package_dir / "debug" / "cmake", ".cmake", &misplaced_cmake_files); + Files::recursive_find_files_with_extension_in_dir(package_dir / "lib" / "cmake", ".cmake", &misplaced_cmake_files); + Files::recursive_find_files_with_extension_in_dir(package_dir / "debug" / "lib" / "cmake", ".cmake", &misplaced_cmake_files); if (!misplaced_cmake_files.empty()) { System::println(System::color::warning, "The following cmake files were found outside /share/%s. Please place cmake files in /share/%s.", spec.name(), spec.name()); - print_vector_of_files(misplaced_cmake_files); + Files::print_paths(misplaced_cmake_files); return lint_status::ERROR_DETECTED; } @@ -159,13 +108,13 @@ namespace vcpkg static lint_status check_for_dlls_in_lib_dirs(const fs::path& package_dir) { std::vector<fs::path> dlls; - recursive_find_files_with_extension_in_dir(package_dir / "lib", ".dll", &dlls); - recursive_find_files_with_extension_in_dir(package_dir / "debug" / "lib", ".dll", &dlls); + Files::recursive_find_files_with_extension_in_dir(package_dir / "lib", ".dll", &dlls); + Files::recursive_find_files_with_extension_in_dir(package_dir / "debug" / "lib", ".dll", &dlls); if (!dlls.empty()) { System::println(System::color::warning, "\nThe following dlls were found in /lib and /debug/lib. Please move them to /bin or /debug/bin, respectively."); - print_vector_of_files(dlls); + Files::print_paths(dlls); return lint_status::ERROR_DETECTED; } @@ -213,7 +162,7 @@ namespace vcpkg if (potential_copyright_files.size() > 1) { System::println(System::color::warning, "The following files are potential copyright files:"); - print_vector_of_files(potential_copyright_files); + Files::print_paths(potential_copyright_files); } System::println(" %s/share/%s/copyright", packages_dir.generic_string(), spec.name()); @@ -223,13 +172,13 @@ namespace vcpkg static lint_status check_for_exes(const fs::path& package_dir) { std::vector<fs::path> exes; - recursive_find_files_with_extension_in_dir(package_dir / "bin", ".exe", &exes); - recursive_find_files_with_extension_in_dir(package_dir / "debug" / "bin", ".exe", &exes); + Files::recursive_find_files_with_extension_in_dir(package_dir / "bin", ".exe", &exes); + Files::recursive_find_files_with_extension_in_dir(package_dir / "debug" / "bin", ".exe", &exes); if (!exes.empty()) { System::println(System::color::warning, "The following EXEs were found in /bin and /debug/bin. EXEs are not valid distribution targets."); - print_vector_of_files(exes); + Files::print_paths(exes); return lint_status::ERROR_DETECTED; } @@ -254,7 +203,7 @@ namespace vcpkg if (!dlls_with_no_exports.empty()) { System::println(System::color::warning, "The following DLLs have no exports:"); - print_vector_of_files(dlls_with_no_exports); + Files::print_paths(dlls_with_no_exports); System::println(System::color::warning, "DLLs without any exports are likely a bug in the build script."); return lint_status::ERROR_DETECTED; } @@ -285,7 +234,7 @@ namespace vcpkg if (!dlls_with_improper_uwp_bit.empty()) { System::println(System::color::warning, "The following DLLs do not have the App Container bit set:"); - print_vector_of_files(dlls_with_improper_uwp_bit); + Files::print_paths(dlls_with_improper_uwp_bit); System::println(System::color::warning, "This bit is required for Windows Store apps."); return lint_status::ERROR_DETECTED; } @@ -387,7 +336,7 @@ namespace vcpkg } 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); + Files::print_paths(dlls); return lint_status::ERROR_DETECTED; } @@ -402,10 +351,10 @@ namespace vcpkg 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); + Files::print_paths(debug_binaries); System::println("Release binaries"); - print_vector_of_files(release_binaries); + Files::print_paths(release_binaries); if (debug_count == 0) { @@ -434,16 +383,16 @@ namespace vcpkg static lint_status check_no_subdirectories(const fs::path& dir) { - const std::vector<fs::path> subdirectories = recursive_find_matching_paths_in_dir(dir, [&](const fs::path& current) - { - return fs::is_directory(current); - }); + const std::vector<fs::path> subdirectories = Files::recursive_find_matching_paths_in_dir(dir, [&](const fs::path& current) + { + return fs::is_directory(current); + }); if (!subdirectories.empty()) { System::println(System::color::warning, "Directory %s should have no subdirectories", dir.generic_string()); System::println("The following subdirectories were found: "); - print_vector_of_files(subdirectories); + Files::print_paths(subdirectories); return lint_status::ERROR_DETECTED; } @@ -483,16 +432,16 @@ namespace vcpkg 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); - }); + const std::vector<fs::path> empty_directories = Files::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); + Files::print_paths(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" @@ -599,22 +548,19 @@ namespace vcpkg { std::vector<fs::path> misplaced_files; - non_recursive_find_matching_paths_in_dir(package_dir, [](const fs::path& current) - { - const std::string filename = current.filename().generic_string(); - return !fs::is_directory(current) && !((_stricmp(filename.c_str(), "CONTROL") == 0 || _stricmp(filename.c_str(), "BUILD_INFO") == 0)); - }, &misplaced_files); + Files::non_recursive_find_matching_paths_in_dir(package_dir, [](const fs::path& current) + { + const std::string filename = current.filename().generic_string(); + return !fs::is_directory(current) && !((_stricmp(filename.c_str(), "CONTROL") == 0 || _stricmp(filename.c_str(), "BUILD_INFO") == 0)); + }, &misplaced_files); const fs::path debug_dir = package_dir / "debug"; - non_recursive_find_matching_paths_in_dir(debug_dir, [](const fs::path& current) - { - return !fs::is_directory(current); - }, &misplaced_files); + Files::non_recursive_find_all_files_in_dir(debug_dir, &misplaced_files); if (!misplaced_files.empty()) { System::println(System::color::warning, "The following files are placed in\n%s and\n%s: ", package_dir.generic_string(), debug_dir.generic_string()); - print_vector_of_files(misplaced_files); + Files::print_paths(misplaced_files); System::println(System::color::warning, "Files cannot be present in those directories.\n"); return lint_status::ERROR_DETECTED; } @@ -645,14 +591,13 @@ namespace vcpkg error_count += check_for_copyright_file(spec, paths); error_count += check_for_exes(package_dir); - const fs::path debug_lib_dir = package_dir / "debug" / "lib"; const fs::path release_lib_dir = package_dir / "lib"; const fs::path debug_bin_dir = package_dir / "debug" / "bin"; const fs::path release_bin_dir = package_dir / "bin"; - const std::vector<fs::path> debug_libs = recursive_find_files_with_extension_in_dir(debug_lib_dir, ".lib"); - const std::vector<fs::path> release_libs = recursive_find_files_with_extension_in_dir(release_lib_dir, ".lib"); + const std::vector<fs::path> debug_libs = Files::recursive_find_files_with_extension_in_dir(debug_lib_dir, ".lib"); + const std::vector<fs::path> release_libs = Files::recursive_find_files_with_extension_in_dir(release_lib_dir, ".lib"); error_count += check_matching_debug_and_release_binaries(debug_libs, release_libs); @@ -666,8 +611,8 @@ namespace vcpkg { case LinkageType::DYNAMIC: { - const std::vector<fs::path> debug_dlls = recursive_find_files_with_extension_in_dir(debug_bin_dir, ".dll"); - const std::vector<fs::path> release_dlls = recursive_find_files_with_extension_in_dir(release_bin_dir, ".dll"); + const std::vector<fs::path> debug_dlls = Files::recursive_find_files_with_extension_in_dir(debug_bin_dir, ".dll"); + const std::vector<fs::path> release_dlls = Files::recursive_find_files_with_extension_in_dir(release_bin_dir, ".dll"); error_count += check_matching_debug_and_release_binaries(debug_dlls, release_dlls); @@ -688,7 +633,7 @@ namespace vcpkg case LinkageType::STATIC: { std::vector<fs::path> dlls; - recursive_find_files_with_extension_in_dir(package_dir, ".dll", &dlls); + Files::recursive_find_files_with_extension_in_dir(package_dir, ".dll", &dlls); error_count += check_no_dlls_present(dlls); error_count += check_bin_folders_are_not_present_in_static_build(package_dir); @@ -707,8 +652,8 @@ namespace vcpkg Checks::unreachable(); } #if 0 - error_count += check_no_subdirectories(package_dir / "lib"); - error_count += check_no_subdirectories(package_dir / "debug" / "lib"); + error_count += check_no_subdirectories(package_dir / "lib"); + error_count += check_no_subdirectories(package_dir / "debug" / "lib"); #endif error_count += check_no_empty_folders(package_dir); @@ -723,4 +668,4 @@ namespace vcpkg System::println("-- Performing post-build validation done"); } -} +}} diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp index b1fe76982..4b65ea972 100644 --- a/toolsrc/src/vcpkg.cpp +++ b/toolsrc/src/vcpkg.cpp @@ -6,7 +6,6 @@ #include <string> #include <unordered_map> #include <memory> -#include <filesystem> #include <vector> #include <cassert> #include "vcpkg_Files.h" diff --git a/toolsrc/src/vcpkg_Files.cpp b/toolsrc/src/vcpkg_Files.cpp index 611aa7450..698579736 100644 --- a/toolsrc/src/vcpkg_Files.cpp +++ b/toolsrc/src/vcpkg_Files.cpp @@ -1,9 +1,7 @@ #include "vcpkg_Files.h" #include <fstream> -#include <filesystem> #include <regex> - -namespace fs = std::tr2::sys; +#include "vcpkg_System.h" namespace vcpkg {namespace Files { @@ -58,4 +56,59 @@ namespace vcpkg {namespace Files return current_dir; } + + void recursive_find_files_with_extension_in_dir(const fs::path& dir, const std::string& extension, std::vector<fs::path>* output) + { + recursive_find_matching_paths_in_dir(dir, [&extension](const fs::path& current) + { + 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; + } + + void recursive_find_all_files_in_dir(const fs::path& dir, std::vector<fs::path>* output) + { + recursive_find_matching_paths_in_dir(dir, [&](const fs::path& current) + { + return !fs::is_directory(current); + }, output); + } + + std::vector<fs::path> recursive_find_all_files_in_dir(const fs::path& dir) + { + std::vector<fs::path> v; + recursive_find_all_files_in_dir(dir, &v); + return v; + } + + void non_recursive_find_all_files_in_dir(const fs::path& dir, std::vector<fs::path>* output) + { + non_recursive_find_matching_paths_in_dir(dir, [&](const fs::path& current) + { + return !fs::is_directory(current); + }, output); + } + + std::vector<fs::path> non_recursive_find_all_files_in_dir(const fs::path& dir) + { + std::vector<fs::path> v; + non_recursive_find_all_files_in_dir(dir, &v); + return v; + } + + void print_paths(const std::vector<fs::path>& paths) + { + System::println(""); + for (const fs::path& p : paths) + { + System::println(" %s", p.generic_string()); + } + System::println(""); + } }} diff --git a/toolsrc/src/vcpkg_System.cpp b/toolsrc/src/vcpkg_System.cpp index cc7080069..cb3eb6584 100644 --- a/toolsrc/src/vcpkg_System.cpp +++ b/toolsrc/src/vcpkg_System.cpp @@ -3,8 +3,6 @@ #include <Windows.h> #include <regex> -namespace fs = std::tr2::sys; - namespace vcpkg {namespace System { fs::path get_exe_path_of_current_process() diff --git a/toolsrc/src/vcpkg_metrics_uploader.cpp b/toolsrc/src/vcpkg_metrics_uploader.cpp index f1f4a52ed..63668d1d7 100644 --- a/toolsrc/src/vcpkg_metrics_uploader.cpp +++ b/toolsrc/src/vcpkg_metrics_uploader.cpp @@ -1,10 +1,8 @@ #include "metrics.h" -#include <filesystem> #include "vcpkg_Checks.h" #include "vcpkg_Files.h" #include <Windows.h> -namespace fs = std::tr2::sys; using namespace vcpkg; int WINAPI diff --git a/toolsrc/src/vcpkg_paths.cpp b/toolsrc/src/vcpkg_paths.cpp index 5347b79d8..b7e716307 100644 --- a/toolsrc/src/vcpkg_paths.cpp +++ b/toolsrc/src/vcpkg_paths.cpp @@ -1,4 +1,3 @@ -#include <filesystem> #include "expected.h" #include "vcpkg_paths.h" #include "metrics.h" diff --git a/toolsrc/vcpkg/vcpkg.vcxproj b/toolsrc/vcpkg/vcpkg.vcxproj index 9d9022229..7fab309d3 100644 --- a/toolsrc/vcpkg/vcpkg.vcxproj +++ b/toolsrc/vcpkg/vcpkg.vcxproj @@ -154,6 +154,7 @@ </ItemGroup> <ItemGroup> <ClInclude Include="..\include\coff_file_reader.h" /> + <ClInclude Include="..\include\filesystem_fs.h" /> <ClInclude Include="..\include\MachineType.h" /> <ClInclude Include="..\include\vcpkg_cmd_arguments.h" /> <ClInclude Include="..\include\vcpkg_Commands.h" /> diff --git a/toolsrc/vcpkg/vcpkg.vcxproj.filters b/toolsrc/vcpkg/vcpkg.vcxproj.filters index 568850787..cfbb17a22 100644 --- a/toolsrc/vcpkg/vcpkg.vcxproj.filters +++ b/toolsrc/vcpkg/vcpkg.vcxproj.filters @@ -110,5 +110,8 @@ <ClInclude Include="..\include\MachineType.h"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="..\include\filesystem_fs.h"> + <Filter>Header Files</Filter> + </ClInclude> </ItemGroup> </Project>
\ No newline at end of file |
