diff options
| author | Billy O'Neal <bion@microsoft.com> | 2020-06-03 19:31:28 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-03 19:31:28 -0700 |
| commit | 4fb225608532e9fb2fd2f5f1dbe9ec092cdc7c93 (patch) | |
| tree | d4ccfc78c9043c6c136dc2ec72a3f005366564a3 /toolsrc/include | |
| parent | 20e6626d8758f5e46c1777e3e1ff4d98ed5d2e7a (diff) | |
| download | vcpkg-4fb225608532e9fb2fd2f5f1dbe9ec092cdc7c93.tar.gz vcpkg-4fb225608532e9fb2fd2f5f1dbe9ec092cdc7c93.zip | |
[vcpkg] Allow CI to pass in all relevant directories and remove use of symbolic links (#11483)
Diffstat (limited to 'toolsrc/include')
| -rw-r--r-- | toolsrc/include/vcpkg/base/files.h | 4 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/commands.h | 9 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/help.h | 16 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/metrics.h | 3 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/vcpkgcmdarguments.h | 43 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/vcpkgpaths.h | 14 |
6 files changed, 54 insertions, 35 deletions
diff --git a/toolsrc/include/vcpkg/base/files.h b/toolsrc/include/vcpkg/base/files.h index 0fba3a55f..909029b55 100644 --- a/toolsrc/include/vcpkg/base/files.h +++ b/toolsrc/include/vcpkg/base/files.h @@ -19,10 +19,10 @@ namespace fs #endif using stdfs::copy_options; + using stdfs::directory_iterator; using stdfs::path; using stdfs::perms; using stdfs::u8path; - using stdfs::directory_iterator; #if defined(_WIN32) enum class file_type @@ -166,6 +166,8 @@ namespace vcpkg::Files fs::path canonical(const fs::path& path, ignore_errors_t) const; virtual fs::path current_path(std::error_code&) const = 0; fs::path current_path(LineInfo li) const; + virtual void current_path(const fs::path& path, std::error_code&) = 0; + void current_path(const fs::path& path, LineInfo li); virtual std::vector<fs::path> find_from_PATH(const std::string& name) const = 0; }; diff --git a/toolsrc/include/vcpkg/commands.h b/toolsrc/include/vcpkg/commands.h index 55d6bd7aa..c4b231433 100644 --- a/toolsrc/include/vcpkg/commands.h +++ b/toolsrc/include/vcpkg/commands.h @@ -14,7 +14,7 @@ namespace vcpkg::Commands { using CommandTypeA = void (*)(const VcpkgCmdArguments& args, const VcpkgPaths& paths, Triplet default_triplet); using CommandTypeB = void (*)(const VcpkgCmdArguments& args, const VcpkgPaths& paths); - using CommandTypeC = void (*)(const VcpkgCmdArguments& args); + using CommandTypeC = void (*)(const VcpkgCmdArguments& args, Files::Filesystem& fs); namespace BuildExternal { @@ -92,10 +92,11 @@ namespace vcpkg::Commands namespace Integrate { - extern const char* const INTEGRATE_COMMAND_HELPSTRING; extern const CommandStructure COMMAND_STRUCTURE; void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths); + void append_helpstring(HelpTableFormatter& table); + std::string get_helpstring(); } namespace PortsDiff @@ -118,14 +119,14 @@ namespace vcpkg::Commands const char* base_version(); const std::string& version(); void warn_if_vcpkg_version_mismatch(const VcpkgPaths& paths); - void perform_and_exit(const VcpkgCmdArguments& args); + void perform_and_exit(const VcpkgCmdArguments& args, Files::Filesystem& fs); } namespace Contact { extern const CommandStructure COMMAND_STRUCTURE; const std::string& email(); - void perform_and_exit(const VcpkgCmdArguments& args); + void perform_and_exit(const VcpkgCmdArguments& args, Files::Filesystem& fs); } namespace X_VSInstances diff --git a/toolsrc/include/vcpkg/help.h b/toolsrc/include/vcpkg/help.h index 87ce60b76..97bc11864 100644 --- a/toolsrc/include/vcpkg/help.h +++ b/toolsrc/include/vcpkg/help.h @@ -12,20 +12,4 @@ namespace vcpkg::Help void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths); void help_topic_valid_triplet(const VcpkgPaths& paths); - - void print_usage(); - - std::string create_example_string(const std::string& command_and_arguments); - - struct HelpTableFormatter - { - void format(StringView col1, StringView col2); - - std::string m_str; - - private: - void newline_indent(); - void indent(); - }; - } diff --git a/toolsrc/include/vcpkg/metrics.h b/toolsrc/include/vcpkg/metrics.h index c56a227f3..832da90ce 100644 --- a/toolsrc/include/vcpkg/metrics.h +++ b/toolsrc/include/vcpkg/metrics.h @@ -1,6 +1,7 @@ #pragma once #include <vcpkg/base/util.h> +#include <vcpkg/base/files.h> #include <string> @@ -21,7 +22,7 @@ namespace vcpkg::Metrics bool metrics_enabled(); void upload(const std::string& payload); - void flush(); + void flush(Files::Filesystem& fs); }; extern Util::LockGuarded<Metrics> g_metrics; diff --git a/toolsrc/include/vcpkg/vcpkgcmdarguments.h b/toolsrc/include/vcpkg/vcpkgcmdarguments.h index f8602b1e9..4856f6db1 100644 --- a/toolsrc/include/vcpkg/vcpkgcmdarguments.h +++ b/toolsrc/include/vcpkg/vcpkgcmdarguments.h @@ -3,6 +3,7 @@ #include <vcpkg/base/optional.h> #include <vcpkg/base/span.h> #include <vcpkg/base/stringliteral.h> +#include <vcpkg/base/files.h> #include <memory> #include <unordered_map> @@ -72,7 +73,8 @@ namespace vcpkg std::vector<std::string> (*valid_arguments)(const VcpkgPaths& paths); }; - void display_usage(const CommandStructure& command_structure); + void print_usage(); + void print_usage(const CommandStructure& command_structure); #if defined(_WIN32) using CommandLineCharType = wchar_t; @@ -80,33 +82,62 @@ namespace vcpkg using CommandLineCharType = char; #endif + std::string create_example_string(const std::string& command_and_arguments); + + std::string format_environment_variable(StringLiteral lit); + + struct HelpTableFormatter + { + void format(StringView col1, StringView col2); + void example(StringView example_text); + void header(StringView name); + void blank(); + + std::string m_str; + }; + struct VcpkgCmdArguments { - static VcpkgCmdArguments create_from_command_line(const int argc, const CommandLineCharType* const* const argv); + static VcpkgCmdArguments create_from_command_line(const Files::Filesystem& fs, + const int argc, + const CommandLineCharType* const* const argv); static VcpkgCmdArguments create_from_arg_sequence(const std::string* arg_begin, const std::string* arg_end); + static void append_common_options(HelpTableFormatter& target); + std::unique_ptr<std::string> vcpkg_root_dir; + + std::unique_ptr<std::string> buildtrees_root_dir; + std::unique_ptr<std::string> downloads_root_dir; std::unique_ptr<std::string> install_root_dir; + std::unique_ptr<std::string> packages_root_dir; std::unique_ptr<std::string> scripts_root_dir; + + std::unique_ptr<std::string> default_visual_studio_path; + std::unique_ptr<std::string> triplet; std::unique_ptr<std::vector<std::string>> overlay_ports; std::unique_ptr<std::vector<std::string>> overlay_triplets; + std::vector<std::string> binarysources; + Optional<bool> debug = nullopt; - Optional<bool> sendmetrics = nullopt; + Optional<bool> send_metrics = nullopt; // fully disable metrics -- both printing and sending Optional<bool> disable_metrics = nullopt; - Optional<bool> printmetrics = nullopt; + Optional<bool> print_metrics = nullopt; // feature flags - Optional<bool> featurepackages = nullopt; - Optional<bool> binarycaching = nullopt; + Optional<bool> feature_packages = nullopt; + Optional<bool> binary_caching = nullopt; std::string command; std::vector<std::string> command_arguments; ParsedArguments parse_arguments(const CommandStructure& command_structure) const; + void imbue_from_environment(); + private: 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 2588abf4d..2b7faffd9 100644 --- a/toolsrc/include/vcpkg/vcpkgpaths.h +++ b/toolsrc/include/vcpkg/vcpkgpaths.h @@ -3,6 +3,7 @@ #include <vcpkg/binaryparagraph.h> #include <vcpkg/packagespec.h> #include <vcpkg/tools.h> +#include <vcpkg/vcpkgcmdarguments.h> #include <vcpkg/base/cache.h> #include <vcpkg/base/expected.h> @@ -57,12 +58,7 @@ namespace vcpkg TripletFile(const std::string& name, const fs::path& location) : name(name), location(location) {} }; - static Expected<VcpkgPaths> create(const fs::path& vcpkg_root_dir, - const Optional<fs::path>& install_root_dir, - const Optional<fs::path>& vcpkg_scripts_root_dir, - const std::string& default_vs_path, - const std::vector<std::string>* triplets_dirs, - fs::path original_cwd); + VcpkgPaths(Files::Filesystem& filesystem, const VcpkgCmdArguments& args); fs::path package_dir(const PackageSpec& spec) const; fs::path build_info_file_path(const PackageSpec& spec) const; @@ -75,14 +71,16 @@ namespace vcpkg fs::path original_cwd; fs::path root; - fs::path packages; + fs::path buildtrees; fs::path downloads; + fs::path packages; fs::path ports; fs::path installed; fs::path triplets; fs::path community_triplets; fs::path scripts; + fs::path prefab; fs::path tools; fs::path buildsystems; @@ -114,6 +112,8 @@ namespace vcpkg fs::path default_vs_path; std::vector<fs::path> triplets_dirs; + Files::Filesystem* fsPtr; + mutable std::unique_ptr<ToolCache> m_tool_cache; mutable vcpkg::Cache<Triplet, fs::path> m_triplets_cache; }; |
