diff options
| author | Patrick Bader <mail@patrickbader.eu> | 2017-01-06 19:09:17 +0100 |
|---|---|---|
| committer | Patrick Bader <mail@patrickbader.eu> | 2017-01-06 19:09:17 +0100 |
| commit | 04f8da985c9acdd090055ad06bcf75eb20af1987 (patch) | |
| tree | 76ae8c42d498f0c2d607c891eac50f41f06d1269 /toolsrc/src | |
| parent | 44c86f56db351da15e5a2b2fcca62656ab8cccbf (diff) | |
| parent | ff10939203b7694f21d8e8e0464f092dff1b4eb0 (diff) | |
| download | vcpkg-04f8da985c9acdd090055ad06bcf75eb20af1987.tar.gz vcpkg-04f8da985c9acdd090055ad06bcf75eb20af1987.zip | |
Merge branch 'master' of https://github.com/Microsoft/vcpkg
Diffstat (limited to 'toolsrc/src')
| -rw-r--r-- | toolsrc/src/BuildInfo.cpp | 4 | ||||
| -rw-r--r-- | toolsrc/src/Paragraphs.cpp | 4 | ||||
| -rw-r--r-- | toolsrc/src/coff_file_reader.cpp | 4 | ||||
| -rw-r--r-- | toolsrc/src/commands_installation.cpp | 24 | ||||
| -rw-r--r-- | toolsrc/src/metrics.cpp | 8 | ||||
| -rw-r--r-- | toolsrc/src/post_build_lint.cpp | 4 | ||||
| -rw-r--r-- | toolsrc/src/tests_paragraph.cpp | 4 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg.cpp | 2 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_Checks.cpp | 4 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_Dependencies.cpp | 4 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_Environment.cpp | 4 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_Files.cpp | 4 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_Input.cpp | 6 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_Strings.cpp | 8 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_System.cpp | 6 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_info.cpp | 4 | ||||
| -rw-r--r-- | toolsrc/src/vcpkglib_helpers.cpp | 4 |
17 files changed, 55 insertions, 43 deletions
diff --git a/toolsrc/src/BuildInfo.cpp b/toolsrc/src/BuildInfo.cpp index f151a3ea5..a45dc4b72 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 PostBuildLint +namespace vcpkg::PostBuildLint { const ConfigurationType& BuildType::config() const { @@ -161,4 +161,4 @@ namespace vcpkg { namespace PostBuildLint { return this->m_dll_name; } -}} +} diff --git a/toolsrc/src/Paragraphs.cpp b/toolsrc/src/Paragraphs.cpp index 823b4a85e..d99ad45cf 100644 --- a/toolsrc/src/Paragraphs.cpp +++ b/toolsrc/src/Paragraphs.cpp @@ -1,7 +1,7 @@ #include "Paragraphs.h" #include "vcpkg_Files.h" -namespace vcpkg { namespace Paragraphs +namespace vcpkg::Paragraphs { struct Parser { @@ -160,4 +160,4 @@ namespace vcpkg { namespace Paragraphs { return Parser(str.c_str(), str.c_str() + str.size()).get_paragraphs(); } -}} +} diff --git a/toolsrc/src/coff_file_reader.cpp b/toolsrc/src/coff_file_reader.cpp index 1f30ea70b..8ce714bbe 100644 --- a/toolsrc/src/coff_file_reader.cpp +++ b/toolsrc/src/coff_file_reader.cpp @@ -6,7 +6,7 @@ using namespace std; -namespace vcpkg { namespace COFFFileReader +namespace vcpkg::COFFFileReader { template <class T> static T reinterpret_bytes(const char* data) @@ -306,4 +306,4 @@ namespace vcpkg { namespace COFFFileReader return {std::vector<MachineType>(machine_types.cbegin(), machine_types.cend())}; } -}} +} diff --git a/toolsrc/src/commands_installation.cpp b/toolsrc/src/commands_installation.cpp index 8d940bc9d..c239bf06c 100644 --- a/toolsrc/src/commands_installation.cpp +++ b/toolsrc/src/commands_installation.cpp @@ -164,9 +164,8 @@ namespace vcpkg return output; } - void install_package(const vcpkg_paths& paths, const BinaryParagraph& binary_paragraph, StatusParagraphs& status_db) + static ImmutableSortedVector<std::string> build_list_of_package_files(const fs::path& package_dir) { - const fs::path package_dir = paths.package_dir(binary_paragraph.spec); const std::vector<fs::path> package_file_paths = Files::recursive_find_all_files_in_dir(package_dir); std::vector<std::string> package_files; const size_t package_remove_char_count = package_dir.generic_string().size() + 1; // +1 for the slash @@ -176,14 +175,27 @@ namespace vcpkg as_string.erase(0, package_remove_char_count); return std::move(as_string); }); - std::sort(package_files.begin(), package_files.end()); - const std::vector<StatusParagraph_and_associated_files>& pgh_and_files = get_installed_files(paths, status_db); - const triplet& triplet = binary_paragraph.spec.target_triplet(); + return ImmutableSortedVector<std::string>::create(std::move(package_files)); + } + + static ImmutableSortedVector<std::string> build_list_of_installed_files(const std::vector<StatusParagraph_and_associated_files>& pgh_and_files, const triplet& triplet) + { std::vector<std::string> installed_files = extract_files_in_triplet(pgh_and_files, triplet); const size_t installed_remove_char_count = triplet.canonical_name().size() + 1; // +1 for the slash remove_first_n_chars(&installed_files, installed_remove_char_count); - std::sort(installed_files.begin(), installed_files.end()); // Should already be sorted + + return ImmutableSortedVector<std::string>::create(std::move(installed_files)); + } + + void install_package(const vcpkg_paths& paths, const BinaryParagraph& binary_paragraph, StatusParagraphs& status_db) + { + const fs::path package_dir = paths.package_dir(binary_paragraph.spec); + const triplet& triplet = binary_paragraph.spec.target_triplet(); + const std::vector<StatusParagraph_and_associated_files> pgh_and_files = get_installed_files(paths, status_db); + + const ImmutableSortedVector<std::string> package_files = build_list_of_package_files(package_dir); + const ImmutableSortedVector<std::string> installed_files = build_list_of_installed_files(pgh_and_files, triplet); std::vector<std::string> intersection; std::set_intersection(package_files.cbegin(), package_files.cend(), diff --git a/toolsrc/src/metrics.cpp b/toolsrc/src/metrics.cpp index 51c7179c8..1806dad87 100644 --- a/toolsrc/src/metrics.cpp +++ b/toolsrc/src/metrics.cpp @@ -237,13 +237,13 @@ true std::wstring GetSQMUser() { - LONG err = NULL; + LONG err; struct RAII_HKEY { - HKEY hkey = NULL; + HKEY hkey = nullptr; ~RAII_HKEY() { - if (hkey != NULL) + if (hkey != nullptr) RegCloseKey(hkey); } } HKCU_SQMClient; @@ -257,7 +257,7 @@ true std::array<wchar_t,128> buffer; DWORD lType = 0; DWORD dwBufferSize = static_cast<DWORD>(buffer.size() * sizeof(wchar_t)); - err = RegQueryValueExW(HKCU_SQMClient.hkey, L"UserId", NULL, &lType, reinterpret_cast<LPBYTE>(buffer.data()), &dwBufferSize); + err = RegQueryValueExW(HKCU_SQMClient.hkey, L"UserId", nullptr, &lType, reinterpret_cast<LPBYTE>(buffer.data()), &dwBufferSize); if (err == ERROR_SUCCESS && lType == REG_SZ && dwBufferSize >= sizeof(wchar_t)) { size_t sz = dwBufferSize / sizeof(wchar_t); diff --git a/toolsrc/src/post_build_lint.cpp b/toolsrc/src/post_build_lint.cpp index 4f0adf677..1fca3a2f6 100644 --- a/toolsrc/src/post_build_lint.cpp +++ b/toolsrc/src/post_build_lint.cpp @@ -7,7 +7,7 @@ #include "BuildInfo.h" #include <regex> -namespace vcpkg { namespace PostBuildLint +namespace vcpkg::PostBuildLint { enum class lint_status { @@ -668,4 +668,4 @@ namespace vcpkg { namespace PostBuildLint System::println("-- Performing post-build validation done"); } -}} +} diff --git a/toolsrc/src/tests_paragraph.cpp b/toolsrc/src/tests_paragraph.cpp index 6d9e46fcf..fb20eee82 100644 --- a/toolsrc/src/tests_paragraph.cpp +++ b/toolsrc/src/tests_paragraph.cpp @@ -7,14 +7,14 @@ using namespace Microsoft::VisualStudio::CppUnitTestFramework; -namespace Microsoft { namespace VisualStudio { namespace CppUnitTestFramework +namespace Microsoft::VisualStudio::CppUnitTestFramework { template <> inline std::wstring ToString<vcpkg::package_spec_parse_result>(const vcpkg::package_spec_parse_result& t) { return ToString(static_cast<uint32_t>(t)); } -}}} +} namespace UnitTest1 { diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp index 4748aeb54..eb2184ccb 100644 --- a/toolsrc/src/vcpkg.cpp +++ b/toolsrc/src/vcpkg.cpp @@ -204,7 +204,7 @@ std::vector<StatusParagraph_and_associated_files> vcpkg::get_installed_files(con } ), installed_files_of_current_pgh.end()); - StatusParagraph_and_associated_files pgh_and_files = {*pgh, std::move(installed_files_of_current_pgh)}; + StatusParagraph_and_associated_files pgh_and_files = {*pgh, ImmutableSortedVector<std::string>::create(std::move(installed_files_of_current_pgh))}; installed_files.push_back(std::move(pgh_and_files)); } diff --git a/toolsrc/src/vcpkg_Checks.cpp b/toolsrc/src/vcpkg_Checks.cpp index 817ac9e96..46b28e55c 100644 --- a/toolsrc/src/vcpkg_Checks.cpp +++ b/toolsrc/src/vcpkg_Checks.cpp @@ -3,7 +3,7 @@ #include <stdexcept> #include "vcpkg_System.h" -namespace vcpkg {namespace Checks +namespace vcpkg::Checks { void unreachable() { @@ -41,4 +41,4 @@ namespace vcpkg {namespace Checks exit_with_message(errorMessage); } } -}} +} diff --git a/toolsrc/src/vcpkg_Dependencies.cpp b/toolsrc/src/vcpkg_Dependencies.cpp index ae7f697fa..f1464a605 100644 --- a/toolsrc/src/vcpkg_Dependencies.cpp +++ b/toolsrc/src/vcpkg_Dependencies.cpp @@ -9,7 +9,7 @@ #include "vcpkg_Files.h" #include "vcpkg.h" -namespace vcpkg { namespace Dependencies +namespace vcpkg::Dependencies { std::vector<package_spec_with_install_plan> create_install_plan(const vcpkg_paths& paths, const std::vector<package_spec>& specs, const StatusParagraphs& status_db) { @@ -72,4 +72,4 @@ namespace vcpkg { namespace Dependencies } return ret; } -}} +} diff --git a/toolsrc/src/vcpkg_Environment.cpp b/toolsrc/src/vcpkg_Environment.cpp index ed70e6881..c7eec3bd0 100644 --- a/toolsrc/src/vcpkg_Environment.cpp +++ b/toolsrc/src/vcpkg_Environment.cpp @@ -5,7 +5,7 @@ #include "metrics.h" #include "vcpkg_System.h" -namespace vcpkg {namespace Environment +namespace vcpkg::Environment { static const fs::path default_cmake_installation_dir = "C:/Program Files/CMake/bin"; static const fs::path default_cmake_installation_dir_x86 = "C:/Program Files (x86)/CMake/bin"; @@ -83,4 +83,4 @@ namespace vcpkg {namespace Environment // TODO: switch out ExecutionPolicy Bypass with "Remove Mark Of The Web" code and restore RemoteSigned ensure_on_path(nuget_version, L"nuget 2>&1", L"powershell -ExecutionPolicy Bypass scripts\\fetchDependency.ps1 -Dependency nuget"); } -}} +} diff --git a/toolsrc/src/vcpkg_Files.cpp b/toolsrc/src/vcpkg_Files.cpp index 48283e43f..1d4faa773 100644 --- a/toolsrc/src/vcpkg_Files.cpp +++ b/toolsrc/src/vcpkg_Files.cpp @@ -3,7 +3,7 @@ #include <regex> #include "vcpkg_System.h" -namespace vcpkg {namespace Files +namespace vcpkg::Files { static const std::regex FILESYSTEM_INVALID_CHARACTERS_REGEX = std::regex(R"([\/:*?"<>|])"); @@ -140,4 +140,4 @@ namespace vcpkg {namespace Files } System::println(""); } -}} +} diff --git a/toolsrc/src/vcpkg_Input.cpp b/toolsrc/src/vcpkg_Input.cpp index 29d487fdb..365f28cdb 100644 --- a/toolsrc/src/vcpkg_Input.cpp +++ b/toolsrc/src/vcpkg_Input.cpp @@ -3,7 +3,7 @@ #include "metrics.h" #include "vcpkg_Commands.h" -namespace vcpkg {namespace Input +namespace vcpkg::Input { package_spec check_and_get_package_spec(const std::string& package_spec_as_string, const triplet& default_target_triplet, const std::string& example_text) { @@ -42,11 +42,11 @@ namespace vcpkg {namespace Input } } - void check_triplets(std::vector<package_spec> triplets, const vcpkg_paths& paths) + void check_triplets(const std::vector<package_spec>& triplets, const vcpkg_paths& paths) { for (const package_spec& spec : triplets) { check_triplet(spec.target_triplet(), paths); } } -}} +} diff --git a/toolsrc/src/vcpkg_Strings.cpp b/toolsrc/src/vcpkg_Strings.cpp index 46a4b1855..cf7d3b0ee 100644 --- a/toolsrc/src/vcpkg_Strings.cpp +++ b/toolsrc/src/vcpkg_Strings.cpp @@ -7,7 +7,7 @@ #include <functional> #include <cctype> -namespace vcpkg {namespace Strings {namespace details +namespace vcpkg::Strings::details { // To disambiguate between two overloads static const auto isspace = [](const char c) @@ -40,9 +40,9 @@ namespace vcpkg {namespace Strings {namespace details return output; } -}}} +} -namespace vcpkg {namespace Strings +namespace vcpkg::Strings { std::wstring utf8_to_utf16(const std::string& s) { @@ -119,4 +119,4 @@ namespace vcpkg {namespace Strings return s == ""; }), strings->end()); } -}} +} diff --git a/toolsrc/src/vcpkg_System.cpp b/toolsrc/src/vcpkg_System.cpp index 43eae3412..405dfd1b8 100644 --- a/toolsrc/src/vcpkg_System.cpp +++ b/toolsrc/src/vcpkg_System.cpp @@ -3,7 +3,7 @@ #include <Windows.h> #include <regex> -namespace vcpkg {namespace System +namespace vcpkg::System { fs::path get_exe_path_of_current_process() { @@ -104,6 +104,6 @@ namespace vcpkg {namespace System double Stopwatch2::microseconds() const { return (reinterpret_cast<const LARGE_INTEGER*>(&end_time)->QuadPart - - reinterpret_cast<const LARGE_INTEGER*>(&start_time)->QuadPart) * 1000000.0 / reinterpret_cast<const LARGE_INTEGER*>(&freq)->QuadPart; + reinterpret_cast<const LARGE_INTEGER*>(&start_time)->QuadPart) * 1000000.0 / reinterpret_cast<const LARGE_INTEGER*>(&freq)->QuadPart; } -}} +} diff --git a/toolsrc/src/vcpkg_info.cpp b/toolsrc/src/vcpkg_info.cpp index 25c09d6da..69bc6a355 100644 --- a/toolsrc/src/vcpkg_info.cpp +++ b/toolsrc/src/vcpkg_info.cpp @@ -6,7 +6,7 @@ #define VCPKG_VERSION_AS_STRING MACRO_TO_STRING(VCPKG_VERSION)"" // Double quotes needed at the end to prevent blank token -namespace vcpkg { namespace Info +namespace vcpkg::Info { const std::string& version() { @@ -31,4 +31,4 @@ namespace vcpkg { namespace Info static const std::string s_email = R"(vcpkg@microsoft.com)"; return s_email; } -}} +} diff --git a/toolsrc/src/vcpkglib_helpers.cpp b/toolsrc/src/vcpkglib_helpers.cpp index d104bb19d..fdc287507 100644 --- a/toolsrc/src/vcpkglib_helpers.cpp +++ b/toolsrc/src/vcpkglib_helpers.cpp @@ -3,7 +3,7 @@ #include <unordered_map> #include <regex> -namespace vcpkg {namespace details +namespace vcpkg::details { std::string optional_field(const std::unordered_map<std::string, std::string>& fields, const std::string& fieldname) { @@ -53,4 +53,4 @@ namespace vcpkg {namespace details simple_desc.append("..."); return simple_desc; } -}} +} |
