diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2017-09-27 17:22:40 -0700 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2017-09-27 17:22:40 -0700 |
| commit | eca068e4c5673b888d6470b42d6b5b44b21c4007 (patch) | |
| tree | ad874e6e221eec640d7ba3083a26461006fef08e /toolsrc/src/VcpkgPaths.cpp | |
| parent | f160164219ab0c8422fdcefde3a3def89e5a59de (diff) | |
| download | vcpkg-eca068e4c5673b888d6470b42d6b5b44b21c4007.tar.gz vcpkg-eca068e4c5673b888d6470b42d6b5b44b21c4007.zip | |
Extract function for duplicated code
Diffstat (limited to 'toolsrc/src/VcpkgPaths.cpp')
| -rw-r--r-- | toolsrc/src/VcpkgPaths.cpp | 51 |
1 files changed, 24 insertions, 27 deletions
diff --git a/toolsrc/src/VcpkgPaths.cpp b/toolsrc/src/VcpkgPaths.cpp index 02e238b3f..00f4691cd 100644 --- a/toolsrc/src/VcpkgPaths.cpp +++ b/toolsrc/src/VcpkgPaths.cpp @@ -269,10 +269,29 @@ namespace vcpkg return nullopt; } - static std::vector<Toolset> find_toolset_instances(const VcpkgPaths& paths) + static std::vector<ToolsetArchOption> detect_supported_architectures(const Files::Filesystem& fs, + const fs::path& vcvarsall_dir) { using CPU = System::CPUArchitecture; + std::vector<ToolsetArchOption> supported_architectures; + + if (fs.exists(vcvarsall_dir / "vcvars32.bat")) supported_architectures.push_back({L"x86", CPU::X86, CPU::X86}); + if (fs.exists(vcvarsall_dir / "vcvars64.bat")) + supported_architectures.push_back({L"amd64", CPU::X64, CPU::X64}); + if (fs.exists(vcvarsall_dir / "vcvarsx86_amd64.bat")) + supported_architectures.push_back({L"x86_amd64", CPU::X86, CPU::X64}); + if (fs.exists(vcvarsall_dir / "vcvarsx86_arm.bat")) + supported_architectures.push_back({L"x86_arm", CPU::X86, CPU::ARM}); + if (fs.exists(vcvarsall_dir / "vcvarsamd64_x86.bat")) + supported_architectures.push_back({L"amd64_x86", CPU::X64, CPU::X86}); + if (fs.exists(vcvarsall_dir / "vcvarsamd64_arm.bat")) + supported_architectures.push_back({L"amd64_arm", CPU::X64, CPU::ARM}); + + return supported_architectures; + } + static std::vector<Toolset> find_toolset_instances(const VcpkgPaths& paths) + { const auto& fs = paths.get_filesystem(); const std::vector<std::string> vs2017_installation_instances = get_vs2017_installation_instances(paths); @@ -294,19 +313,8 @@ namespace vcpkg paths_examined.push_back(vs2015_dumpbin_exe); const fs::path vs2015_bin_dir = vs2015_vcvarsall_bat.parent_path() / "bin"; - std::vector<ToolsetArchOption> supported_architectures; - if (fs.exists(vs2015_bin_dir / "vcvars32.bat")) - supported_architectures.push_back({L"x86", CPU::X86, CPU::X86}); - if (fs.exists(vs2015_bin_dir / "amd64\\vcvars64.bat")) - supported_architectures.push_back({L"x64", CPU::X64, CPU::X64}); - if (fs.exists(vs2015_bin_dir / "x86_amd64\\vcvarsx86_amd64.bat")) - supported_architectures.push_back({L"x86_amd64", CPU::X86, CPU::X64}); - if (fs.exists(vs2015_bin_dir / "x86_arm\\vcvarsx86_arm.bat")) - supported_architectures.push_back({L"x86_arm", CPU::X86, CPU::ARM}); - if (fs.exists(vs2015_bin_dir / "amd64_x86\\vcvarsamd64_x86.bat")) - supported_architectures.push_back({L"amd64_x86", CPU::X64, CPU::X86}); - if (fs.exists(vs2015_bin_dir / "amd64_arm\\vcvarsamd64_arm.bat")) - supported_architectures.push_back({L"amd64_arm", CPU::X64, CPU::ARM}); + const std::vector<ToolsetArchOption> supported_architectures = + detect_supported_architectures(fs, vs2015_bin_dir); if (fs.exists(vs2015_dumpbin_exe)) { @@ -329,19 +337,8 @@ namespace vcpkg if (!fs.exists(vcvarsall_bat)) continue; // Get all supported architectures - std::vector<ToolsetArchOption> supported_architectures; - if (fs.exists(vcvarsall_dir / "vcvars32.bat")) - supported_architectures.push_back({L"x86", CPU::X86, CPU::X86}); - if (fs.exists(vcvarsall_dir / "vcvars64.bat")) - supported_architectures.push_back({L"amd64", CPU::X64, CPU::X64}); - if (fs.exists(vcvarsall_dir / "vcvarsx86_amd64.bat")) - supported_architectures.push_back({L"x86_amd64", CPU::X86, CPU::X64}); - if (fs.exists(vcvarsall_dir / "vcvarsx86_arm.bat")) - supported_architectures.push_back({L"x86_arm", CPU::X86, CPU::ARM}); - if (fs.exists(vcvarsall_dir / "vcvarsamd64_x86.bat")) - supported_architectures.push_back({L"amd64_x86", CPU::X64, CPU::X86}); - if (fs.exists(vcvarsall_dir / "vcvarsamd64_arm.bat")) - supported_architectures.push_back({L"amd64_arm", CPU::X64, CPU::ARM}); + const std::vector<ToolsetArchOption> supported_architectures = + detect_supported_architectures(fs, vcvarsall_dir); // Locate the "best" MSVC toolchain version const fs::path msvc_path = vc_dir / "Tools" / "MSVC"; |
