diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2017-05-03 16:33:02 -0700 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2017-05-04 15:06:18 -0700 |
| commit | 7bdf189a921fdee47044e907a3ff48ce8c880fe2 (patch) | |
| tree | f9e5b253020e4134ad58562fccece9d7832c6df5 /toolsrc/src/vcpkg_System.cpp | |
| parent | a66b066d4584d6b92d249d71b9348344efc78d5e (diff) | |
| download | vcpkg-7bdf189a921fdee47044e907a3ff48ce8c880fe2.tar.gz vcpkg-7bdf189a921fdee47044e907a3ff48ce8c880fe2.zip | |
Rework vcpkg's triplet environment reading
The triplet is "run" and vcpkg observes the environment.
Previously, the environment was deduced by the triplet's name
Diffstat (limited to 'toolsrc/src/vcpkg_System.cpp')
| -rw-r--r-- | toolsrc/src/vcpkg_System.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/toolsrc/src/vcpkg_System.cpp b/toolsrc/src/vcpkg_System.cpp index 5d4d2b15a..17632f043 100644 --- a/toolsrc/src/vcpkg_System.cpp +++ b/toolsrc/src/vcpkg_System.cpp @@ -23,6 +23,25 @@ namespace vcpkg::System return fs::path(buf, buf + bytes); } + Optional<CPUArchitecture> to_cpu_architecture(CStringView arch) + { + if (_stricmp(arch, "x86") == 0) return CPUArchitecture::X86; + if (_stricmp(arch, "x64") == 0) return CPUArchitecture::X64; + if (_stricmp(arch, "amd64") == 0) return CPUArchitecture::X64; + if (_stricmp(arch, "arm") == 0) return CPUArchitecture::ARM; + if (_stricmp(arch, "arm64") == 0) return CPUArchitecture::ARM64; + return nullopt; + } + + CPUArchitecture get_host_processor() + { + auto w6432 = get_environment_variable(L"PROCESSOR_ARCHITEW6432"); + if (auto p = w6432.get()) return to_cpu_architecture(Strings::to_utf8(*p)).value_or_exit(VCPKG_LINE_INFO); + + auto procarch = get_environment_variable(L"PROCESSOR_ARCHITECTURE").value_or_exit(VCPKG_LINE_INFO); + return to_cpu_architecture(Strings::to_utf8(procarch)).value_or_exit(VCPKG_LINE_INFO); + } + int cmd_execute_clean(const CWStringView cmd_line) { static const std::wstring system_root = get_environment_variable(L"SystemRoot").value_or_exit(VCPKG_LINE_INFO); |
