diff options
| author | Phil Christensen <philc@microsoft.com> | 2018-12-06 15:06:28 -0800 |
|---|---|---|
| committer | Phil Christensen <philc@microsoft.com> | 2018-12-06 15:06:28 -0800 |
| commit | 7347305e8459fcc78553a9f88196e0d93eb0a8fe (patch) | |
| tree | ac9eee9ff267c6a71a83249bed7a94f02b00d9a5 /toolsrc/include | |
| parent | ed9357a5aafea7192932b5874264bd103fc61255 (diff) | |
| parent | 63c1b2628e958f8e02356411f032941c0c2f3bbb (diff) | |
| download | vcpkg-7347305e8459fcc78553a9f88196e0d93eb0a8fe.tar.gz vcpkg-7347305e8459fcc78553a9f88196e0d93eb0a8fe.zip | |
Merge branch 'master' of https://github.com/microsoft/vcpkg into dev/philc/3425
Diffstat (limited to 'toolsrc/include')
| -rw-r--r-- | toolsrc/include/vcpkg/archives.h | 9 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/chrono.h | 8 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/downloads.h | 16 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/files.h | 20 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/hash.h | 11 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/stringliteral.h | 3 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/stringrange.h | 33 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/strings.h | 4 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/system.h | 27 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/util.h | 12 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/build.h | 14 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/commands.h | 21 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/globalstate.h | 22 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/tools.h | 21 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/vcpkgpaths.h | 6 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/visualstudio.h | 14 |
16 files changed, 179 insertions, 62 deletions
diff --git a/toolsrc/include/vcpkg/archives.h b/toolsrc/include/vcpkg/archives.h new file mode 100644 index 000000000..2298f9e1e --- /dev/null +++ b/toolsrc/include/vcpkg/archives.h @@ -0,0 +1,9 @@ +#pragma once + +#include <vcpkg/base/files.h> +#include <vcpkg/vcpkgpaths.h> + +namespace vcpkg::Archives +{ + void extract_archive(const VcpkgPaths& paths, const fs::path& archive, const fs::path& to_path); +} diff --git a/toolsrc/include/vcpkg/base/chrono.h b/toolsrc/include/vcpkg/base/chrono.h index aa764a597..6f6e2b317 100644 --- a/toolsrc/include/vcpkg/base/chrono.h +++ b/toolsrc/include/vcpkg/base/chrono.h @@ -52,8 +52,10 @@ namespace vcpkg::Chrono static Optional<CTime> get_current_date_time(); static Optional<CTime> parse(CStringView str); - constexpr CTime() noexcept : m_tm{0} {} - explicit constexpr CTime(tm t) noexcept : m_tm{t} {} + constexpr CTime() noexcept : m_tm {0} {} + explicit constexpr CTime(tm t) noexcept : m_tm {t} {} + + CTime add_hours(const int hours) const; std::string to_string() const; @@ -62,4 +64,6 @@ namespace vcpkg::Chrono private: mutable tm m_tm; }; + + tm get_current_date_time_local(); } diff --git a/toolsrc/include/vcpkg/base/downloads.h b/toolsrc/include/vcpkg/base/downloads.h new file mode 100644 index 000000000..61c792488 --- /dev/null +++ b/toolsrc/include/vcpkg/base/downloads.h @@ -0,0 +1,16 @@ +#pragma once + +#include <vcpkg/base/files.h> + +namespace vcpkg::Downloads +{ + void verify_downloaded_file_hash(const Files::Filesystem& fs, + const std::string& url, + const fs::path& path, + const std::string& sha512); + + void download_file(Files::Filesystem& fs, + const std::string& url, + const fs::path& download_path, + const std::string& sha512); +} diff --git a/toolsrc/include/vcpkg/base/files.h b/toolsrc/include/vcpkg/base/files.h index f16805d0a..b07ff25b3 100644 --- a/toolsrc/include/vcpkg/base/files.h +++ b/toolsrc/include/vcpkg/base/files.h @@ -20,7 +20,7 @@ namespace fs inline bool is_regular_file(file_status s) { return stdfs::is_regular_file(s); } inline bool is_directory(file_status s) { return stdfs::is_directory(s); } - inline bool status_known(file_status s) { return stdfs::status_known(s); } + inline bool is_symlink(file_status s) { return stdfs::is_symlink(s); } } namespace vcpkg::Files @@ -37,6 +37,10 @@ namespace vcpkg::Files 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; 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; 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; @@ -51,15 +55,13 @@ namespace vcpkg::Files const fs::path& newpath, fs::copy_options opts, std::error_code& ec) = 0; + virtual void copy_symlink(const fs::path& oldpath, const fs::path& newpath, std::error_code& ec) = 0; virtual fs::file_status status(const fs::path& path, std::error_code& ec) const = 0; + virtual fs::file_status symlink_status(const fs::path& path, std::error_code& ec) const = 0; - inline void write_contents(const fs::path& file_path, const std::string& data) - { - std::error_code ec; - write_contents(file_path, data, ec); - Checks::check_exit( - VCPKG_LINE_INFO, !ec, "error while writing file: %s: %s", file_path.u8string(), ec.message()); - } + 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(); @@ -69,6 +71,4 @@ namespace vcpkg::Files bool has_invalid_chars_for_filesystem(const std::string& s); void print_paths(const std::vector<fs::path>& paths); - - std::vector<fs::path> find_from_PATH(const std::string& name); } diff --git a/toolsrc/include/vcpkg/base/hash.h b/toolsrc/include/vcpkg/base/hash.h new file mode 100644 index 000000000..9e6f118c0 --- /dev/null +++ b/toolsrc/include/vcpkg/base/hash.h @@ -0,0 +1,11 @@ +#pragma once + +#include <vcpkg/base/files.h> + +#include <string> + +namespace vcpkg::Hash +{ + std::string get_string_hash(const std::string& s, const std::string& hash_type); + std::string get_file_hash(const Files::Filesystem& fs, const fs::path& path, const std::string& hash_type); +} diff --git a/toolsrc/include/vcpkg/base/stringliteral.h b/toolsrc/include/vcpkg/base/stringliteral.h index c07f04cec..9970adc2a 100644 --- a/toolsrc/include/vcpkg/base/stringliteral.h +++ b/toolsrc/include/vcpkg/base/stringliteral.h @@ -7,7 +7,8 @@ namespace vcpkg struct StringLiteral { template<int N> - constexpr StringLiteral(const char (&str)[N]) : m_size(N), m_cstr(str) + constexpr StringLiteral(const char (&str)[N]) + : m_size(N - 1) /* -1 here accounts for the null byte at the end*/, m_cstr(str) { } diff --git a/toolsrc/include/vcpkg/base/stringrange.h b/toolsrc/include/vcpkg/base/stringrange.h new file mode 100644 index 000000000..6126ec48f --- /dev/null +++ b/toolsrc/include/vcpkg/base/stringrange.h @@ -0,0 +1,33 @@ +#pragma once + +#include <vcpkg/base/optional.h> + +#include <string> +#include <vector> + +namespace vcpkg +{ + struct StringRange + { + static std::vector<StringRange> find_all_enclosed(const StringRange& input, + const std::string& left_delim, + const std::string& right_delim); + + static StringRange find_exactly_one_enclosed(const StringRange& input, + const std::string& left_tag, + const std::string& right_tag); + + static Optional<StringRange> find_at_most_one_enclosed(const StringRange& input, + const std::string& left_tag, + const std::string& right_tag); + + StringRange() = default; + StringRange(const std::string& s); // Implicit by design + StringRange(const std::string::const_iterator begin, const std::string::const_iterator end); + + std::string::const_iterator begin; + std::string::const_iterator end; + + std::string to_string() const; + }; +} diff --git a/toolsrc/include/vcpkg/base/strings.h b/toolsrc/include/vcpkg/base/strings.h index 4cc17bcf4..4b39b0a28 100644 --- a/toolsrc/include/vcpkg/base/strings.h +++ b/toolsrc/include/vcpkg/base/strings.h @@ -1,6 +1,7 @@ #pragma once #include <vcpkg/base/cstringview.h> +#include <vcpkg/base/stringliteral.h> #include <vector> @@ -34,9 +35,11 @@ namespace vcpkg::Strings return details::format_internal(fmtstr, to_printf_arg(to_printf_arg(args))...); } +#if defined(_WIN32) std::wstring to_utf16(const CStringView& s); std::string to_utf8(const wchar_t* w); +#endif std::string escape_string(const CStringView& s, char char_to_escape, char escape_char); @@ -51,6 +54,7 @@ namespace vcpkg::Strings std::string ascii_to_uppercase(std::string s); bool case_insensitive_ascii_starts_with(const std::string& s, const std::string& pattern); + bool ends_with(const std::string& s, StringLiteral pattern); template<class Container, class Transformer> std::string join(const char* delimiter, const Container& v, Transformer transformer) diff --git a/toolsrc/include/vcpkg/base/system.h b/toolsrc/include/vcpkg/base/system.h index 0d089276f..af56e45c1 100644 --- a/toolsrc/include/vcpkg/base/system.h +++ b/toolsrc/include/vcpkg/base/system.h @@ -8,8 +8,6 @@ namespace vcpkg::System { - tm get_current_date_time(); - fs::path get_exe_path_of_current_process(); struct CMakeVariable @@ -25,15 +23,6 @@ namespace vcpkg::System const fs::path& cmake_script, const std::vector<CMakeVariable>& pass_variables); - struct PowershellParameter - { - PowershellParameter(const CStringView varname, const char* varvalue); - PowershellParameter(const CStringView varname, const std::string& varvalue); - PowershellParameter(const CStringView varname, const fs::path& path); - - std::string s; - }; - struct ExitCodeAndOutput { int exit_code; @@ -41,19 +30,15 @@ namespace vcpkg::System }; int cmd_execute_clean(const CStringView cmd_line, - const std::unordered_map<std::string, std::string>& extra_env = {}); - - int cmd_execute(const CStringView cmd_line); + const std::unordered_map<std::string, std::string>& extra_env = {}) noexcept; - ExitCodeAndOutput cmd_execute_and_capture_output(const CStringView cmd_line); + int cmd_execute(const CStringView cmd_line) noexcept; - void powershell_execute(const std::string& title, - const fs::path& script_path, - const std::vector<PowershellParameter>& parameters = {}); +#if defined(_WIN32) + void cmd_execute_no_wait(const CStringView cmd_line) noexcept; +#endif - std::string powershell_execute_and_capture_output(const std::string& title, - const fs::path& script_path, - const std::vector<PowershellParameter>& parameters = {}); + ExitCodeAndOutput cmd_execute_and_capture_output(const CStringView cmd_line) noexcept; enum class Color { diff --git a/toolsrc/include/vcpkg/base/util.h b/toolsrc/include/vcpkg/base/util.h index 7266fbbc6..65ce02b99 100644 --- a/toolsrc/include/vcpkg/base/util.h +++ b/toolsrc/include/vcpkg/base/util.h @@ -72,18 +72,6 @@ namespace vcpkg::Util } template<class Container, class Pred> - void stable_keep_if(Container& cont, Pred pred) - { - cont.erase(std::stable_partition(cont.begin(), cont.end(), pred), cont.end()); - } - - template<class Container, class Pred> - void unstable_keep_if(Container& cont, Pred pred) - { - cont.erase(std::partition(cont.begin(), cont.end(), pred), cont.end()); - } - - template<class Container, class Pred> void erase_remove_if(Container& cont, Pred pred) { cont.erase(std::remove_if(cont.begin(), cont.end(), pred), cont.end()); diff --git a/toolsrc/include/vcpkg/build.h b/toolsrc/include/vcpkg/build.h index c5e7e8d88..f27e9d67b 100644 --- a/toolsrc/include/vcpkg/build.h +++ b/toolsrc/include/vcpkg/build.h @@ -64,6 +64,18 @@ namespace vcpkg::Build }; const std::string& to_string(DownloadTool tool); + enum class BinaryCaching + { + NO = 0, + YES + }; + + enum class FailOnTombstone + { + NO = 0, + YES + }; + struct BuildPackageOptions { UseHeadVersion use_head_version; @@ -71,6 +83,8 @@ namespace vcpkg::Build CleanBuildtrees clean_buildtrees; CleanPackages clean_packages; DownloadTool download_tool; + BinaryCaching binary_caching; + FailOnTombstone fail_on_tombstone; }; enum class BuildResult diff --git a/toolsrc/include/vcpkg/commands.h b/toolsrc/include/vcpkg/commands.h index 6d29b7960..fd7d832b3 100644 --- a/toolsrc/include/vcpkg/commands.h +++ b/toolsrc/include/vcpkg/commands.h @@ -25,17 +25,7 @@ namespace vcpkg::Commands namespace CI { - struct UnknownCIPortsResults - { - std::vector<PackageSpec> unknown; - std::map<PackageSpec, Build::BuildResult> known; - }; - extern const CommandStructure COMMAND_STRUCTURE; - UnknownCIPortsResults find_unknown_ports_for_ci(const VcpkgPaths& paths, - const std::set<std::string>& exclusions, - const Dependencies::PortFileProvider& provider, - const std::vector<FeatureSpec>& fspecs); void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_triplet); } @@ -129,18 +119,19 @@ namespace vcpkg::Commands void perform_and_exit(const VcpkgCmdArguments& args); } - namespace Hash + namespace X_VSInstances { - std::string get_string_hash(const std::string& s, const std::string& hash_type); - std::string get_file_hash(const VcpkgPaths& paths, const fs::path& path, const std::string& hash_type); + extern const CommandStructure COMMAND_STRUCTURE; + void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths); + } + namespace Hash + { void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths); } namespace Fetch { - std::vector<Toolset> find_toolset_instances(const VcpkgPaths& paths); - fs::path get_tool_path(const VcpkgPaths& paths, const std::string& tool); void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths); } diff --git a/toolsrc/include/vcpkg/globalstate.h b/toolsrc/include/vcpkg/globalstate.h index bc28e3ff8..ae66ca355 100644 --- a/toolsrc/include/vcpkg/globalstate.h +++ b/toolsrc/include/vcpkg/globalstate.h @@ -18,5 +18,27 @@ namespace vcpkg static std::atomic<int> g_init_console_cp; static std::atomic<int> g_init_console_output_cp; + static std::atomic<bool> g_init_console_initialized; + + struct CtrlCStateMachine + { + CtrlCStateMachine(); + + void transition_to_spawn_process() noexcept; + void transition_from_spawn_process() noexcept; + void transition_handle_ctrl_c() noexcept; + + private: + enum class CtrlCState + { + normal, + blocked_on_child, + exit_requested, + }; + + std::atomic<CtrlCState> m_state; + }; + + static CtrlCStateMachine g_ctrl_c_state; }; } diff --git a/toolsrc/include/vcpkg/tools.h b/toolsrc/include/vcpkg/tools.h new file mode 100644 index 000000000..6a096c321 --- /dev/null +++ b/toolsrc/include/vcpkg/tools.h @@ -0,0 +1,21 @@ +#pragma once + +#include <vcpkg/base/files.h> + +#include <string> +#include <utility> + +namespace vcpkg +{ + struct VcpkgPaths; + + struct ToolCache + { + virtual ~ToolCache() {} + + virtual const fs::path& get_tool_path(const VcpkgPaths& paths, const std::string& tool) const = 0; + virtual const std::string& get_tool_version(const VcpkgPaths& paths, const std::string& tool) const = 0; + }; + + std::unique_ptr<ToolCache> get_tool_cache(); +} diff --git a/toolsrc/include/vcpkg/vcpkgpaths.h b/toolsrc/include/vcpkg/vcpkgpaths.h index 9c8f2911a..42de40d9c 100644 --- a/toolsrc/include/vcpkg/vcpkgpaths.h +++ b/toolsrc/include/vcpkg/vcpkgpaths.h @@ -2,6 +2,7 @@ #include <vcpkg/binaryparagraph.h> #include <vcpkg/packagespec.h> +#include <vcpkg/tools.h> #include <vcpkg/base/cache.h> #include <vcpkg/base/expected.h> @@ -66,6 +67,7 @@ namespace vcpkg fs::path triplets; fs::path scripts; + fs::path tools; fs::path buildsystems; fs::path buildsystems_msbuild_targets; @@ -77,6 +79,7 @@ namespace vcpkg fs::path ports_cmake; const fs::path& get_tool_exe(const std::string& tool) const; + const std::string& get_tool_version(const std::string& tool) const; /// <summary>Retrieve a toolset matching a VS version</summary> /// <remarks> @@ -88,10 +91,11 @@ namespace vcpkg private: Lazy<std::vector<std::string>> available_triplets; - Cache<std::string, fs::path> tool_paths; Lazy<std::vector<Toolset>> toolsets; Lazy<std::vector<Toolset>> toolsets_vs2013; fs::path default_vs_path; + + mutable std::unique_ptr<ToolCache> m_tool_cache; }; } diff --git a/toolsrc/include/vcpkg/visualstudio.h b/toolsrc/include/vcpkg/visualstudio.h new file mode 100644 index 000000000..cd99db352 --- /dev/null +++ b/toolsrc/include/vcpkg/visualstudio.h @@ -0,0 +1,14 @@ +#pragma once
+
+#if defined(_WIN32)
+
+#include <vcpkg/vcpkgpaths.h>
+
+namespace vcpkg::VisualStudio
+{
+ std::vector<std::string> get_visual_studio_instances(const VcpkgPaths& paths);
+
+ std::vector<Toolset> find_toolset_instances_preferred_first(const VcpkgPaths& paths);
+}
+
+#endif
|
