[vcpkg] Fix regressions in WSL build.

This commit is contained in:
Robert Schumacher 2017-12-14 14:31:16 -08:00
parent 7b7e7dac3b
commit 63a23cf0ca
7 changed files with 27 additions and 16 deletions

View File

@ -3,10 +3,12 @@ project(vcpkg CXX)
add_compile_options(-std=c++1z)
if(CMAKE_COMPILER_IS_GNUXX)
if(CMAKE_COMPILER_IS_GNUXX OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(GCC 1)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang")
set(CLANG 1)
else()
message(FATAL_ERROR "Unknown compiler: ${CMAKE_CXX_COMPILER_ID}")
endif()
file(GLOB_RECURSE VCPKGLIB_SOURCES src/vcpkg/*.cpp)

View File

@ -53,10 +53,8 @@ namespace vcpkg
// Constructors are intentionally implicit
constexpr Optional(NullOpt) {}
Optional(const T& t) : m_base(t) {}
template<class = std::enable_if_t<!std::is_reference<T>::value>>
Optional(T&& t) : m_base(std::move(t))
template<class U>
Optional(U&& t) : m_base(std::forward<U>(t))
{
}

View File

@ -92,14 +92,20 @@ namespace vcpkg::Chrono
Optional<CTime> CTime::parse(CStringView str)
{
CTime ret;
auto assigned = sscanf_s(str.c_str(),
"%d-%d-%dT%d:%d:%d.",
&ret.m_tm.tm_year,
&ret.m_tm.tm_mon,
&ret.m_tm.tm_mday,
&ret.m_tm.tm_hour,
&ret.m_tm.tm_min,
&ret.m_tm.tm_sec);
auto assigned =
#if defined(_WIN32)
sscanf_s
#else
sscanf
#endif
(str.c_str(),
"%d-%d-%dT%d:%d:%d.",
&ret.m_tm.tm_year,
&ret.m_tm.tm_mon,
&ret.m_tm.tm_mday,
&ret.m_tm.tm_hour,
&ret.m_tm.tm_min,
&ret.m_tm.tm_sec);
if (assigned != 6) return nullopt;
if (ret.m_tm.tm_year < 1900) return nullopt;
ret.m_tm.tm_year -= 1900;

View File

@ -5,6 +5,7 @@
#include <vcpkg/paragraphs.h>
#include <vcpkg/userconfig.h>
#if defined(_WIN32)
namespace
{
static vcpkg::Lazy<fs::path> s_localappdata;
@ -24,13 +25,14 @@ namespace
});
}
}
#endif
namespace vcpkg
{
UserConfig UserConfig::try_read_data(const Files::Filesystem& fs)
{
UserConfig ret;
#if defined(_WIN32)
try
{
auto maybe_pghs = Paragraphs::get_paragraphs(fs, get_localappdata() / "vcpkg" / "config");
@ -56,12 +58,14 @@ namespace vcpkg
catch (...)
{
}
#endif
return ret;
}
void UserConfig::try_write_data(Files::Filesystem& fs) const
{
#if defined(_WIN32)
try
{
std::error_code ec;
@ -79,5 +83,6 @@ namespace vcpkg
catch (...)
{
}
#endif
}
}

View File

@ -185,7 +185,6 @@
<ClInclude Include="..\include\vcpkg\versiont.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\commands.upgrade.cpp" />
<ClCompile Include="..\src\pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
@ -221,6 +220,7 @@
<ClCompile Include="..\src\vcpkg\commands.owns.cpp" />
<ClCompile Include="..\src\vcpkg\commands.portsdiff.cpp" />
<ClCompile Include="..\src\vcpkg\commands.search.cpp" />
<ClCompile Include="..\src\vcpkg\commands.upgrade.cpp" />
<ClCompile Include="..\src\vcpkg\commands.version.cpp" />
<ClCompile Include="..\src\vcpkg\dependencies.cpp" />
<ClCompile Include="..\src\vcpkg\export.cpp" />

View File

@ -195,7 +195,7 @@
<ClCompile Include="..\src\vcpkg\userconfig.cpp">
<Filter>Source Files\vcpkg</Filter>
</ClCompile>
<ClCompile Include="..\src\commands.upgrade.cpp">
<ClCompile Include="..\src\vcpkg\commands.upgrade.cpp">
<Filter>Source Files\vcpkg</Filter>
</ClCompile>
</ItemGroup>