From a94efe662b0537a606d40bdd4b986b5b2ea246e2 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 4 May 2017 14:54:23 -0700 Subject: Rename Strings:: function for utf8/utf16 conversion --- toolsrc/src/vcpkg_System.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'toolsrc/src/vcpkg_System.cpp') diff --git a/toolsrc/src/vcpkg_System.cpp b/toolsrc/src/vcpkg_System.cpp index abbed587c..e401e956e 100644 --- a/toolsrc/src/vcpkg_System.cpp +++ b/toolsrc/src/vcpkg_System.cpp @@ -97,7 +97,7 @@ namespace vcpkg::System // Basically we are wrapping it in quotes const std::wstring& actual_cmd_line = Strings::wformat(LR"###("%s")###", cmd_line); - if (g_debugging) System::println("[DEBUG] _wspawnlpe(cmd.exe /c %s)", Strings::utf16_to_utf8(actual_cmd_line)); + if (g_debugging) System::println("[DEBUG] _wspawnlpe(cmd.exe /c %s)", Strings::to_utf8(actual_cmd_line)); auto exit_code = _wspawnlpe(_P_WAIT, L"cmd.exe", L"cmd.exe", L"/c", actual_cmd_line.c_str(), nullptr, env_cstr.data()); if (g_debugging) System::println("[DEBUG] _wspawnlpe() returned %d", exit_code); @@ -111,7 +111,7 @@ namespace vcpkg::System // Basically we are wrapping it in quotes const std::wstring& actual_cmd_line = Strings::wformat(LR"###("%s")###", cmd_line); - if (g_debugging) System::println("[DEBUG] _wsystem(%s)", Strings::utf16_to_utf8(actual_cmd_line)); + if (g_debugging) System::println("[DEBUG] _wsystem(%s)", Strings::to_utf8(actual_cmd_line)); int exit_code = _wsystem(actual_cmd_line.c_str()); if (g_debugging) System::println("[DEBUG] _wsystem() returned %d", exit_code); return exit_code; -- cgit v1.2.3 From a66b066d4584d6b92d249d71b9348344efc78d5e Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 4 May 2017 14:58:18 -0700 Subject: get_environmental_variable() -> get_environment_variable() --- toolsrc/src/vcpkg_System.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'toolsrc/src/vcpkg_System.cpp') diff --git a/toolsrc/src/vcpkg_System.cpp b/toolsrc/src/vcpkg_System.cpp index e401e956e..5d4d2b15a 100644 --- a/toolsrc/src/vcpkg_System.cpp +++ b/toolsrc/src/vcpkg_System.cpp @@ -25,8 +25,7 @@ namespace vcpkg::System int cmd_execute_clean(const CWStringView cmd_line) { - static const std::wstring system_root = - get_environmental_variable(L"SystemRoot").value_or_exit(VCPKG_LINE_INFO); + static const std::wstring system_root = get_environment_variable(L"SystemRoot").value_or_exit(VCPKG_LINE_INFO); static const std::wstring system_32 = system_root + LR"(\system32)"; static const std::wstring new_PATH = Strings::wformat( LR"(Path=%s;%s;%s\Wbem;%s\WindowsPowerShell\v1.0\)", system_32, system_root, system_32, system_32); @@ -83,7 +82,7 @@ namespace vcpkg::System for (auto&& env_wstring : env_wstrings) { - const Optional value = System::get_environmental_variable(env_wstring); + const Optional value = System::get_environment_variable(env_wstring); auto v = value.get(); if (!v || v->empty()) continue; @@ -177,7 +176,7 @@ namespace vcpkg::System putchar('\n'); } - Optional get_environmental_variable(const CWStringView varname) noexcept + Optional get_environment_variable(const CWStringView varname) noexcept { auto sz = GetEnvironmentVariableW(varname, nullptr, 0); if (sz == 0) return nullopt; @@ -221,14 +220,14 @@ namespace vcpkg::System static const fs::path& get_ProgramFiles() { - static const fs::path p = System::get_environmental_variable(L"PROGRAMFILES").value_or_exit(VCPKG_LINE_INFO); + static const fs::path p = System::get_environment_variable(L"PROGRAMFILES").value_or_exit(VCPKG_LINE_INFO); return p; } const fs::path& get_ProgramFiles_32_bit() { static const fs::path p = []() -> fs::path { - auto value = System::get_environmental_variable(L"ProgramFiles(x86)"); + auto value = System::get_environment_variable(L"ProgramFiles(x86)"); if (auto v = value.get()) { return std::move(*v); @@ -241,7 +240,7 @@ namespace vcpkg::System const fs::path& get_ProgramFiles_platform_bitness() { static const fs::path p = []() -> fs::path { - auto value = System::get_environmental_variable(L"ProgramW6432"); + auto value = System::get_environment_variable(L"ProgramW6432"); if (auto v = value.get()) { return std::move(*v); -- cgit v1.2.3 From 7bdf189a921fdee47044e907a3ff48ce8c880fe2 Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Wed, 3 May 2017 16:33:02 -0700 Subject: 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 --- toolsrc/src/vcpkg_System.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'toolsrc/src/vcpkg_System.cpp') 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 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); -- cgit v1.2.3 From 05b47002ebbf99561476564cb9dfe1869cb79c7c Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Thu, 4 May 2017 15:19:22 -0700 Subject: Introduce Strings::case_insensitive_ascii_compare() --- toolsrc/src/vcpkg_System.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'toolsrc/src/vcpkg_System.cpp') diff --git a/toolsrc/src/vcpkg_System.cpp b/toolsrc/src/vcpkg_System.cpp index 17632f043..00f4a091b 100644 --- a/toolsrc/src/vcpkg_System.cpp +++ b/toolsrc/src/vcpkg_System.cpp @@ -25,11 +25,11 @@ namespace vcpkg::System Optional 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; + if (Strings::case_insensitive_ascii_compare(arch, "x86") == 0) return CPUArchitecture::X86; + if (Strings::case_insensitive_ascii_compare(arch, "x64") == 0) return CPUArchitecture::X64; + if (Strings::case_insensitive_ascii_compare(arch, "amd64") == 0) return CPUArchitecture::X64; + if (Strings::case_insensitive_ascii_compare(arch, "arm") == 0) return CPUArchitecture::ARM; + if (Strings::case_insensitive_ascii_compare(arch, "arm64") == 0) return CPUArchitecture::ARM64; return nullopt; } -- cgit v1.2.3