aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src
diff options
context:
space:
mode:
authorRobert Schumacher <roschuma@microsoft.com>2017-08-26 00:19:51 -0700
committerRobert Schumacher <roschuma@microsoft.com>2017-08-26 00:20:03 -0700
commit70949b0d814c469d76b8ddecc514ae0af6686347 (patch)
tree3b01ce11c0e6bb1cfbb4b67369fc58b5ef23d536 /toolsrc/src
parentceb54bae8754f707bec17ac6ff3e35a32b0966e3 (diff)
downloadvcpkg-70949b0d814c469d76b8ddecc514ae0af6686347.tar.gz
vcpkg-70949b0d814c469d76b8ddecc514ae0af6686347.zip
[vcpkg] Use vcvars argument strings from detected toolset. Avoid c-string pointer comparison.
Diffstat (limited to 'toolsrc/src')
-rw-r--r--toolsrc/src/VcpkgPaths.cpp37
-rw-r--r--toolsrc/src/vcpkg_Build.cpp33
2 files changed, 26 insertions, 44 deletions
diff --git a/toolsrc/src/VcpkgPaths.cpp b/toolsrc/src/VcpkgPaths.cpp
index 642ca6a9c..7e3e5c736 100644
--- a/toolsrc/src/VcpkgPaths.cpp
+++ b/toolsrc/src/VcpkgPaths.cpp
@@ -302,25 +302,24 @@ 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_archictectures;
- if(fs.exists(vs2015_bin_dir / "vcvars32.bat"))
- supported_archictectures.push_back({L"x86", CPU::X86, CPU::X86});
+ 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_archictectures.push_back({L"x64", CPU::X64, CPU::X64});
- if (fs.exists(vs2015_bin_dir / "arm\\vcvarsarm.bat"))
- supported_archictectures.push_back({L"arm", CPU::ARM, CPU::ARM});
+ supported_architectures.push_back({L"x64", CPU::X64, CPU::X64});
if (fs.exists(vs2015_bin_dir / "x86_amd64\\vcvarsx86_amd64.bat"))
- supported_archictectures.push_back({L"x86_amd64", CPU::X86, CPU::X64});
+ supported_architectures.push_back({L"x86_amd64", CPU::X86, CPU::X64});
if (fs.exists(vs2015_bin_dir / "x86_arm\\vcvarsx86_arm.bat"))
- supported_archictectures.push_back({L"x86_arm" , CPU::X86, CPU::ARM});
+ supported_architectures.push_back({L"x86_arm", CPU::X86, CPU::ARM});
if (fs.exists(vs2015_bin_dir / "amd64_x86\\vcvarsamd64_x86.bat"))
- supported_archictectures.push_back({L"amd64_x86", CPU::X64, CPU::X86});
+ supported_architectures.push_back({L"amd64_x86", CPU::X64, CPU::X86});
if (fs.exists(vs2015_bin_dir / "amd64_arm\\vcvarsamd64_arm.bat"))
- supported_archictectures.push_back({L"amd64_arm", CPU::X64, CPU::ARM});
+ supported_architectures.push_back({L"amd64_arm", CPU::X64, CPU::ARM});
if (fs.exists(vs2015_dumpbin_exe))
{
- found_toolsets.push_back({vs2015_dumpbin_exe, vs2015_vcvarsall_bat, L"v140", supported_archictectures });
+ found_toolsets.push_back(
+ {vs2015_dumpbin_exe, vs2015_vcvarsall_bat, L"v140", supported_architectures});
}
}
}
@@ -337,22 +336,20 @@ namespace vcpkg
paths_examined.push_back(vcvarsall_bat);
if (!fs.exists(vcvarsall_bat)) continue;
- //Get all supported architecturs
+ // 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 });
+ 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 / "vcvarsarm.bat"))
- supported_architectures.push_back({L"arm", CPU::ARM,CPU::ARM });
+ 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 });
+ 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 });
+ 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 });
+ 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 });
+ supported_architectures.push_back({L"amd64_arm", CPU::X64, CPU::ARM});
// Locate the "best" MSVC toolchain version
const fs::path msvc_path = vc_dir / "Tools" / "MSVC";
diff --git a/toolsrc/src/vcpkg_Build.cpp b/toolsrc/src/vcpkg_Build.cpp
index b0053766e..2b6950bc0 100644
--- a/toolsrc/src/vcpkg_Build.cpp
+++ b/toolsrc/src/vcpkg_Build.cpp
@@ -38,33 +38,18 @@ namespace vcpkg::Build
CWStringView to_vcvarsall_toolchain(const std::string& target_architecture, const Toolset& toolset)
{
- using CPU = System::CPUArchitecture;
-
- static constexpr ToolsetArchOption X86 = {L"x86", CPU::X86, CPU::X86};
- static constexpr ToolsetArchOption X86_X64 = {L"x86_x64", CPU::X86, CPU::X64};
- static constexpr ToolsetArchOption X86_ARM = {L"x86_arm", CPU::X86, CPU::ARM};
- static constexpr ToolsetArchOption X86_ARM64 = {L"x86_arm64", CPU::X86, CPU::ARM64};
-
- static constexpr ToolsetArchOption X64 = {L"amd64", CPU::X64, CPU::X64};
- static constexpr ToolsetArchOption X64_X86 = {L"amd64_x86", CPU::X64, CPU::X86};
- static constexpr ToolsetArchOption X64_ARM = {L"amd64_arm", CPU::X64, CPU::ARM};
- static constexpr ToolsetArchOption X64_ARM64 = {L"amd64_arm64", CPU::X64, CPU::ARM64};
-
- static constexpr std::array<ToolsetArchOption, 8> VALUES = {
- X64, X64_X86, X64_ARM, X64_ARM64, X86, X86_X64, X86_ARM, X86_ARM64};
-
- auto target_arch = System::to_cpu_architecture(target_architecture);
+ auto maybe_target_arch = System::to_cpu_architecture(target_architecture);
+ Checks::check_exit(
+ VCPKG_LINE_INFO, maybe_target_arch.has_value(), "Invalid architecture string: %s", target_architecture);
+ auto target_arch = maybe_target_arch.value_or_exit(VCPKG_LINE_INFO);
auto host_architectures = System::get_supported_host_architectures();
- for (auto&& value : VALUES)
+ for (auto&& host : host_architectures)
{
- if (target_arch != value.target_arch ||
- std::find(host_architectures.begin(), host_architectures.end(), value.host_arch) == host_architectures.end() ||
- std::find(toolset.supported_architectures.begin(), toolset.supported_architectures.end(), value) == toolset.supported_architectures.end()
- )
- continue;
-
- return value.name;
+ auto it = Util::find_if(toolset.supported_architectures, [&](const ToolsetArchOption& opt) {
+ return host == opt.host_arch && target_arch == opt.target_arch;
+ });
+ if (it != toolset.supported_architectures.end()) return it->name;
}
Checks::exit_with_message(VCPKG_LINE_INFO, "Unsupported toolchain combination %s", target_architecture);