From b7d6160b80f417137bc480137b946c91f3272bf5 Mon Sep 17 00:00:00 2001 From: Curtis J Bezault Date: Wed, 12 Jun 2019 14:18:43 -0700 Subject: [icu] Enable parallel builds (#6695) * Add VCPKG_NUM_LOGICAL_CORES * break out logic that retries running a command several times into its own function * Parallelize icu --- toolsrc/include/vcpkg/base/system.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg/base/system.h b/toolsrc/include/vcpkg/base/system.h index 0245b684a..907a692a2 100644 --- a/toolsrc/include/vcpkg/base/system.h +++ b/toolsrc/include/vcpkg/base/system.h @@ -28,4 +28,6 @@ namespace vcpkg::System const Optional& get_program_files_32_bit(); const Optional& get_program_files_platform_bitness(); + + int get_num_logical_cores(); } -- cgit v1.2.3 From e5b92a39116791cfd4e1f4931221c9f69125bae3 Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Wed, 19 Jun 2019 11:49:57 -0700 Subject: [vcpkg] Improve vcpkg::Files::Filesystem error handling (#6919) * [vcpkg] Modify Filesystem::remove and Filesystem::rename to not throw. * [.gitignore] Ignore new VS2019 CMake integration default location * [.gitignore] Ignore CMakeSettings.json in toolsrc * [vcpkg] Time external processes called with System::cmd_execute * [vcpkg] Work around VS2019 CMake bug * [vcpkg] Fix several unused variable warnings. * [vcpkg] Improve error handling in vcpkg::Files::Filesystem Always require either std::error_code or LineInfo to print better errors. * [vcpkg] Fixup missing return value. Drive by fix: silence warnings in tests. * [vcpkg] Fix exiting in error_code overload Drive by fixes for /analyze with VS2019 --- toolsrc/include/tests.utils.h | 8 ++++---- toolsrc/include/vcpkg/base/files.h | 14 ++++++++------ toolsrc/include/vcpkg/base/graphs.h | 4 ++-- toolsrc/include/vcpkg/base/optional.h | 23 +++++++++++++++++++---- toolsrc/include/vcpkg/base/strings.h | 2 +- 5 files changed, 34 insertions(+), 17 deletions(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/tests.utils.h b/toolsrc/include/tests.utils.h index 7f7ec9e88..3e8514e67 100644 --- a/toolsrc/include/tests.utils.h +++ b/toolsrc/include/tests.utils.h @@ -13,7 +13,7 @@ namespace Microsoft::VisualStudio::CppUnitTestFramework { template<> - std::wstring ToString(const vcpkg::Dependencies::InstallPlanType& t) + inline std::wstring ToString(const vcpkg::Dependencies::InstallPlanType& t) { switch (t) { @@ -26,7 +26,7 @@ namespace Microsoft::VisualStudio::CppUnitTestFramework } template<> - std::wstring ToString(const vcpkg::Dependencies::RequestType& t) + inline std::wstring ToString(const vcpkg::Dependencies::RequestType& t) { switch (t) { @@ -38,13 +38,13 @@ namespace Microsoft::VisualStudio::CppUnitTestFramework } template<> - std::wstring ToString(const vcpkg::PackageSpecParseResult& t) + inline std::wstring ToString(const vcpkg::PackageSpecParseResult& t) { return ToString(static_cast(t)); } template<> - std::wstring ToString(const vcpkg::PackageSpec& t) + inline std::wstring ToString(const vcpkg::PackageSpec& t) { return ToString(t.to_string()); } diff --git a/toolsrc/include/vcpkg/base/files.h b/toolsrc/include/vcpkg/base/files.h index b07ff25b3..02e2b8db8 100644 --- a/toolsrc/include/vcpkg/base/files.h +++ b/toolsrc/include/vcpkg/base/files.h @@ -27,21 +27,25 @@ namespace vcpkg::Files { struct Filesystem { + std::string read_contents(const fs::path& file_path, LineInfo linfo) const; virtual Expected read_contents(const fs::path& file_path) const = 0; virtual Expected> read_lines(const fs::path& file_path) const = 0; virtual fs::path find_file_recursively_up(const fs::path& starting_dir, const std::string& filename) const = 0; virtual std::vector get_files_recursive(const fs::path& dir) const = 0; virtual std::vector get_files_non_recursive(const fs::path& dir) const = 0; - - virtual void write_lines(const fs::path& file_path, const std::vector& lines) = 0; + void write_lines(const fs::path& file_path, const std::vector& lines, LineInfo linfo); + virtual void write_lines(const fs::path& file_path, + const std::vector& lines, + std::error_code& ec) = 0; + void write_contents(const fs::path& path, const std::string& data, LineInfo linfo); virtual void write_contents(const fs::path& file_path, const std::string& data, std::error_code& ec) = 0; - virtual void rename(const fs::path& oldpath, const fs::path& newpath) = 0; + void rename(const fs::path& oldpath, const fs::path& newpath, LineInfo linfo); virtual void rename(const fs::path& oldpath, const fs::path& newpath, std::error_code& ec) = 0; virtual void rename_or_copy(const fs::path& oldpath, const fs::path& newpath, StringLiteral temp_suffix, std::error_code& ec) = 0; - virtual bool remove(const fs::path& path) = 0; + bool remove(const fs::path& path, LineInfo linfo); virtual bool remove(const fs::path& path, std::error_code& ec) = 0; virtual std::uintmax_t remove_all(const fs::path& path, std::error_code& ec) = 0; virtual bool exists(const fs::path& path) const = 0; @@ -60,8 +64,6 @@ namespace vcpkg::Files virtual fs::file_status symlink_status(const fs::path& path, std::error_code& ec) const = 0; virtual std::vector find_from_PATH(const std::string& name) const = 0; - - void write_contents(const fs::path& file_path, const std::string& data); }; Filesystem& get_real_filesystem(); diff --git a/toolsrc/include/vcpkg/base/graphs.h b/toolsrc/include/vcpkg/base/graphs.h index 46831a911..9901a49a0 100644 --- a/toolsrc/include/vcpkg/base/graphs.h +++ b/toolsrc/include/vcpkg/base/graphs.h @@ -44,9 +44,9 @@ namespace vcpkg::Graphs void shuffle(Container& c, Randomizer* r) { if (!r) return; - for (int i = static_cast(c.size()); i > 1; --i) + for (auto i = c.size(); i > 1; --i) { - auto j = r->random(i); + auto j = r->random(static_cast(i)); if (j != i - 1) { std::swap(c[i - 1], c[j]); diff --git a/toolsrc/include/vcpkg/base/optional.h b/toolsrc/include/vcpkg/base/optional.h index 4d386a961..2d8c126c6 100644 --- a/toolsrc/include/vcpkg/base/optional.h +++ b/toolsrc/include/vcpkg/base/optional.h @@ -19,6 +19,9 @@ namespace vcpkg template::value> struct OptionalStorage { +#if defined(_WIN32) +#pragma warning(suppress : 26495) +#endif constexpr OptionalStorage() noexcept : m_is_present(false), m_inactive() {} constexpr OptionalStorage(const T& t) : m_is_present(true), m_t(t) {} constexpr OptionalStorage(T&& t) : m_is_present(true), m_t(std::move(t)) {} @@ -28,12 +31,18 @@ namespace vcpkg if (m_is_present) m_t.~T(); } +#if defined(_WIN32) +#pragma warning(suppress : 26495) +#endif OptionalStorage(const OptionalStorage& o) : m_is_present(o.m_is_present), m_inactive() { if (m_is_present) new (&m_t) T(o.m_t); } - OptionalStorage(OptionalStorage&& o) : m_is_present(o.m_is_present), m_inactive() +#if defined(_WIN32) +#pragma warning(suppress : 26495) +#endif + OptionalStorage(OptionalStorage&& o) noexcept : m_is_present(o.m_is_present), m_inactive() { if (m_is_present) { @@ -59,7 +68,7 @@ namespace vcpkg return *this; } - OptionalStorage& operator=(OptionalStorage&& o) + OptionalStorage& operator=(OptionalStorage&& o) noexcept { if (m_is_present && o.m_is_present) { @@ -100,6 +109,9 @@ namespace vcpkg template struct OptionalStorage { +#if defined(_WIN32) +#pragma warning(suppress : 26495) +#endif constexpr OptionalStorage() noexcept : m_is_present(false), m_inactive() {} constexpr OptionalStorage(T&& t) : m_is_present(true), m_t(std::move(t)) {} @@ -108,7 +120,10 @@ namespace vcpkg if (m_is_present) m_t.~T(); } - OptionalStorage(OptionalStorage&& o) : m_is_present(o.m_is_present), m_inactive() +#if defined(_WIN32) +#pragma warning(suppress : 26495) +#endif + OptionalStorage(OptionalStorage&& o) noexcept : m_is_present(o.m_is_present), m_inactive() { if (m_is_present) { @@ -116,7 +131,7 @@ namespace vcpkg } } - OptionalStorage& operator=(OptionalStorage&& o) + OptionalStorage& operator=(OptionalStorage&& o) noexcept { if (m_is_present && o.m_is_present) { diff --git a/toolsrc/include/vcpkg/base/strings.h b/toolsrc/include/vcpkg/base/strings.h index 3a9de97df..d553d1d41 100644 --- a/toolsrc/include/vcpkg/base/strings.h +++ b/toolsrc/include/vcpkg/base/strings.h @@ -163,7 +163,7 @@ namespace vcpkg::Strings std::vector split(const std::string& s, const std::string& delimiter); - std::vector split(const std::string& s, const std::string& delimiter, int max_count); + std::vector split(const std::string& s, const std::string& delimiter, size_t max_count); std::vector find_all_enclosed(StringView input, StringView left_delim, StringView right_delim); -- cgit v1.2.3 From f0902b35370fbebcf257de88e43ee47379185a10 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Thu, 20 Jun 2019 11:46:55 -0700 Subject: VS 2019 16.3 deprecates . (#6968) VS 2019 16.3 will contain a couple of source-breaking changes: * will be deprecated via an impossible-to-miss preprocessor "#error The header providing std::experimental::filesystem is deprecated by Microsoft and will be REMOVED. It is superseded by the C++17 header providing std::filesystem. You can define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING to acknowledge that you have received this warning." * will no longer include . In the long term, I believe that vcpkg should detect when it's being built with VS 2017 15.7 or newer, compile in C++17 mode, include , and use std::filesystem. (Activating this for VS 2019 16.0 or newer would also be reasonable.) Similarly for other toolsets supporting std::filesystem. In the short term, this commit makes vcpkg compatible with the upcoming deprecation. First, we need to define the silencing macro before including the appropriate header. I've chosen to define it unconditionally (without checking for platform or version), since it has no effect for other platforms or versions. Second, we need to deal with no longer including . I verified that VS 2015 Update 3 contained (back then, it simply included the header, where the experimental implementation was defined; this was later reorganized). Therefore, all of vcpkg's supported MSVC toolsets have , so we can simply always include it. I've verified that this builds with both VS 2015 Update 3 and VS 2019 16.1.3 (the current production version). --- toolsrc/include/pch.h | 5 +---- toolsrc/include/vcpkg/base/files.h | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/pch.h b/toolsrc/include/pch.h index fa2c2bb72..15ec25e76 100644 --- a/toolsrc/include/pch.h +++ b/toolsrc/include/pch.h @@ -37,11 +37,8 @@ #include #include #include -#if defined(_WIN32) -#include -#else +#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING #include -#endif #include #include #include diff --git a/toolsrc/include/vcpkg/base/files.h b/toolsrc/include/vcpkg/base/files.h index 02e2b8db8..3ea0d6036 100644 --- a/toolsrc/include/vcpkg/base/files.h +++ b/toolsrc/include/vcpkg/base/files.h @@ -2,11 +2,8 @@ #include -#if defined(_WIN32) -#include -#else +#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING #include -#endif namespace fs { -- cgit v1.2.3 From f3db66b403840b24ea2612d09cca30a5285f5ea3 Mon Sep 17 00:00:00 2001 From: Victor Romero Date: Fri, 21 Jun 2019 23:50:05 -0700 Subject: Ports Overlay partial implementation (#6981) * Ports Overlay feature spec * Ports Overlay implementation * [--overlay-ports] Refactor handling of additional paths * Code cleanup * [--overlay-ports] Add help * [depend-info] Support --overlay-ports * Add method to load all ports using PathsPortFileProvider * Make PortFileProvider::load_all_control_files() const * Remove unused code * [vcpkg] Avoid double-load of source control file between Build::perform_and_exit and Build::perform_and_exit_ex * [vcpkg] Clang format * [vcpkg] Fixup build failure introduced in b069ceb2f231 * Report errors from Paragraphs::try_load_port() --- toolsrc/include/vcpkg/build.h | 2 +- toolsrc/include/vcpkg/dependencies.h | 27 ++++++++++++++++----------- toolsrc/include/vcpkg/postbuildlint.h | 3 ++- toolsrc/include/vcpkg/sourceparagraph.h | 9 +++++++++ toolsrc/include/vcpkg/vcpkgcmdarguments.h | 16 +++++++++++++++- toolsrc/include/vcpkg/vcpkgpaths.h | 2 -- 6 files changed, 43 insertions(+), 16 deletions(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg/build.h b/toolsrc/include/vcpkg/build.h index 9044cb556..04cd7cf87 100644 --- a/toolsrc/include/vcpkg/build.h +++ b/toolsrc/include/vcpkg/build.h @@ -20,7 +20,7 @@ namespace vcpkg::Build namespace Command { void perform_and_exit_ex(const FullPackageSpec& full_spec, - const fs::path& port_dir, + const SourceControlFileLocation& scfl, const ParsedArguments& options, const VcpkgPaths& paths); diff --git a/toolsrc/include/vcpkg/dependencies.h b/toolsrc/include/vcpkg/dependencies.h index 16fdb3f73..8c2050b3d 100644 --- a/toolsrc/include/vcpkg/dependencies.h +++ b/toolsrc/include/vcpkg/dependencies.h @@ -48,7 +48,7 @@ namespace vcpkg::Dependencies const RequestType& request_type); InstallPlanAction(const PackageSpec& spec, - const SourceControlFile& scf, + const SourceControlFileLocation& scfl, const std::set& features, const RequestType& request_type, std::vector&& dependencies); @@ -57,7 +57,7 @@ namespace vcpkg::Dependencies PackageSpec spec; - Optional source_control_file; + Optional source_control_file_location; Optional installed_package; InstallPlanType plan_type; @@ -129,26 +129,31 @@ namespace vcpkg::Dependencies struct PortFileProvider { - virtual Optional get_control_file(const std::string& src_name) const = 0; + virtual Optional get_control_file(const std::string& src_name) const = 0; + virtual std::vector load_all_control_files() const = 0; }; struct MapPortFileProvider : Util::ResourceBase, PortFileProvider { - explicit MapPortFileProvider(const std::unordered_map& map); - Optional get_control_file(const std::string& src_name) const override; + explicit MapPortFileProvider(const std::unordered_map& map); + Optional get_control_file(const std::string& src_name) const override; + std::vector load_all_control_files() const override; private: - const std::unordered_map& ports; + const std::unordered_map& ports; }; struct PathsPortFileProvider : Util::ResourceBase, PortFileProvider { - explicit PathsPortFileProvider(const VcpkgPaths& paths); - Optional get_control_file(const std::string& src_name) const override; + explicit PathsPortFileProvider(const vcpkg::VcpkgPaths& paths, + const std::vector* ports_dirs_paths); + Optional get_control_file(const std::string& src_name) const override; + std::vector load_all_control_files() const override; private: - const VcpkgPaths& ports; - mutable std::unordered_map cache; + Files::Filesystem& filesystem; + std::vector ports_dirs; + mutable std::unordered_map cache; }; struct ClusterGraph; @@ -181,7 +186,7 @@ namespace vcpkg::Dependencies std::vector create_export_plan(const std::vector& specs, const StatusParagraphs& status_db); - std::vector create_feature_install_plan(const std::unordered_map& map, + std::vector create_feature_install_plan(const std::unordered_map& map, const std::vector& specs, const StatusParagraphs& status_db); diff --git a/toolsrc/include/vcpkg/postbuildlint.h b/toolsrc/include/vcpkg/postbuildlint.h index 5dcfeb8df..027619eb8 100644 --- a/toolsrc/include/vcpkg/postbuildlint.h +++ b/toolsrc/include/vcpkg/postbuildlint.h @@ -9,5 +9,6 @@ namespace vcpkg::PostBuildLint size_t perform_all_checks(const PackageSpec& spec, const VcpkgPaths& paths, const Build::PreBuildInfo& pre_build_info, - const Build::BuildInfo& build_info); + const Build::BuildInfo& build_info, + const fs::path& port_dir); } diff --git a/toolsrc/include/vcpkg/sourceparagraph.h b/toolsrc/include/vcpkg/sourceparagraph.h index d70fd4337..6232a3fd2 100644 --- a/toolsrc/include/vcpkg/sourceparagraph.h +++ b/toolsrc/include/vcpkg/sourceparagraph.h @@ -68,6 +68,15 @@ namespace vcpkg Optional find_feature(const std::string& featurename) const; }; + /// + /// Full metadata of a package: core and other features. As well as the location the SourceControlFile was loaded from. + /// + struct SourceControlFileLocation + { + std::unique_ptr source_control_file; + fs::path source_location; + }; + void print_error_message(Span> error_info_list); inline void print_error_message(const std::unique_ptr& error_info_list) { diff --git a/toolsrc/include/vcpkg/vcpkgcmdarguments.h b/toolsrc/include/vcpkg/vcpkgcmdarguments.h index de65eec28..cad013eb8 100644 --- a/toolsrc/include/vcpkg/vcpkgcmdarguments.h +++ b/toolsrc/include/vcpkg/vcpkgcmdarguments.h @@ -15,6 +15,7 @@ namespace vcpkg { std::unordered_set switches; std::unordered_map settings; + std::unordered_map> multisettings; }; struct VcpkgPaths; @@ -41,10 +42,22 @@ namespace vcpkg StringLiteral short_help_text; }; + struct CommandMultiSetting + { + constexpr CommandMultiSetting(const StringLiteral& name, const StringLiteral& short_help_text) + : name(name), short_help_text(short_help_text) + { + } + + StringLiteral name; + StringLiteral short_help_text; + }; + struct CommandOptionsStructure { Span switches; Span settings; + Span multisettings; }; struct CommandStructure @@ -74,6 +87,7 @@ namespace vcpkg std::unique_ptr vcpkg_root_dir; std::unique_ptr triplet; + std::unique_ptr> overlay_ports; Optional debug = nullopt; Optional sendmetrics = nullopt; Optional printmetrics = nullopt; @@ -88,6 +102,6 @@ namespace vcpkg ParsedArguments parse_arguments(const CommandStructure& command_structure) const; private: - std::unordered_map> optional_command_arguments; + std::unordered_map>> optional_command_arguments; }; } diff --git a/toolsrc/include/vcpkg/vcpkgpaths.h b/toolsrc/include/vcpkg/vcpkgpaths.h index 42de40d9c..b09169b02 100644 --- a/toolsrc/include/vcpkg/vcpkgpaths.h +++ b/toolsrc/include/vcpkg/vcpkgpaths.h @@ -50,8 +50,6 @@ namespace vcpkg static Expected create(const fs::path& vcpkg_root_dir, const std::string& default_vs_path); fs::path package_dir(const PackageSpec& spec) const; - fs::path port_dir(const PackageSpec& spec) const; - fs::path port_dir(const std::string& name) const; fs::path build_info_file_path(const PackageSpec& spec) const; fs::path listfile_path(const BinaryParagraph& pgh) const; -- cgit v1.2.3 From 9e565e986789cf273de12fe1b07ce31800d10417 Mon Sep 17 00:00:00 2001 From: Victor Romero Date: Mon, 24 Jun 2019 12:09:48 -0700 Subject: [--overlay-ports] Show location of overriden ports during install plan (#7002) * [--overlay-ports] Show source location of overlayed ports during install plan * Code cleanup * Code cleanup --- toolsrc/include/vcpkg/dependencies.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg/dependencies.h b/toolsrc/include/vcpkg/dependencies.h index 8c2050b3d..964158026 100644 --- a/toolsrc/include/vcpkg/dependencies.h +++ b/toolsrc/include/vcpkg/dependencies.h @@ -199,5 +199,7 @@ namespace vcpkg::Dependencies const StatusParagraphs& status_db, const CreateInstallPlanOptions& options = {}); - void print_plan(const std::vector& action_plan, const bool is_recursive = true); + void print_plan(const std::vector& action_plan, + const bool is_recursive = true, + const fs::path& default_ports_dir = ""); } -- cgit v1.2.3 From 35e985d3ccf60235bc4881df4d934610cd507090 Mon Sep 17 00:00:00 2001 From: Victor Romero Date: Thu, 27 Jun 2019 12:20:12 -0700 Subject: Triplets Overlay Implementation (#7053) * Triplets Overlay Implementation * Use cache for get_triplet_file_path() * Code cleanup --- toolsrc/include/vcpkg/vcpkgcmdarguments.h | 1 + toolsrc/include/vcpkg/vcpkgpaths.h | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'toolsrc/include') diff --git a/toolsrc/include/vcpkg/vcpkgcmdarguments.h b/toolsrc/include/vcpkg/vcpkgcmdarguments.h index cad013eb8..ff13ae6bf 100644 --- a/toolsrc/include/vcpkg/vcpkgcmdarguments.h +++ b/toolsrc/include/vcpkg/vcpkgcmdarguments.h @@ -88,6 +88,7 @@ namespace vcpkg std::unique_ptr vcpkg_root_dir; std::unique_ptr triplet; std::unique_ptr> overlay_ports; + std::unique_ptr> overlay_triplets; Optional debug = nullopt; Optional sendmetrics = nullopt; Optional printmetrics = nullopt; diff --git a/toolsrc/include/vcpkg/vcpkgpaths.h b/toolsrc/include/vcpkg/vcpkgpaths.h index b09169b02..a30e0c653 100644 --- a/toolsrc/include/vcpkg/vcpkgpaths.h +++ b/toolsrc/include/vcpkg/vcpkgpaths.h @@ -47,14 +47,17 @@ namespace vcpkg struct VcpkgPaths { - static Expected create(const fs::path& vcpkg_root_dir, const std::string& default_vs_path); + static Expected create(const fs::path& vcpkg_root_dir, + const std::string& default_vs_path, + const std::vector* triplets_dirs); fs::path package_dir(const PackageSpec& spec) const; fs::path build_info_file_path(const PackageSpec& spec) const; fs::path listfile_path(const BinaryParagraph& pgh) const; - - const std::vector& get_available_triplets() const; + bool is_valid_triplet(const Triplet& t) const; + const std::vector& get_available_triplets() const; + const fs::path get_triplet_file_path(const Triplet& triplet) const; fs::path root; fs::path packages; @@ -93,7 +96,9 @@ namespace vcpkg Lazy> toolsets_vs2013; fs::path default_vs_path; + std::vector triplets_dirs; mutable std::unique_ptr m_tool_cache; + mutable vcpkg::Cache m_triplets_cache; }; } -- cgit v1.2.3