diff options
| author | nicole mazzuca <mazzucan@outlook.com> | 2020-04-17 15:49:59 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-17 15:49:59 -0700 |
| commit | 556325a1f7b6049d91565257c00db2f0bf1eadc5 (patch) | |
| tree | 82485596a6285844862b431e6930c306b33cd484 /toolsrc/src/vcpkg.cpp | |
| parent | 71377f69e255414ccf3569a8a772fc89ee9f89ff (diff) | |
| download | vcpkg-556325a1f7b6049d91565257c00db2f0bf1eadc5.tar.gz vcpkg-556325a1f7b6049d91565257c00db2f0bf1eadc5.zip | |
[vcpkg] Add x-set-installed command (#10817)
This command takes a list of ports, and causes the final state of the
installed directory to be as-if one ran the install on an empty
installed directory (removing any unnecessary packages).
This is especially useful with the new `--x-install-root` option, which
allows one to set the `installed` directory for vcpkg to use.
Additionally, as a drive-by, we do some `stdfs` clean-up and add a
`.is_feature()` member function to BinaryParagraph (as opposed to
checking for `.feature().empty()`, which is far less clear to read).
This feature is experimental.
Diffstat (limited to 'toolsrc/src/vcpkg.cpp')
| -rw-r--r-- | toolsrc/src/vcpkg.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp index c2ee42200..4e6109c38 100644 --- a/toolsrc/src/vcpkg.cpp +++ b/toolsrc/src/vcpkg.cpp @@ -62,6 +62,8 @@ static void invalid_command(const std::string& cmd) static void inner(const VcpkgCmdArguments& args) { + auto& fs = Files::get_real_filesystem(); + Metrics::g_metrics.lock()->track_property("command", args.command); if (args.command.empty()) { @@ -88,26 +90,26 @@ static void inner(const VcpkgCmdArguments& args) } fs::path vcpkg_root_dir; - if (args.vcpkg_root_dir != nullptr) + if (args.vcpkg_root_dir) { - vcpkg_root_dir = fs::stdfs::absolute(fs::u8path(*args.vcpkg_root_dir)); + vcpkg_root_dir = fs.absolute(VCPKG_LINE_INFO, fs::u8path(*args.vcpkg_root_dir)); } else { const auto vcpkg_root_dir_env = System::get_environment_variable("VCPKG_ROOT"); if (const auto v = vcpkg_root_dir_env.get()) { - vcpkg_root_dir = fs::stdfs::absolute(*v); + vcpkg_root_dir = fs.absolute(VCPKG_LINE_INFO, *v); } else { - const fs::path current_path = fs::stdfs::current_path(); - vcpkg_root_dir = Files::get_real_filesystem().find_file_recursively_up(current_path, ".vcpkg-root"); + const fs::path current_path = fs.current_path(VCPKG_LINE_INFO); + vcpkg_root_dir = fs.find_file_recursively_up(current_path, ".vcpkg-root"); if (vcpkg_root_dir.empty()) { - vcpkg_root_dir = Files::get_real_filesystem().find_file_recursively_up( - fs::stdfs::absolute(System::get_exe_path_of_current_process()), ".vcpkg-root"); + vcpkg_root_dir = fs.find_file_recursively_up( + fs.absolute(VCPKG_LINE_INFO, System::get_exe_path_of_current_process()), ".vcpkg-root"); } } } @@ -116,17 +118,23 @@ static void inner(const VcpkgCmdArguments& args) Debug::print("Using vcpkg-root: ", vcpkg_root_dir.u8string(), '\n'); + Optional<fs::path> install_root_dir; + if (args.install_root_dir) { + install_root_dir = Files::get_real_filesystem().canonical(VCPKG_LINE_INFO, fs::u8path(*args.install_root_dir)); + Debug::print("Using install-root: ", install_root_dir.value_or_exit(VCPKG_LINE_INFO).u8string(), '\n'); + } + Optional<fs::path> vcpkg_scripts_root_dir = nullopt; - if (nullptr != args.scripts_root_dir) + if (args.scripts_root_dir) { - vcpkg_scripts_root_dir = fs::stdfs::canonical(fs::u8path(*args.scripts_root_dir)); + vcpkg_scripts_root_dir = Files::get_real_filesystem().canonical(VCPKG_LINE_INFO, fs::u8path(*args.scripts_root_dir)); Debug::print("Using scripts-root: ", vcpkg_scripts_root_dir.value_or_exit(VCPKG_LINE_INFO).u8string(), '\n'); } auto default_vs_path = System::get_environment_variable("VCPKG_VISUAL_STUDIO_PATH").value_or(""); const Expected<VcpkgPaths> expected_paths = - VcpkgPaths::create(vcpkg_root_dir, vcpkg_scripts_root_dir, default_vs_path, args.overlay_triplets.get()); + VcpkgPaths::create(vcpkg_root_dir, install_root_dir, vcpkg_scripts_root_dir, default_vs_path, args.overlay_triplets.get()); Checks::check_exit(VCPKG_LINE_INFO, !expected_paths.error(), "Error: Invalid vcpkg root directory %s: %s", |
