mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-06-07 18:32:47 +08:00
[vcpkg] Add VCPKG_DEFAULT_VS_PATH environment variable
This commit is contained in:
parent
b7daa881f5
commit
6670b87c18
@ -33,7 +33,7 @@ namespace vcpkg
|
|||||||
|
|
||||||
struct VcpkgPaths
|
struct VcpkgPaths
|
||||||
{
|
{
|
||||||
static Expected<VcpkgPaths> create(const fs::path& vcpkg_root_dir);
|
static Expected<VcpkgPaths> create(const fs::path& vcpkg_root_dir, const std::string& default_vs_path);
|
||||||
|
|
||||||
fs::path package_dir(const PackageSpec& spec) const;
|
fs::path package_dir(const PackageSpec& spec) const;
|
||||||
fs::path port_dir(const PackageSpec& spec) const;
|
fs::path port_dir(const PackageSpec& spec) const;
|
||||||
@ -90,5 +90,7 @@ namespace vcpkg
|
|||||||
Lazy<fs::path> ifw_repogen_exe;
|
Lazy<fs::path> ifw_repogen_exe;
|
||||||
Lazy<std::vector<Toolset>> toolsets;
|
Lazy<std::vector<Toolset>> toolsets;
|
||||||
Lazy<std::vector<Toolset>> toolsets_vs2013;
|
Lazy<std::vector<Toolset>> toolsets_vs2013;
|
||||||
|
|
||||||
|
fs::path default_vs_path;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,9 @@ static void inner(const VcpkgCmdArguments& args)
|
|||||||
|
|
||||||
Checks::check_exit(VCPKG_LINE_INFO, !vcpkg_root_dir.empty(), "Error: Could not detect vcpkg-root.");
|
Checks::check_exit(VCPKG_LINE_INFO, !vcpkg_root_dir.empty(), "Error: Could not detect vcpkg-root.");
|
||||||
|
|
||||||
const Expected<VcpkgPaths> expected_paths = VcpkgPaths::create(vcpkg_root_dir);
|
auto default_vs_path = System::get_environment_variable("VCPKG_DEFAULT_VS_PATH").value_or("");
|
||||||
|
|
||||||
|
const Expected<VcpkgPaths> expected_paths = VcpkgPaths::create(vcpkg_root_dir, default_vs_path);
|
||||||
Checks::check_exit(VCPKG_LINE_INFO,
|
Checks::check_exit(VCPKG_LINE_INFO,
|
||||||
!expected_paths.error(),
|
!expected_paths.error(),
|
||||||
"Error: Invalid vcpkg root directory %s: %s",
|
"Error: Invalid vcpkg root directory %s: %s",
|
||||||
|
@ -293,7 +293,7 @@ namespace vcpkg
|
|||||||
return fetch_tool(paths.scripts, "installerbase", TOOL_DATA);
|
return fetch_tool(paths.scripts, "installerbase", TOOL_DATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
Expected<VcpkgPaths> VcpkgPaths::create(const fs::path& vcpkg_root_dir)
|
Expected<VcpkgPaths> VcpkgPaths::create(const fs::path& vcpkg_root_dir, const std::string& default_vs_path)
|
||||||
{
|
{
|
||||||
std::error_code ec;
|
std::error_code ec;
|
||||||
const fs::path canonical_vcpkg_root_dir = fs::stdfs::canonical(vcpkg_root_dir, ec);
|
const fs::path canonical_vcpkg_root_dir = fs::stdfs::canonical(vcpkg_root_dir, ec);
|
||||||
@ -304,6 +304,7 @@ namespace vcpkg
|
|||||||
|
|
||||||
VcpkgPaths paths;
|
VcpkgPaths paths;
|
||||||
paths.root = canonical_vcpkg_root_dir;
|
paths.root = canonical_vcpkg_root_dir;
|
||||||
|
paths.default_vs_path = default_vs_path;
|
||||||
|
|
||||||
if (paths.root.empty())
|
if (paths.root.empty())
|
||||||
{
|
{
|
||||||
@ -643,7 +644,11 @@ namespace vcpkg
|
|||||||
|
|
||||||
std::vector<const Toolset*> candidates = Util::element_pointers(vs_toolsets);
|
std::vector<const Toolset*> candidates = Util::element_pointers(vs_toolsets);
|
||||||
const auto tsv = prebuildinfo.platform_toolset.get();
|
const auto tsv = prebuildinfo.platform_toolset.get();
|
||||||
const auto vsp = prebuildinfo.visual_studio_path.get();
|
auto vsp = prebuildinfo.visual_studio_path.get();
|
||||||
|
if (!vsp && !default_vs_path.empty())
|
||||||
|
{
|
||||||
|
vsp = &default_vs_path;
|
||||||
|
}
|
||||||
|
|
||||||
if (tsv && vsp)
|
if (tsv && vsp)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user