From 3f76b9e53d48e34960bb5947bbbb880ac806281b Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Mon, 3 Apr 2017 16:29:11 -0700 Subject: vcpkg_paths -> VcpkgPaths --- toolsrc/src/Paragraphs.cpp | 2 +- toolsrc/src/PostBuildLint.cpp | 8 +- toolsrc/src/VcpkgPaths.cpp | 338 ++++++++++++++++++++++++++++++++ toolsrc/src/commands_build.cpp | 8 +- toolsrc/src/commands_build_external.cpp | 2 +- toolsrc/src/commands_cache.cpp | 4 +- toolsrc/src/commands_ci.cpp | 2 +- toolsrc/src/commands_create.cpp | 2 +- toolsrc/src/commands_edit.cpp | 2 +- toolsrc/src/commands_env.cpp | 2 +- toolsrc/src/commands_help.cpp | 4 +- toolsrc/src/commands_import.cpp | 4 +- toolsrc/src/commands_install.cpp | 6 +- toolsrc/src/commands_integrate.cpp | 6 +- toolsrc/src/commands_list.cpp | 2 +- toolsrc/src/commands_owns.cpp | 4 +- toolsrc/src/commands_portsdiff.cpp | 4 +- toolsrc/src/commands_remove.cpp | 4 +- toolsrc/src/commands_search.cpp | 2 +- toolsrc/src/commands_update.cpp | 4 +- toolsrc/src/vcpkg.cpp | 4 +- toolsrc/src/vcpkg_Dependencies.cpp | 4 +- toolsrc/src/vcpkg_Input.cpp | 2 +- toolsrc/src/vcpkg_paths.cpp | 338 -------------------------------- toolsrc/src/vcpkglib.cpp | 6 +- 25 files changed, 382 insertions(+), 382 deletions(-) create mode 100644 toolsrc/src/VcpkgPaths.cpp delete mode 100644 toolsrc/src/vcpkg_paths.cpp (limited to 'toolsrc/src') diff --git a/toolsrc/src/Paragraphs.cpp b/toolsrc/src/Paragraphs.cpp index 4fd424f83..98eb64328 100644 --- a/toolsrc/src/Paragraphs.cpp +++ b/toolsrc/src/Paragraphs.cpp @@ -222,7 +222,7 @@ namespace vcpkg::Paragraphs return pghs.error_code(); } - Expected try_load_cached_package(const vcpkg_paths& paths, const PackageSpec& spec) + Expected try_load_cached_package(const VcpkgPaths& paths, const PackageSpec& spec) { Expected> pghs = get_single_paragraph(paths.package_dir(spec) / "CONTROL"); diff --git a/toolsrc/src/PostBuildLint.cpp b/toolsrc/src/PostBuildLint.cpp index 4a3308c47..30b262da9 100644 --- a/toolsrc/src/PostBuildLint.cpp +++ b/toolsrc/src/PostBuildLint.cpp @@ -1,5 +1,5 @@ #include "pch.h" -#include "vcpkg_paths.h" +#include "VcpkgPaths.h" #include "PackageSpec.h" #include "vcpkg_Files.h" #include "vcpkg_System.h" @@ -174,7 +174,7 @@ namespace vcpkg::PostBuildLint return lint_status::SUCCESS; } - static lint_status check_for_copyright_file(const PackageSpec& spec, const vcpkg_paths& paths) + static lint_status check_for_copyright_file(const PackageSpec& spec, const VcpkgPaths& paths) { const fs::path packages_dir = paths.packages / spec.dir(); const fs::path copyright_file = packages_dir / "share" / spec.name() / "copyright"; @@ -619,7 +619,7 @@ namespace vcpkg::PostBuildLint left += static_cast(right); } - static size_t perform_all_checks_and_return_error_count(const PackageSpec& spec, const vcpkg_paths& paths) + static size_t perform_all_checks_and_return_error_count(const PackageSpec& spec, const VcpkgPaths& paths) { // for dumpbin const Toolset& toolset = paths.get_toolset(); @@ -709,7 +709,7 @@ namespace vcpkg::PostBuildLint return error_count; } - size_t perform_all_checks(const PackageSpec& spec, const vcpkg_paths& paths) + size_t perform_all_checks(const PackageSpec& spec, const VcpkgPaths& paths) { System::println("-- Performing post-build validation"); const size_t error_count = perform_all_checks_and_return_error_count(spec, paths); diff --git a/toolsrc/src/VcpkgPaths.cpp b/toolsrc/src/VcpkgPaths.cpp new file mode 100644 index 000000000..93a181ef5 --- /dev/null +++ b/toolsrc/src/VcpkgPaths.cpp @@ -0,0 +1,338 @@ +#include "pch.h" +#include "vcpkg_expected.h" +#include "VcpkgPaths.h" +#include "metrics.h" +#include "vcpkg_System.h" +#include "PackageSpec.h" +#include "vcpkg_Files.h" +#include "vcpkg_Util.h" + +namespace vcpkg +{ + static bool exists_and_has_equal_or_greater_version(const std::wstring& version_cmd, const std::array& expected_version) + { + static const std::regex re(R"###((\d+)\.(\d+)\.(\d+))###"); + + auto rc = System::cmd_execute_and_capture_output(Strings::wformat(LR"(%s)", version_cmd)); + if (rc.exit_code != 0) + { + return false; + } + + std::match_results match; + auto found = std::regex_search(rc.output, match, re); + if (!found) + { + return false; + } + + int d1 = atoi(match[1].str().c_str()); + int d2 = atoi(match[2].str().c_str()); + int d3 = atoi(match[3].str().c_str()); + if (d1 > expected_version[0] || (d1 == expected_version[0] && d2 > expected_version[1]) || (d1 == expected_version[0] && d2 == expected_version[1] && d3 >= expected_version[2])) + { + // satisfactory version found + return true; + } + + return false; + } + + static Optional find_if_has_equal_or_greater_version(const std::vector& candidate_paths, const std::wstring& version_check_arguments, const std::array& expected_version) + { + auto it = std::find_if(candidate_paths.cbegin(), candidate_paths.cend(), [&](const fs::path& p) + { + const std::wstring cmd = Strings::wformat(LR"("%s" %s)", p.native(), version_check_arguments); + return exists_and_has_equal_or_greater_version(cmd, expected_version); + }); + + if (it != candidate_paths.cend()) + { + return std::move(*it); + } + + return nullopt; + } + + static std::vector find_from_PATH(const std::wstring& name) + { + const std::wstring cmd = Strings::wformat(L"where.exe %s", name); + auto out = System::cmd_execute_and_capture_output(cmd); + if (out.exit_code != 0) + { + return {}; + } + + return Util::fmap(Strings::split(out.output, "\n"), [](auto&& s) { return fs::path(s); }); + } + + static fs::path fetch_dependency(const fs::path scripts_folder, const std::wstring& tool_name, const fs::path& expected_downloaded_path) + { + const fs::path script = scripts_folder / "fetchDependency.ps1"; + auto install_cmd = System::create_powershell_script_cmd(script, Strings::wformat(L"-Dependency %s", tool_name)); + System::exit_code_and_output rc = System::cmd_execute_and_capture_output(install_cmd); + if (rc.exit_code) + { + System::println(System::color::error, "Launching powershell failed or was denied"); + Metrics::track_property("error", "powershell install failed"); + Metrics::track_property("installcmd", install_cmd); + Checks::exit_with_code(VCPKG_LINE_INFO, rc.exit_code); + } + + const fs::path actual_downloaded_path = Strings::trimmed(rc.output); + Checks::check_exit(VCPKG_LINE_INFO, expected_downloaded_path == actual_downloaded_path, "Expected dependency downloaded path to be %s, but was %s", + expected_downloaded_path.generic_string(), actual_downloaded_path.generic_string()); + return actual_downloaded_path; + } + + static fs::path get_cmake_path(const fs::path& downloads_folder, const fs::path scripts_folder) + { + static constexpr std::array expected_version = { 3,8,0 }; + static const std::wstring version_check_arguments = L"--version"; + + const fs::path downloaded_copy = downloads_folder / "cmake-3.8.0-rc1-win32-x86" / "bin" / "cmake.exe"; + const std::vector from_path = find_from_PATH(L"cmake"); + + std::vector candidate_paths; + candidate_paths.push_back(downloaded_copy); + candidate_paths.insert(candidate_paths.end(), from_path.cbegin(), from_path.cend()); + candidate_paths.push_back(System::get_ProgramFiles_platform_bitness() / "CMake" / "bin" / "cmake.exe"); + candidate_paths.push_back(System::get_ProgramFiles_32_bit() / "CMake" / "bin"); + + const Optional path = find_if_has_equal_or_greater_version(candidate_paths, version_check_arguments, expected_version); + if (auto p = path.get()) + { + return *p; + } + + return fetch_dependency(scripts_folder, L"cmake", downloaded_copy); + } + + fs::path get_nuget_path(const fs::path& downloads_folder, const fs::path scripts_folder) + { + static constexpr std::array expected_version = { 3,3,0 }; + static const std::wstring version_check_arguments = L""; + + const fs::path downloaded_copy = downloads_folder / "nuget-3.5.0" / "nuget.exe"; + const std::vector from_path = find_from_PATH(L"nuget"); + + std::vector candidate_paths; + candidate_paths.push_back(downloaded_copy); + candidate_paths.insert(candidate_paths.end(), from_path.cbegin(), from_path.cend()); + + auto path = find_if_has_equal_or_greater_version(candidate_paths, version_check_arguments, expected_version); + if (auto p = path.get()) + { + return *p; + } + + return fetch_dependency(scripts_folder, L"nuget", downloaded_copy); + } + + fs::path get_git_path(const fs::path& downloads_folder, const fs::path scripts_folder) + { + static constexpr std::array expected_version = { 2,0,0 }; + static const std::wstring version_check_arguments = L"--version"; + + const fs::path downloaded_copy = downloads_folder / "MinGit-2.11.1-32-bit" / "cmd" / "git.exe"; + const std::vector from_path = find_from_PATH(L"git"); + + std::vector candidate_paths; + candidate_paths.push_back(downloaded_copy); + candidate_paths.insert(candidate_paths.end(), from_path.cbegin(), from_path.cend()); + candidate_paths.push_back(System::get_ProgramFiles_platform_bitness() / "git" / "cmd" / "git.exe"); + candidate_paths.push_back(System::get_ProgramFiles_32_bit() / "git" / "cmd" / "git.exe"); + + const Optional path = find_if_has_equal_or_greater_version(candidate_paths, version_check_arguments, expected_version); + if (auto p = path.get()) + { + return *p; + } + + return fetch_dependency(scripts_folder, L"git", downloaded_copy); + } + + Expected VcpkgPaths::create(const fs::path& vcpkg_root_dir) + { + std::error_code ec; + const fs::path canonical_vcpkg_root_dir = fs::canonical(vcpkg_root_dir, ec); + if (ec) + { + return ec; + } + + VcpkgPaths paths; + paths.root = canonical_vcpkg_root_dir; + + if (paths.root.empty()) + { + Metrics::track_property("error", "Invalid vcpkg root directory"); + Checks::exit_with_message(VCPKG_LINE_INFO, "Invalid vcpkg root directory: %s", paths.root.string()); + } + + paths.packages = paths.root / "packages"; + paths.buildtrees = paths.root / "buildtrees"; + paths.downloads = paths.root / "downloads"; + paths.ports = paths.root / "ports"; + paths.installed = paths.root / "installed"; + paths.triplets = paths.root / "triplets"; + paths.scripts = paths.root / "scripts"; + + paths.buildsystems = paths.scripts / "buildsystems"; + paths.buildsystems_msbuild_targets = paths.buildsystems / "msbuild" / "vcpkg.targets"; + + paths.vcpkg_dir = paths.installed / "vcpkg"; + paths.vcpkg_dir_status_file = paths.vcpkg_dir / "status"; + paths.vcpkg_dir_info = paths.vcpkg_dir / "info"; + paths.vcpkg_dir_updates = paths.vcpkg_dir / "updates"; + + paths.ports_cmake = paths.scripts / "ports.cmake"; + + return paths; + } + + fs::path VcpkgPaths::package_dir(const PackageSpec& spec) const + { + return this->packages / spec.dir(); + } + + fs::path VcpkgPaths::port_dir(const PackageSpec& spec) const + { + return this->ports / spec.name(); + } + + fs::path VcpkgPaths::build_info_file_path(const PackageSpec& spec) const + { + return this->package_dir(spec) / "BUILD_INFO"; + } + + fs::path VcpkgPaths::listfile_path(const BinaryParagraph& pgh) const + { + return this->vcpkg_dir_info / (pgh.fullstem() + ".list"); + } + + bool VcpkgPaths::is_valid_triplet(const Triplet& t) const + { + auto it = fs::directory_iterator(this->triplets); + for (; it != fs::directory_iterator(); ++it) + { + std::string triplet_file_name = it->path().stem().generic_u8string(); + if (t.canonical_name() == triplet_file_name) // TODO: fuzzy compare + { + //t.value = triplet_file_name; // NOTE: uncomment when implementing fuzzy compare + return true; + } + } + return false; + } + + const fs::path& VcpkgPaths::get_cmake_exe() const + { + return this->cmake_exe.get_lazy([this]() { return get_cmake_path(this->downloads, this->scripts); }); + } + + const fs::path& VcpkgPaths::get_git_exe() const + { + return this->git_exe.get_lazy([this]() { return get_git_path(this->downloads, this->scripts); }); + } + + const fs::path& VcpkgPaths::get_nuget_exe() const + { + return this->nuget_exe.get_lazy([this]() { return get_nuget_path(this->downloads, this->scripts); }); + } + + static std::vector get_VS2017_installation_instances(const VcpkgPaths& paths) + { + const fs::path script = paths.scripts / "findVisualStudioInstallationInstances.ps1"; + const std::wstring cmd = System::create_powershell_script_cmd(script); + System::exit_code_and_output ec_data = System::cmd_execute_and_capture_output(cmd); + Checks::check_exit(VCPKG_LINE_INFO, ec_data.exit_code == 0, "Could not run script to detect VS 2017 instances"); + return Strings::split(ec_data.output, "\n"); + } + + static Optional get_VS2015_installation_instance() + { + const Optional vs2015_cmntools_optional = System::get_environmental_variable(L"VS140COMNTOOLS"); + if (auto v = vs2015_cmntools_optional.get()) + { + const fs::path vs2015_cmntools = fs::path(*v).parent_path(); // The call to parent_path() is needed because the env variable has a trailing backslash + return vs2015_cmntools.parent_path().parent_path(); + } + + return nullopt; + } + + static Toolset find_toolset_instance(const VcpkgPaths& paths) + { + const std::vector vs2017_installation_instances = get_VS2017_installation_instances(paths); + // Note: this will contain a mix of vcvarsall.bat locations and dumpbin.exe locations. + std::vector paths_examined; + + // VS2017 + for (const fs::path& instance : vs2017_installation_instances) + { + const fs::path vc_dir = instance / "VC"; + + // Skip any instances that do not have vcvarsall. + const fs::path vcvarsall_bat = vc_dir / "Auxiliary" / "Build" / "vcvarsall.bat"; + paths_examined.push_back(vcvarsall_bat); + if (!fs::exists(vcvarsall_bat)) + continue; + + // Locate the "best" MSVC toolchain version + const fs::path msvc_path = vc_dir / "Tools" / "MSVC"; + std::vector msvc_subdirectories; + Files::non_recursive_find_matching_paths_in_dir(msvc_path, [](const fs::path& current) + { + return fs::is_directory(current); + }, &msvc_subdirectories); + + // Sort them so that latest comes first + std::sort(msvc_subdirectories.begin(), msvc_subdirectories.end(), [](const fs::path& left, const fs::path& right) + { + return left.filename() > right.filename(); + }); + + for (const fs::path& subdir : msvc_subdirectories) + { + const fs::path dumpbin_path = subdir / "bin" / "HostX86" / "x86" / "dumpbin.exe"; + paths_examined.push_back(dumpbin_path); + if (fs::exists(dumpbin_path)) + { + return { dumpbin_path, vcvarsall_bat , L"v141" }; + } + } + } + + // VS2015 + const Optional vs_2015_installation_instance = get_VS2015_installation_instance(); + if (auto v = vs_2015_installation_instance.get()) + { + const fs::path vs2015_vcvarsall_bat = *v / "VC" / "vcvarsall.bat"; + + paths_examined.push_back(vs2015_vcvarsall_bat); + if (fs::exists(vs2015_vcvarsall_bat)) + { + const fs::path vs2015_dumpbin_exe = *v / "VC" / "bin" / "dumpbin.exe"; + paths_examined.push_back(vs2015_dumpbin_exe); + if (fs::exists(vs2015_dumpbin_exe)) + { + return { vs2015_dumpbin_exe, vs2015_vcvarsall_bat, L"v140" }; + } + } + } + + System::println(System::color::error, "Could not locate a complete toolset."); + System::println("The following paths were examined:"); + for (const fs::path& path : paths_examined) + { + System::println(" %s", path.u8string()); + } + Checks::exit_fail(VCPKG_LINE_INFO); + } + + const Toolset& VcpkgPaths::get_toolset() const + { + return this->toolset.get_lazy([this]() { return find_toolset_instance(*this); }); + } +} diff --git a/toolsrc/src/commands_build.cpp b/toolsrc/src/commands_build.cpp index b6de8e4ea..6df081442 100644 --- a/toolsrc/src/commands_build.cpp +++ b/toolsrc/src/commands_build.cpp @@ -18,7 +18,7 @@ namespace vcpkg::Commands::Build static const std::string OPTION_CHECKS_ONLY = "--checks-only"; - static void create_binary_control_file(const vcpkg_paths& paths, const SourceParagraph& source_paragraph, const Triplet& target_triplet) + static void create_binary_control_file(const VcpkgPaths& paths, const SourceParagraph& source_paragraph, const Triplet& target_triplet) { const BinaryParagraph bpgh = BinaryParagraph(source_paragraph, target_triplet); const fs::path binary_control_file = paths.packages / bpgh.dir() / "CONTROL"; @@ -32,7 +32,7 @@ namespace vcpkg::Commands::Build Strings::utf8_to_utf16(target_triplet.architecture())); } - BuildResult build_package(const SourceParagraph& source_paragraph, const PackageSpec& spec, const vcpkg_paths& paths, const fs::path& port_dir, const StatusParagraphs& status_db) + BuildResult build_package(const SourceParagraph& source_paragraph, const PackageSpec& spec, const VcpkgPaths& paths, const fs::path& port_dir, const StatusParagraphs& status_db) { Checks::check_exit(VCPKG_LINE_INFO, spec.name() == source_paragraph.name, "inconsistent arguments to build_package()"); @@ -127,7 +127,7 @@ namespace vcpkg::Commands::Build , spec.toString(), Version::version()); } - void perform_and_exit(const PackageSpec& spec, const fs::path& port_dir, const std::unordered_set& options, const vcpkg_paths& paths) + void perform_and_exit(const PackageSpec& spec, const fs::path& port_dir, const std::unordered_set& options, const VcpkgPaths& paths) { if (options.find(OPTION_CHECKS_ONLY) != options.end()) { @@ -174,7 +174,7 @@ namespace vcpkg::Commands::Build Checks::exit_success(VCPKG_LINE_INFO); } - void perform_and_exit(const VcpkgCmdArguments& args, const vcpkg_paths& paths, const Triplet& default_target_triplet) + void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_target_triplet) { static const std::string example = Commands::Help::create_example_string("build zlib:x64-windows"); args.check_exact_arg_count(1, example); // Build only takes a single package and all dependencies must already be installed diff --git a/toolsrc/src/commands_build_external.cpp b/toolsrc/src/commands_build_external.cpp index 19504d7a8..7b5a01025 100644 --- a/toolsrc/src/commands_build_external.cpp +++ b/toolsrc/src/commands_build_external.cpp @@ -5,7 +5,7 @@ namespace vcpkg::Commands::BuildExternal { - void perform_and_exit(const VcpkgCmdArguments& args, const vcpkg_paths& paths, const Triplet& default_target_triplet) + void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_target_triplet) { static const std::string example = Commands::Help::create_example_string(R"(build_external zlib2 C:\path\to\dir\with\controlfile\)"); args.check_exact_arg_count(2, example); diff --git a/toolsrc/src/commands_cache.cpp b/toolsrc/src/commands_cache.cpp index def93b231..eae1d8fe3 100644 --- a/toolsrc/src/commands_cache.cpp +++ b/toolsrc/src/commands_cache.cpp @@ -7,7 +7,7 @@ namespace vcpkg::Commands::Cache { - static std::vector read_all_binary_paragraphs(const vcpkg_paths& paths) + static std::vector read_all_binary_paragraphs(const VcpkgPaths& paths) { std::vector output; for (auto it = fs::directory_iterator(paths.packages); it != fs::directory_iterator(); ++it) @@ -24,7 +24,7 @@ namespace vcpkg::Commands::Cache return output; } - void perform_and_exit(const VcpkgCmdArguments& args, const vcpkg_paths& paths) + void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths) { static const std::string example = Strings::format( "The argument should be a substring to search for, or no argument to display all cached libraries.\n%s", Commands::Help::create_example_string("cache png")); diff --git a/toolsrc/src/commands_ci.cpp b/toolsrc/src/commands_ci.cpp index e811779ee..472964f91 100644 --- a/toolsrc/src/commands_ci.cpp +++ b/toolsrc/src/commands_ci.cpp @@ -26,7 +26,7 @@ namespace vcpkg::Commands::CI return specs; } - void perform_and_exit(const VcpkgCmdArguments& args, const vcpkg_paths& paths, const Triplet& default_target_triplet) + void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_target_triplet) { static const std::string example = Commands::Help::create_example_string("ci x64-windows"); args.check_max_arg_count(1, example); diff --git a/toolsrc/src/commands_create.cpp b/toolsrc/src/commands_create.cpp index 2e2b163b1..31278f441 100644 --- a/toolsrc/src/commands_create.cpp +++ b/toolsrc/src/commands_create.cpp @@ -7,7 +7,7 @@ namespace vcpkg::Commands::Create { - void perform_and_exit(const VcpkgCmdArguments& args, const vcpkg_paths& paths) + void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths) { static const std::string example = Commands::Help::create_example_string(R"###(create zlib2 http://zlib.net/zlib1211.zip "zlib1211-2.zip")###"); args.check_max_arg_count(3, example); diff --git a/toolsrc/src/commands_edit.cpp b/toolsrc/src/commands_edit.cpp index e118f41b6..8549f5073 100644 --- a/toolsrc/src/commands_edit.cpp +++ b/toolsrc/src/commands_edit.cpp @@ -5,7 +5,7 @@ namespace vcpkg::Commands::Edit { - void perform_and_exit(const VcpkgCmdArguments& args, const vcpkg_paths& paths) + void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths) { static const std::string example = Commands::Help::create_example_string("edit zlib"); args.check_exact_arg_count(1, example); diff --git a/toolsrc/src/commands_env.cpp b/toolsrc/src/commands_env.cpp index e89aed41d..dd4c3af06 100644 --- a/toolsrc/src/commands_env.cpp +++ b/toolsrc/src/commands_env.cpp @@ -4,7 +4,7 @@ namespace vcpkg::Commands::Env { - void perform_and_exit(const VcpkgCmdArguments& args, const vcpkg_paths& paths, const Triplet& default_triplet) + void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_triplet) { static const std::string example = Commands::Help::create_example_string(R"(env --Triplet x64-windows)"); args.check_exact_arg_count(0, example); diff --git a/toolsrc/src/commands_help.cpp b/toolsrc/src/commands_help.cpp index 843b2c0a7..41cfa1363 100644 --- a/toolsrc/src/commands_help.cpp +++ b/toolsrc/src/commands_help.cpp @@ -4,7 +4,7 @@ namespace vcpkg::Commands::Help { - void help_topic_valid_triplet(const vcpkg_paths& paths) + void help_topic_valid_triplet(const VcpkgPaths& paths) { System::println("Available architecture triplets:"); auto it = fs::directory_iterator(paths.triplets); @@ -64,7 +64,7 @@ namespace vcpkg::Commands::Help System::println(create_example_string(command_and_arguments)); } - void perform_and_exit(const VcpkgCmdArguments& args, const vcpkg_paths& paths) + void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths) { args.check_max_arg_count(1); args.check_and_get_optional_command_arguments({}); diff --git a/toolsrc/src/commands_import.cpp b/toolsrc/src/commands_import.cpp index f0825749b..eb140604a 100644 --- a/toolsrc/src/commands_import.cpp +++ b/toolsrc/src/commands_import.cpp @@ -58,7 +58,7 @@ namespace vcpkg::Commands::Import copy_files_into_directory(debug_binaries.libs, destination_path / "debug" / "lib"); } - static void do_import(const vcpkg_paths& paths, const fs::path& include_directory, const fs::path& project_directory, const BinaryParagraph& control_file_data) + static void do_import(const VcpkgPaths& paths, const fs::path& include_directory, const fs::path& project_directory, const BinaryParagraph& control_file_data) { fs::path library_destination_path = paths.package_dir(control_file_data.spec); fs::create_directory(library_destination_path); @@ -68,7 +68,7 @@ namespace vcpkg::Commands::Import std::ofstream(control_file_path) << control_file_data; } - void perform_and_exit(const VcpkgCmdArguments& args, const vcpkg_paths& paths) + void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths) { static const std::string example = Commands::Help::create_example_string(R"(import C:\path\to\CONTROLfile C:\path\to\includedir C:\path\to\projectdir)"); args.check_exact_arg_count(3, example); diff --git a/toolsrc/src/commands_install.cpp b/toolsrc/src/commands_install.cpp index 33cc2b677..b59b13fe0 100644 --- a/toolsrc/src/commands_install.cpp +++ b/toolsrc/src/commands_install.cpp @@ -14,7 +14,7 @@ namespace vcpkg::Commands::Install using Dependencies::PackageSpecWithInstallPlan; using Dependencies::InstallPlanType; - static void install_and_write_listfile(const vcpkg_paths& paths, const BinaryParagraph& bpgh) + static void install_and_write_listfile(const VcpkgPaths& paths, const BinaryParagraph& bpgh) { std::vector output; @@ -136,7 +136,7 @@ namespace vcpkg::Commands::Install return SortedVector(std::move(installed_files)); } - void install_package(const vcpkg_paths& paths, const BinaryParagraph& binary_paragraph, StatusParagraphs* status_db) + void install_package(const VcpkgPaths& 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(); @@ -183,7 +183,7 @@ namespace vcpkg::Commands::Install status_db->insert(std::make_unique(spgh)); } - void perform_and_exit(const VcpkgCmdArguments& args, const vcpkg_paths& paths, const Triplet& default_target_triplet) + void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_target_triplet) { // input sanitization static const std::string example = Commands::Help::create_example_string("install zlib zlib:x64-windows curl boost"); diff --git a/toolsrc/src/commands_integrate.cpp b/toolsrc/src/commands_integrate.cpp index db41839c5..5ccd1979a 100644 --- a/toolsrc/src/commands_integrate.cpp +++ b/toolsrc/src/commands_integrate.cpp @@ -139,7 +139,7 @@ namespace vcpkg::Commands::Integrate return local_app_data / "vcpkg" / "vcpkg.user.targets"; } - static void integrate_install(const vcpkg_paths& paths) + static void integrate_install(const VcpkgPaths& paths) { // TODO: This block of code should eventually be removed for (auto&& old_system_wide_targets_file : old_system_target_files) @@ -243,7 +243,7 @@ namespace vcpkg::Commands::Integrate Checks::exit_success(VCPKG_LINE_INFO); } - static void integrate_project(const vcpkg_paths& paths) + static void integrate_project(const VcpkgPaths& paths) { const fs::path& nuget_exe = paths.get_nuget_exe(); @@ -284,7 +284,7 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console " vcpkg integrate remove Remove user-wide integration\n" " vcpkg integrate project Generate a referencing nuget package for individual VS project use\n"; - void perform_and_exit(const VcpkgCmdArguments& args, const vcpkg_paths& paths) + void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths) { static const std::string example = Strings::format("Commands:\n" "%s", INTEGRATE_COMMAND_HELPSTRING); diff --git a/toolsrc/src/commands_list.cpp b/toolsrc/src/commands_list.cpp index a68dec0d3..199ee5c16 100644 --- a/toolsrc/src/commands_list.cpp +++ b/toolsrc/src/commands_list.cpp @@ -14,7 +14,7 @@ namespace vcpkg::Commands::List details::shorten_description(pgh.package.description)); } - void perform_and_exit(const VcpkgCmdArguments& args, const vcpkg_paths& paths) + void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths) { static const std::string example = Strings::format( "The argument should be a substring to search for, or no argument to display all installed libraries.\n%s", Commands::Help::create_example_string("list png")); diff --git a/toolsrc/src/commands_owns.cpp b/toolsrc/src/commands_owns.cpp index 23e6d2b5c..7e974addb 100644 --- a/toolsrc/src/commands_owns.cpp +++ b/toolsrc/src/commands_owns.cpp @@ -5,7 +5,7 @@ namespace vcpkg::Commands::Owns { - static void search_file(const vcpkg_paths& paths, const std::string& file_substr, const StatusParagraphs& status_db) + static void search_file(const VcpkgPaths& paths, const std::string& file_substr, const StatusParagraphs& status_db) { const std::vector installed_files = get_installed_files(paths, status_db); for (const StatusParagraph_and_associated_files& pgh_and_file : installed_files) @@ -22,7 +22,7 @@ namespace vcpkg::Commands::Owns } } - void perform_and_exit(const VcpkgCmdArguments& args, const vcpkg_paths& paths) + void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths) { static const std::string example = Strings::format("The argument should be a pattern to search for. %s", Commands::Help::create_example_string("owns zlib.dll")); args.check_exact_arg_count(1, example); diff --git a/toolsrc/src/commands_portsdiff.cpp b/toolsrc/src/commands_portsdiff.cpp index 07ce774ec..249d48616 100644 --- a/toolsrc/src/commands_portsdiff.cpp +++ b/toolsrc/src/commands_portsdiff.cpp @@ -67,7 +67,7 @@ namespace vcpkg::Commands::PortsDiff } } - static std::map read_ports_from_commit(const vcpkg_paths& paths, const std::wstring& git_commit_id) + static std::map read_ports_from_commit(const VcpkgPaths& paths, const std::wstring& git_commit_id) { const fs::path& git_exe = paths.get_git_exe(); const fs::path dot_git_dir = paths.root / ".git"; @@ -100,7 +100,7 @@ namespace vcpkg::Commands::PortsDiff Checks::check_exit(VCPKG_LINE_INFO, output.output == VALID_COMMIT_OUTPUT, "Invalid commit id %s", Strings::utf16_to_utf8(git_commit_id)); } - void perform_and_exit(const VcpkgCmdArguments& args, const vcpkg_paths& paths) + void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths) { static const std::string example = Strings::format("The argument should be a branch/tag/hash to checkout.\n%s", Commands::Help::create_example_string("portsdiff mybranchname")); args.check_min_arg_count(1, example); diff --git a/toolsrc/src/commands_remove.cpp b/toolsrc/src/commands_remove.cpp index 5feaaf647..7542247a1 100644 --- a/toolsrc/src/commands_remove.cpp +++ b/toolsrc/src/commands_remove.cpp @@ -27,7 +27,7 @@ namespace vcpkg::Commands::Remove } } - static void remove_package(const vcpkg_paths& paths, const PackageSpec& spec, StatusParagraphs* status_db) + static void remove_package(const VcpkgPaths& paths, const PackageSpec& spec, StatusParagraphs* status_db) { StatusParagraph& pkg = **status_db->find(spec.name(), spec.target_triplet()); @@ -162,7 +162,7 @@ namespace vcpkg::Commands::Remove } } - void perform_and_exit(const VcpkgCmdArguments& args, const vcpkg_paths& paths, const Triplet& default_target_triplet) + void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths, const Triplet& default_target_triplet) { static const std::string OPTION_PURGE = "--purge"; static const std::string OPTION_NO_PURGE = "--no-purge"; diff --git a/toolsrc/src/commands_search.cpp b/toolsrc/src/commands_search.cpp index 1941b074d..478f53a76 100644 --- a/toolsrc/src/commands_search.cpp +++ b/toolsrc/src/commands_search.cpp @@ -52,7 +52,7 @@ namespace vcpkg::Commands::Search details::shorten_description(source_paragraph.description)); } - void perform_and_exit(const VcpkgCmdArguments& args, const vcpkg_paths& paths) + void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths) { static const std::string example = Strings::format("The argument should be a substring to search for, or no argument to display all libraries.\n%s", Commands::Help::create_example_string("search png")); diff --git a/toolsrc/src/commands_update.cpp b/toolsrc/src/commands_update.cpp index 4935be3b3..24dad34fe 100644 --- a/toolsrc/src/commands_update.cpp +++ b/toolsrc/src/commands_update.cpp @@ -12,7 +12,7 @@ namespace vcpkg::Commands::Update return left.spec.name() < right.spec.name(); } - std::vector find_outdated_packages(const vcpkg_paths& paths, const StatusParagraphs& status_db) + std::vector find_outdated_packages(const VcpkgPaths& paths, const StatusParagraphs& status_db) { const std::vector source_paragraphs = Paragraphs::load_all_ports(paths.ports); const std::map src_names_to_versions = Paragraphs::extract_port_names_and_versions(source_paragraphs); @@ -36,7 +36,7 @@ namespace vcpkg::Commands::Update return output; } - void perform_and_exit(const VcpkgCmdArguments& args, const vcpkg_paths& paths) + void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths) { args.check_exact_arg_count(0); args.check_and_get_optional_command_arguments({}); diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp index 522d78af2..d6d3f6d9d 100644 --- a/toolsrc/src/vcpkg.cpp +++ b/toolsrc/src/vcpkg.cpp @@ -58,9 +58,9 @@ static void inner(const VcpkgCmdArguments& args) Checks::check_exit(VCPKG_LINE_INFO, !vcpkg_root_dir.empty(), "Error: Could not detect vcpkg-root."); - const Expected expected_paths = vcpkg_paths::create(vcpkg_root_dir); + const Expected expected_paths = VcpkgPaths::create(vcpkg_root_dir); Checks::check_exit(VCPKG_LINE_INFO, !expected_paths.error_code(), "Error: Invalid vcpkg root directory %s: %s", vcpkg_root_dir.string(), expected_paths.error_code().message()); - const vcpkg_paths paths = expected_paths.value_or_exit(VCPKG_LINE_INFO); + const VcpkgPaths paths = expected_paths.value_or_exit(VCPKG_LINE_INFO); int exit_code = _wchdir(paths.root.c_str()); Checks::check_exit(VCPKG_LINE_INFO, exit_code == 0, "Changing the working dir failed"); diff --git a/toolsrc/src/vcpkg_Dependencies.cpp b/toolsrc/src/vcpkg_Dependencies.cpp index 52c55b6a8..d753a5cd4 100644 --- a/toolsrc/src/vcpkg_Dependencies.cpp +++ b/toolsrc/src/vcpkg_Dependencies.cpp @@ -1,7 +1,7 @@ #include "pch.h" #include "vcpkg_Dependencies.h" #include "vcpkg_Graphs.h" -#include "vcpkg_paths.h" +#include "VcpkgPaths.h" #include "PackageSpec.h" #include "StatusParagraphs.h" #include "vcpkg_Files.h" @@ -35,7 +35,7 @@ namespace vcpkg::Dependencies { } - std::vector create_install_plan(const vcpkg_paths& paths, const std::vector& specs, const StatusParagraphs& status_db) + std::vector create_install_plan(const VcpkgPaths& paths, const std::vector& specs, const StatusParagraphs& status_db) { std::unordered_map was_examined; // Examine = we have checked its immediate (non-recursive) dependencies Graphs::Graph graph; diff --git a/toolsrc/src/vcpkg_Input.cpp b/toolsrc/src/vcpkg_Input.cpp index 38d7890a0..58d09648f 100644 --- a/toolsrc/src/vcpkg_Input.cpp +++ b/toolsrc/src/vcpkg_Input.cpp @@ -21,7 +21,7 @@ namespace vcpkg::Input Checks::exit_fail(VCPKG_LINE_INFO); } - void check_triplet(const Triplet& t, const vcpkg_paths& paths) + void check_triplet(const Triplet& t, const VcpkgPaths& paths) { if (!paths.is_valid_triplet(t)) { diff --git a/toolsrc/src/vcpkg_paths.cpp b/toolsrc/src/vcpkg_paths.cpp deleted file mode 100644 index ece12562e..000000000 --- a/toolsrc/src/vcpkg_paths.cpp +++ /dev/null @@ -1,338 +0,0 @@ -#include "pch.h" -#include "vcpkg_expected.h" -#include "vcpkg_paths.h" -#include "metrics.h" -#include "vcpkg_System.h" -#include "PackageSpec.h" -#include "vcpkg_Files.h" -#include "vcpkg_Util.h" - -namespace vcpkg -{ - static bool exists_and_has_equal_or_greater_version(const std::wstring& version_cmd, const std::array& expected_version) - { - static const std::regex re(R"###((\d+)\.(\d+)\.(\d+))###"); - - auto rc = System::cmd_execute_and_capture_output(Strings::wformat(LR"(%s)", version_cmd)); - if (rc.exit_code != 0) - { - return false; - } - - std::match_results match; - auto found = std::regex_search(rc.output, match, re); - if (!found) - { - return false; - } - - int d1 = atoi(match[1].str().c_str()); - int d2 = atoi(match[2].str().c_str()); - int d3 = atoi(match[3].str().c_str()); - if (d1 > expected_version[0] || (d1 == expected_version[0] && d2 > expected_version[1]) || (d1 == expected_version[0] && d2 == expected_version[1] && d3 >= expected_version[2])) - { - // satisfactory version found - return true; - } - - return false; - } - - static Optional find_if_has_equal_or_greater_version(const std::vector& candidate_paths, const std::wstring& version_check_arguments, const std::array& expected_version) - { - auto it = std::find_if(candidate_paths.cbegin(), candidate_paths.cend(), [&](const fs::path& p) - { - const std::wstring cmd = Strings::wformat(LR"("%s" %s)", p.native(), version_check_arguments); - return exists_and_has_equal_or_greater_version(cmd, expected_version); - }); - - if (it != candidate_paths.cend()) - { - return std::move(*it); - } - - return nullopt; - } - - static std::vector find_from_PATH(const std::wstring& name) - { - const std::wstring cmd = Strings::wformat(L"where.exe %s", name); - auto out = System::cmd_execute_and_capture_output(cmd); - if (out.exit_code != 0) - { - return {}; - } - - return Util::fmap(Strings::split(out.output, "\n"), [](auto&& s) { return fs::path(s); }); - } - - static fs::path fetch_dependency(const fs::path scripts_folder, const std::wstring& tool_name, const fs::path& expected_downloaded_path) - { - const fs::path script = scripts_folder / "fetchDependency.ps1"; - auto install_cmd = System::create_powershell_script_cmd(script, Strings::wformat(L"-Dependency %s", tool_name)); - System::exit_code_and_output rc = System::cmd_execute_and_capture_output(install_cmd); - if (rc.exit_code) - { - System::println(System::color::error, "Launching powershell failed or was denied"); - Metrics::track_property("error", "powershell install failed"); - Metrics::track_property("installcmd", install_cmd); - Checks::exit_with_code(VCPKG_LINE_INFO, rc.exit_code); - } - - const fs::path actual_downloaded_path = Strings::trimmed(rc.output); - Checks::check_exit(VCPKG_LINE_INFO, expected_downloaded_path == actual_downloaded_path, "Expected dependency downloaded path to be %s, but was %s", - expected_downloaded_path.generic_string(), actual_downloaded_path.generic_string()); - return actual_downloaded_path; - } - - static fs::path get_cmake_path(const fs::path& downloads_folder, const fs::path scripts_folder) - { - static constexpr std::array expected_version = { 3,8,0 }; - static const std::wstring version_check_arguments = L"--version"; - - const fs::path downloaded_copy = downloads_folder / "cmake-3.8.0-rc1-win32-x86" / "bin" / "cmake.exe"; - const std::vector from_path = find_from_PATH(L"cmake"); - - std::vector candidate_paths; - candidate_paths.push_back(downloaded_copy); - candidate_paths.insert(candidate_paths.end(), from_path.cbegin(), from_path.cend()); - candidate_paths.push_back(System::get_ProgramFiles_platform_bitness() / "CMake" / "bin" / "cmake.exe"); - candidate_paths.push_back(System::get_ProgramFiles_32_bit() / "CMake" / "bin"); - - const Optional path = find_if_has_equal_or_greater_version(candidate_paths, version_check_arguments, expected_version); - if (auto p = path.get()) - { - return *p; - } - - return fetch_dependency(scripts_folder, L"cmake", downloaded_copy); - } - - fs::path get_nuget_path(const fs::path& downloads_folder, const fs::path scripts_folder) - { - static constexpr std::array expected_version = { 3,3,0 }; - static const std::wstring version_check_arguments = L""; - - const fs::path downloaded_copy = downloads_folder / "nuget-3.5.0" / "nuget.exe"; - const std::vector from_path = find_from_PATH(L"nuget"); - - std::vector candidate_paths; - candidate_paths.push_back(downloaded_copy); - candidate_paths.insert(candidate_paths.end(), from_path.cbegin(), from_path.cend()); - - auto path = find_if_has_equal_or_greater_version(candidate_paths, version_check_arguments, expected_version); - if (auto p = path.get()) - { - return *p; - } - - return fetch_dependency(scripts_folder, L"nuget", downloaded_copy); - } - - fs::path get_git_path(const fs::path& downloads_folder, const fs::path scripts_folder) - { - static constexpr std::array expected_version = { 2,0,0 }; - static const std::wstring version_check_arguments = L"--version"; - - const fs::path downloaded_copy = downloads_folder / "MinGit-2.11.1-32-bit" / "cmd" / "git.exe"; - const std::vector from_path = find_from_PATH(L"git"); - - std::vector candidate_paths; - candidate_paths.push_back(downloaded_copy); - candidate_paths.insert(candidate_paths.end(), from_path.cbegin(), from_path.cend()); - candidate_paths.push_back(System::get_ProgramFiles_platform_bitness() / "git" / "cmd" / "git.exe"); - candidate_paths.push_back(System::get_ProgramFiles_32_bit() / "git" / "cmd" / "git.exe"); - - const Optional path = find_if_has_equal_or_greater_version(candidate_paths, version_check_arguments, expected_version); - if (auto p = path.get()) - { - return *p; - } - - return fetch_dependency(scripts_folder, L"git", downloaded_copy); - } - - Expected vcpkg_paths::create(const fs::path& vcpkg_root_dir) - { - std::error_code ec; - const fs::path canonical_vcpkg_root_dir = fs::canonical(vcpkg_root_dir, ec); - if (ec) - { - return ec; - } - - vcpkg_paths paths; - paths.root = canonical_vcpkg_root_dir; - - if (paths.root.empty()) - { - Metrics::track_property("error", "Invalid vcpkg root directory"); - Checks::exit_with_message(VCPKG_LINE_INFO, "Invalid vcpkg root directory: %s", paths.root.string()); - } - - paths.packages = paths.root / "packages"; - paths.buildtrees = paths.root / "buildtrees"; - paths.downloads = paths.root / "downloads"; - paths.ports = paths.root / "ports"; - paths.installed = paths.root / "installed"; - paths.triplets = paths.root / "triplets"; - paths.scripts = paths.root / "scripts"; - - paths.buildsystems = paths.scripts / "buildsystems"; - paths.buildsystems_msbuild_targets = paths.buildsystems / "msbuild" / "vcpkg.targets"; - - paths.vcpkg_dir = paths.installed / "vcpkg"; - paths.vcpkg_dir_status_file = paths.vcpkg_dir / "status"; - paths.vcpkg_dir_info = paths.vcpkg_dir / "info"; - paths.vcpkg_dir_updates = paths.vcpkg_dir / "updates"; - - paths.ports_cmake = paths.scripts / "ports.cmake"; - - return paths; - } - - fs::path vcpkg_paths::package_dir(const PackageSpec& spec) const - { - return this->packages / spec.dir(); - } - - fs::path vcpkg_paths::port_dir(const PackageSpec& spec) const - { - return this->ports / spec.name(); - } - - fs::path vcpkg_paths::build_info_file_path(const PackageSpec& spec) const - { - return this->package_dir(spec) / "BUILD_INFO"; - } - - fs::path vcpkg_paths::listfile_path(const BinaryParagraph& pgh) const - { - return this->vcpkg_dir_info / (pgh.fullstem() + ".list"); - } - - bool vcpkg_paths::is_valid_triplet(const Triplet& t) const - { - auto it = fs::directory_iterator(this->triplets); - for (; it != fs::directory_iterator(); ++it) - { - std::string triplet_file_name = it->path().stem().generic_u8string(); - if (t.canonical_name() == triplet_file_name) // TODO: fuzzy compare - { - //t.value = triplet_file_name; // NOTE: uncomment when implementing fuzzy compare - return true; - } - } - return false; - } - - const fs::path& vcpkg_paths::get_cmake_exe() const - { - return this->cmake_exe.get_lazy([this]() { return get_cmake_path(this->downloads, this->scripts); }); - } - - const fs::path& vcpkg_paths::get_git_exe() const - { - return this->git_exe.get_lazy([this]() { return get_git_path(this->downloads, this->scripts); }); - } - - const fs::path& vcpkg_paths::get_nuget_exe() const - { - return this->nuget_exe.get_lazy([this]() { return get_nuget_path(this->downloads, this->scripts); }); - } - - static std::vector get_VS2017_installation_instances(const vcpkg_paths& paths) - { - const fs::path script = paths.scripts / "findVisualStudioInstallationInstances.ps1"; - const std::wstring cmd = System::create_powershell_script_cmd(script); - System::exit_code_and_output ec_data = System::cmd_execute_and_capture_output(cmd); - Checks::check_exit(VCPKG_LINE_INFO, ec_data.exit_code == 0, "Could not run script to detect VS 2017 instances"); - return Strings::split(ec_data.output, "\n"); - } - - static Optional get_VS2015_installation_instance() - { - const Optional vs2015_cmntools_optional = System::get_environmental_variable(L"VS140COMNTOOLS"); - if (auto v = vs2015_cmntools_optional.get()) - { - const fs::path vs2015_cmntools = fs::path(*v).parent_path(); // The call to parent_path() is needed because the env variable has a trailing backslash - return vs2015_cmntools.parent_path().parent_path(); - } - - return nullopt; - } - - static Toolset find_toolset_instance(const vcpkg_paths& paths) - { - const std::vector vs2017_installation_instances = get_VS2017_installation_instances(paths); - // Note: this will contain a mix of vcvarsall.bat locations and dumpbin.exe locations. - std::vector paths_examined; - - // VS2017 - for (const fs::path& instance : vs2017_installation_instances) - { - const fs::path vc_dir = instance / "VC"; - - // Skip any instances that do not have vcvarsall. - const fs::path vcvarsall_bat = vc_dir / "Auxiliary" / "Build" / "vcvarsall.bat"; - paths_examined.push_back(vcvarsall_bat); - if (!fs::exists(vcvarsall_bat)) - continue; - - // Locate the "best" MSVC toolchain version - const fs::path msvc_path = vc_dir / "Tools" / "MSVC"; - std::vector msvc_subdirectories; - Files::non_recursive_find_matching_paths_in_dir(msvc_path, [](const fs::path& current) - { - return fs::is_directory(current); - }, &msvc_subdirectories); - - // Sort them so that latest comes first - std::sort(msvc_subdirectories.begin(), msvc_subdirectories.end(), [](const fs::path& left, const fs::path& right) - { - return left.filename() > right.filename(); - }); - - for (const fs::path& subdir : msvc_subdirectories) - { - const fs::path dumpbin_path = subdir / "bin" / "HostX86" / "x86" / "dumpbin.exe"; - paths_examined.push_back(dumpbin_path); - if (fs::exists(dumpbin_path)) - { - return { dumpbin_path, vcvarsall_bat , L"v141" }; - } - } - } - - // VS2015 - const Optional vs_2015_installation_instance = get_VS2015_installation_instance(); - if (auto v = vs_2015_installation_instance.get()) - { - const fs::path vs2015_vcvarsall_bat = *v / "VC" / "vcvarsall.bat"; - - paths_examined.push_back(vs2015_vcvarsall_bat); - if (fs::exists(vs2015_vcvarsall_bat)) - { - const fs::path vs2015_dumpbin_exe = *v / "VC" / "bin" / "dumpbin.exe"; - paths_examined.push_back(vs2015_dumpbin_exe); - if (fs::exists(vs2015_dumpbin_exe)) - { - return { vs2015_dumpbin_exe, vs2015_vcvarsall_bat, L"v140" }; - } - } - } - - System::println(System::color::error, "Could not locate a complete toolset."); - System::println("The following paths were examined:"); - for (const fs::path& path : paths_examined) - { - System::println(" %s", path.u8string()); - } - Checks::exit_fail(VCPKG_LINE_INFO); - } - - const Toolset& vcpkg_paths::get_toolset() const - { - return this->toolset.get_lazy([this]() { return find_toolset_instance(*this); }); - } -} diff --git a/toolsrc/src/vcpkglib.cpp b/toolsrc/src/vcpkglib.cpp index b40942f65..ba18dcd31 100644 --- a/toolsrc/src/vcpkglib.cpp +++ b/toolsrc/src/vcpkglib.cpp @@ -33,7 +33,7 @@ namespace vcpkg return StatusParagraphs(std::move(status_pghs)); } - StatusParagraphs database_load_check(const vcpkg_paths& paths) + StatusParagraphs database_load_check(const VcpkgPaths& paths) { auto updates_dir = paths.vcpkg_dir_updates; @@ -91,7 +91,7 @@ namespace vcpkg return current_status_db; } - void write_update(const vcpkg_paths& paths, const StatusParagraph& p) + void write_update(const VcpkgPaths& paths, const StatusParagraph& p) { static int update_id = 0; auto my_update_id = update_id++; @@ -184,7 +184,7 @@ namespace vcpkg return installed_packages; } - std::vector get_installed_files(const vcpkg_paths& paths, const StatusParagraphs& status_db) + std::vector get_installed_files(const VcpkgPaths& paths, const StatusParagraphs& status_db) { std::vector installed_files; -- cgit v1.2.3