aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2020-05-08 12:41:44 -0700
committerGitHub <noreply@github.com>2020-05-08 12:41:44 -0700
commit8de3f323dcf60790bf049284b9b7d7232a87984d (patch)
tree3ad60649f9311528d646a37a550ac6efafeddf17
parent62d5125c5d11053af60bbb1e461c50be3b080c9f (diff)
downloadvcpkg-8de3f323dcf60790bf049284b9b7d7232a87984d.tar.gz
vcpkg-8de3f323dcf60790bf049284b9b7d7232a87984d.zip
[vcpkg] Resolve relative overlay ports to the current working directory. (#11233)
Fixes #10771.
-rw-r--r--toolsrc/include/vcpkg/vcpkgpaths.h4
-rw-r--r--toolsrc/src/vcpkg.cpp18
-rw-r--r--toolsrc/src/vcpkg/portfileprovider.cpp5
-rw-r--r--toolsrc/src/vcpkg/vcpkgpaths.cpp13
4 files changed, 29 insertions, 11 deletions
diff --git a/toolsrc/include/vcpkg/vcpkgpaths.h b/toolsrc/include/vcpkg/vcpkgpaths.h
index c95515aee..2588abf4d 100644
--- a/toolsrc/include/vcpkg/vcpkgpaths.h
+++ b/toolsrc/include/vcpkg/vcpkgpaths.h
@@ -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;
diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp
index 4e6109c38..39f588915 100644
--- a/toolsrc/src/vcpkg.cpp
+++ b/toolsrc/src/vcpkg.cpp
@@ -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",
diff --git a/toolsrc/src/vcpkg/portfileprovider.cpp b/toolsrc/src/vcpkg/portfileprovider.cpp
index 0b0ef4aaf..975cd50a8 100644
--- a/toolsrc/src/vcpkg/portfileprovider.cpp
+++ b/toolsrc/src/vcpkg/portfileprovider.cpp
@@ -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),
diff --git a/toolsrc/src/vcpkg/vcpkgpaths.cpp b/toolsrc/src/vcpkg/vcpkgpaths.cpp
index 52dd06b7b..8590b1549 100644
--- a/toolsrc/src/vcpkg/vcpkgpaths.cpp
+++ b/toolsrc/src/vcpkg/vcpkgpaths.cpp
@@ -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";