зеркало из https://github.com/microsoft/vcpkg.git
[vcpkg] Resolve relative overlay ports to the current working directory. (#11233)
Fixes #10771.
This commit is contained in:
Родитель
62d5125c5d
Коммит
8de3f323dc
|
@ -61,7 +61,8 @@ namespace vcpkg
|
|||
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);
|
||||
const std::vector<std::string>* triplets_dirs,
|
||||
fs::path original_cwd);
|
||||
|
||||
fs::path package_dir(const PackageSpec& spec) const;
|
||||
fs::path build_info_file_path(const PackageSpec& spec) const;
|
||||
|
@ -72,6 +73,7 @@ namespace vcpkg
|
|||
const std::vector<TripletFile>& get_available_triplets() const;
|
||||
const fs::path get_triplet_file_path(Triplet triplet) const;
|
||||
|
||||
fs::path original_cwd;
|
||||
fs::path root;
|
||||
fs::path packages;
|
||||
fs::path buildtrees;
|
||||
|
|
|
@ -119,22 +119,30 @@ 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) {
|
||||
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;
|
||||
Optional<fs::path> vcpkg_scripts_root_dir;
|
||||
if (args.scripts_root_dir)
|
||||
{
|
||||
vcpkg_scripts_root_dir = Files::get_real_filesystem().canonical(VCPKG_LINE_INFO, 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, install_root_dir, vcpkg_scripts_root_dir, default_vs_path, args.overlay_triplets.get());
|
||||
auto original_cwd = Files::get_real_filesystem().current_path(VCPKG_LINE_INFO);
|
||||
|
||||
const Expected<VcpkgPaths> expected_paths = VcpkgPaths::create(vcpkg_root_dir,
|
||||
install_root_dir,
|
||||
vcpkg_scripts_root_dir,
|
||||
default_vs_path,
|
||||
args.overlay_triplets.get(),
|
||||
original_cwd);
|
||||
Checks::check_exit(VCPKG_LINE_INFO,
|
||||
!expected_paths.error(),
|
||||
"Error: Invalid vcpkg root directory %s: %s",
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <pch.h>
|
||||
|
||||
#include <vcpkg/base/system.debug.h>
|
||||
#include <vcpkg/paragraphs.h>
|
||||
#include <vcpkg/portfileprovider.h>
|
||||
#include <vcpkg/sourceparagraph.h>
|
||||
|
@ -34,7 +35,9 @@ namespace vcpkg::PortFileProvider
|
|||
{
|
||||
if (!overlay_path.empty())
|
||||
{
|
||||
auto overlay = fs.canonical(VCPKG_LINE_INFO, fs::u8path(overlay_path));
|
||||
auto overlay = fs.canonical(VCPKG_LINE_INFO, paths.original_cwd / fs::u8path(overlay_path));
|
||||
|
||||
Debug::print("Using overlay: ", overlay.u8string(), "\n");
|
||||
|
||||
Checks::check_exit(VCPKG_LINE_INFO,
|
||||
filesystem.exists(overlay),
|
||||
|
|
|
@ -17,7 +17,8 @@ namespace vcpkg
|
|||
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)
|
||||
const std::vector<std::string>* triplets_dirs,
|
||||
fs::path original_cwd)
|
||||
{
|
||||
auto& fs = Files::get_real_filesystem();
|
||||
std::error_code ec;
|
||||
|
@ -30,6 +31,7 @@ namespace vcpkg
|
|||
VcpkgPaths paths;
|
||||
paths.root = canonical_vcpkg_root_dir;
|
||||
paths.default_vs_path = default_vs_path;
|
||||
paths.original_cwd = original_cwd;
|
||||
|
||||
if (paths.root.empty())
|
||||
{
|
||||
|
@ -66,9 +68,12 @@ namespace vcpkg
|
|||
}
|
||||
|
||||
paths.ports = paths.root / "ports";
|
||||
if (auto d = install_root_dir.get()) {
|
||||
paths.installed = fs.absolute(VCPKG_LINE_INFO, std::move(*d));
|
||||
} else {
|
||||
if (auto d = install_root_dir.get())
|
||||
{
|
||||
paths.installed = fs.absolute(VCPKG_LINE_INFO, *d);
|
||||
}
|
||||
else
|
||||
{
|
||||
paths.installed = paths.root / "installed";
|
||||
}
|
||||
paths.triplets = paths.root / "triplets";
|
||||
|
|
Загрузка…
Ссылка в новой задаче