diff options
Diffstat (limited to 'toolsrc/include')
| -rw-r--r-- | toolsrc/include/pch.h | 5 | ||||
| -rw-r--r-- | toolsrc/include/tests.utils.h | 8 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/files.h | 19 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/graphs.h | 4 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/optional.h | 23 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/strings.h | 2 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/system.h | 2 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/build.h | 2 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/dependencies.h | 31 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/postbuildlint.h | 3 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/sourceparagraph.h | 9 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/vcpkgcmdarguments.h | 17 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/vcpkgpaths.h | 13 |
13 files changed, 93 insertions, 45 deletions
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 <cstdarg> #include <cstddef> #include <cstdint> -#if defined(_WIN32) -#include <filesystem> -#else +#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING #include <experimental/filesystem> -#endif #include <cstring> #include <fstream> #include <functional> 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<vcpkg::Dependencies::InstallPlanType>(const vcpkg::Dependencies::InstallPlanType& t) + inline std::wstring ToString<vcpkg::Dependencies::InstallPlanType>(const vcpkg::Dependencies::InstallPlanType& t) { switch (t) { @@ -26,7 +26,7 @@ namespace Microsoft::VisualStudio::CppUnitTestFramework } template<> - std::wstring ToString<vcpkg::Dependencies::RequestType>(const vcpkg::Dependencies::RequestType& t) + inline std::wstring ToString<vcpkg::Dependencies::RequestType>(const vcpkg::Dependencies::RequestType& t) { switch (t) { @@ -38,13 +38,13 @@ namespace Microsoft::VisualStudio::CppUnitTestFramework } template<> - std::wstring ToString<vcpkg::PackageSpecParseResult>(const vcpkg::PackageSpecParseResult& t) + inline std::wstring ToString<vcpkg::PackageSpecParseResult>(const vcpkg::PackageSpecParseResult& t) { return ToString(static_cast<uint32_t>(t)); } template<> - std::wstring ToString<vcpkg::PackageSpec>(const vcpkg::PackageSpec& t) + inline std::wstring ToString<vcpkg::PackageSpec>(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..3ea0d6036 100644 --- a/toolsrc/include/vcpkg/base/files.h +++ b/toolsrc/include/vcpkg/base/files.h @@ -2,11 +2,8 @@ #include <vcpkg/base/expected.h> -#if defined(_WIN32) -#include <filesystem> -#else +#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING #include <experimental/filesystem> -#endif namespace fs { @@ -27,21 +24,25 @@ namespace vcpkg::Files { struct Filesystem { + std::string read_contents(const fs::path& file_path, LineInfo linfo) const; virtual Expected<std::string> read_contents(const fs::path& file_path) const = 0; virtual Expected<std::vector<std::string>> 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<fs::path> get_files_recursive(const fs::path& dir) const = 0; virtual std::vector<fs::path> get_files_non_recursive(const fs::path& dir) const = 0; - - virtual void write_lines(const fs::path& file_path, const std::vector<std::string>& lines) = 0; + void write_lines(const fs::path& file_path, const std::vector<std::string>& lines, LineInfo linfo); + virtual void write_lines(const fs::path& file_path, + const std::vector<std::string>& 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 +61,6 @@ namespace vcpkg::Files virtual fs::file_status symlink_status(const fs::path& path, std::error_code& ec) const = 0; virtual std::vector<fs::path> 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<int>(c.size()); i > 1; --i) + for (auto i = c.size(); i > 1; --i) { - auto j = r->random(i); + auto j = r->random(static_cast<int>(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<class T, bool B = std::is_copy_constructible<T>::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<class T> struct OptionalStorage<T, false> { +#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<std::string> split(const std::string& s, const std::string& delimiter); - std::vector<std::string> split(const std::string& s, const std::string& delimiter, int max_count); + std::vector<std::string> split(const std::string& s, const std::string& delimiter, size_t max_count); std::vector<StringView> find_all_enclosed(StringView input, StringView left_delim, StringView right_delim); 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<fs::path>& get_program_files_32_bit(); const Optional<fs::path>& get_program_files_platform_bitness(); + + int get_num_logical_cores(); } 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..964158026 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<std::string>& features, const RequestType& request_type, std::vector<PackageSpec>&& dependencies); @@ -57,7 +57,7 @@ namespace vcpkg::Dependencies PackageSpec spec; - Optional<const SourceControlFile&> source_control_file; + Optional<const SourceControlFileLocation&> source_control_file_location; Optional<InstalledPackageView> installed_package; InstallPlanType plan_type; @@ -129,26 +129,31 @@ namespace vcpkg::Dependencies struct PortFileProvider { - virtual Optional<const SourceControlFile&> get_control_file(const std::string& src_name) const = 0; + virtual Optional<const SourceControlFileLocation&> get_control_file(const std::string& src_name) const = 0; + virtual std::vector<const SourceControlFileLocation*> load_all_control_files() const = 0; }; struct MapPortFileProvider : Util::ResourceBase, PortFileProvider { - explicit MapPortFileProvider(const std::unordered_map<std::string, SourceControlFile>& map); - Optional<const SourceControlFile&> get_control_file(const std::string& src_name) const override; + explicit MapPortFileProvider(const std::unordered_map<std::string, SourceControlFileLocation>& map); + Optional<const SourceControlFileLocation&> get_control_file(const std::string& src_name) const override; + std::vector<const SourceControlFileLocation*> load_all_control_files() const override; private: - const std::unordered_map<std::string, SourceControlFile>& ports; + const std::unordered_map<std::string, SourceControlFileLocation>& ports; }; struct PathsPortFileProvider : Util::ResourceBase, PortFileProvider { - explicit PathsPortFileProvider(const VcpkgPaths& paths); - Optional<const SourceControlFile&> get_control_file(const std::string& src_name) const override; + explicit PathsPortFileProvider(const vcpkg::VcpkgPaths& paths, + const std::vector<std::string>* ports_dirs_paths); + Optional<const SourceControlFileLocation&> get_control_file(const std::string& src_name) const override; + std::vector<const SourceControlFileLocation*> load_all_control_files() const override; private: - const VcpkgPaths& ports; - mutable std::unordered_map<std::string, SourceControlFile> cache; + Files::Filesystem& filesystem; + std::vector<fs::path> ports_dirs; + mutable std::unordered_map<std::string, SourceControlFileLocation> cache; }; struct ClusterGraph; @@ -181,7 +186,7 @@ namespace vcpkg::Dependencies std::vector<ExportPlanAction> create_export_plan(const std::vector<PackageSpec>& specs, const StatusParagraphs& status_db); - std::vector<AnyAction> create_feature_install_plan(const std::unordered_map<std::string, SourceControlFile>& map, + std::vector<AnyAction> create_feature_install_plan(const std::unordered_map<std::string, SourceControlFileLocation>& map, const std::vector<FeatureSpec>& specs, const StatusParagraphs& status_db); @@ -194,5 +199,7 @@ namespace vcpkg::Dependencies const StatusParagraphs& status_db, const CreateInstallPlanOptions& options = {}); - void print_plan(const std::vector<AnyAction>& action_plan, const bool is_recursive = true); + void print_plan(const std::vector<AnyAction>& action_plan, + const bool is_recursive = true, + const fs::path& default_ports_dir = ""); } 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<const FeatureParagraph&> find_feature(const std::string& featurename) const; }; + /// <summary> + /// Full metadata of a package: core and other features. As well as the location the SourceControlFile was loaded from. + /// </summary> + struct SourceControlFileLocation + { + std::unique_ptr<SourceControlFile> source_control_file; + fs::path source_location; + }; + void print_error_message(Span<const std::unique_ptr<Parse::ParseControlErrorInfo>> error_info_list); inline void print_error_message(const std::unique_ptr<Parse::ParseControlErrorInfo>& error_info_list) { diff --git a/toolsrc/include/vcpkg/vcpkgcmdarguments.h b/toolsrc/include/vcpkg/vcpkgcmdarguments.h index de65eec28..ff13ae6bf 100644 --- a/toolsrc/include/vcpkg/vcpkgcmdarguments.h +++ b/toolsrc/include/vcpkg/vcpkgcmdarguments.h @@ -15,6 +15,7 @@ namespace vcpkg { std::unordered_set<std::string> switches; std::unordered_map<std::string, std::string> settings; + std::unordered_map<std::string, std::vector<std::string>> 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<const CommandSwitch> switches; Span<const CommandSetting> settings; + Span<const CommandMultiSetting> multisettings; }; struct CommandStructure @@ -74,6 +87,8 @@ namespace vcpkg std::unique_ptr<std::string> vcpkg_root_dir; std::unique_ptr<std::string> triplet; + std::unique_ptr<std::vector<std::string>> overlay_ports; + std::unique_ptr<std::vector<std::string>> overlay_triplets; Optional<bool> debug = nullopt; Optional<bool> sendmetrics = nullopt; Optional<bool> printmetrics = nullopt; @@ -88,6 +103,6 @@ namespace vcpkg ParsedArguments parse_arguments(const CommandStructure& command_structure) const; private: - std::unordered_map<std::string, Optional<std::string>> optional_command_arguments; + std::unordered_map<std::string, Optional<std::vector<std::string>>> optional_command_arguments; }; } diff --git a/toolsrc/include/vcpkg/vcpkgpaths.h b/toolsrc/include/vcpkg/vcpkgpaths.h index 42de40d9c..a30e0c653 100644 --- a/toolsrc/include/vcpkg/vcpkgpaths.h +++ b/toolsrc/include/vcpkg/vcpkgpaths.h @@ -47,16 +47,17 @@ namespace vcpkg struct VcpkgPaths { - static Expected<VcpkgPaths> create(const fs::path& vcpkg_root_dir, const std::string& default_vs_path); + static Expected<VcpkgPaths> create(const fs::path& vcpkg_root_dir, + const std::string& default_vs_path, + const std::vector<std::string>* triplets_dirs); 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; - - const std::vector<std::string>& get_available_triplets() const; + bool is_valid_triplet(const Triplet& t) const; + const std::vector<std::string>& get_available_triplets() const; + const fs::path get_triplet_file_path(const Triplet& triplet) const; fs::path root; fs::path packages; @@ -95,7 +96,9 @@ namespace vcpkg Lazy<std::vector<Toolset>> toolsets_vs2013; fs::path default_vs_path; + std::vector<fs::path> triplets_dirs; mutable std::unique_ptr<ToolCache> m_tool_cache; + mutable vcpkg::Cache<Triplet, fs::path> m_triplets_cache; }; } |
