diff options
| author | Arsen Tufankjian <amt3824@g.rit.edu> | 2020-05-08 12:43:30 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-08 12:43:30 -0700 |
| commit | 644ba5d998fec302fc9936a27f3be95f085ba62d (patch) | |
| tree | 18f0bf6ec039fa247220f2caa305d91424b903e7 /toolsrc | |
| parent | 8de3f323dcf60790bf049284b9b7d7232a87984d (diff) | |
| download | vcpkg-644ba5d998fec302fc9936a27f3be95f085ba62d.tar.gz vcpkg-644ba5d998fec302fc9936a27f3be95f085ba62d.zip | |
[vcpkg] Adding support for finding VS2019 by environment variable (#10760)
* Fixing build with VS2019
* Added support for finding VS2019 by VS160COMNTOOLS env var
* [vcpkg] Explicitly handle trailing backslash in VS140 path.
* [vcpkg] Defer instance validation for VS160COMNTOOLS
Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
Diffstat (limited to 'toolsrc')
| -rw-r--r-- | toolsrc/src/vcpkg/visualstudio.cpp | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/toolsrc/src/vcpkg/visualstudio.cpp b/toolsrc/src/vcpkg/visualstudio.cpp index df3c70de2..44ce4be7d 100644 --- a/toolsrc/src/vcpkg/visualstudio.cpp +++ b/toolsrc/src/vcpkg/visualstudio.cpp @@ -119,7 +119,23 @@ namespace vcpkg::VisualStudio } } - const auto append_if_has_cl = [&](fs::path&& path_root) { + // VS2019 instance from environment variable + auto maybe_vs160_comntools = System::get_environment_variable("vs160comntools"); + if (const auto path_as_string = maybe_vs160_comntools.get()) + { + // We want lexically_normal(), but it is not available + // Correct root path might be 2 or 3 levels up, depending on if the path has trailing backslash. + auto common7_tools = fs::u8path(*path_as_string); + if (common7_tools.filename().empty()) + instances.emplace_back(common7_tools.parent_path().parent_path().parent_path(), + "16.0", + VisualStudioInstance::ReleaseType::LEGACY); + else + instances.emplace_back( + common7_tools.parent_path().parent_path(), "16.0", VisualStudioInstance::ReleaseType::LEGACY); + } + + const auto append_if_has_cl_vs140 = [&](fs::path&& path_root) { const auto cl_exe = path_root / "VC" / "bin" / "cl.exe"; const auto vcvarsall_bat = path_root / "VC" / "vcvarsall.bat"; @@ -132,14 +148,16 @@ namespace vcpkg::VisualStudio if (const auto path_as_string = maybe_vs140_comntools.get()) { // We want lexically_normal(), but it is not available - // Correct root path might be 2 or 3 levels up, depending on if the path has trailing backslash. Try both. - auto common7_tools = fs::path{*path_as_string}; - append_if_has_cl(fs::path{*path_as_string}.parent_path().parent_path()); - append_if_has_cl(fs::path{*path_as_string}.parent_path().parent_path().parent_path()); + // Correct root path might be 2 or 3 levels up, depending on if the path has trailing backslash. + auto common7_tools = fs::u8path(*path_as_string); + if (common7_tools.filename().empty()) + append_if_has_cl_vs140(common7_tools.parent_path().parent_path().parent_path()); + else + append_if_has_cl_vs140(common7_tools.parent_path().parent_path()); } // VS2015 instance from Program Files - append_if_has_cl(program_files_32_bit / "Microsoft Visual Studio 14.0"); + append_if_has_cl_vs140(program_files_32_bit / "Microsoft Visual Studio 14.0"); return instances; } |
