Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for building with MinGW #1333

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions aws-cpp-sdk-core/include/aws/core/utils/Array.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ namespace Aws
{
m_data.reset(Aws::NewArray<T>(m_size, ARRAY_ALLOCATION_TAG));

#ifdef _WIN32
#if defined(_WIN32) && !defined(__MINGW32__)
std::copy(arrayToCopy, arrayToCopy + arraySize, stdext::checked_array_iterator< T * >(m_data.get(), m_size));
#else
std::copy(arrayToCopy, arrayToCopy + arraySize, m_data.get());
Expand Down Expand Up @@ -92,7 +92,7 @@ namespace Aws
if(arr->m_size > 0 && arr->m_data)
{
size_t arraySize = arr->m_size;
#ifdef _WIN32
#if defined(_WIN32) && !defined(__MINGW32__)
std::copy(arr->m_data.get(), arr->m_data.get() + arraySize, stdext::checked_array_iterator< T * >(m_data.get() + location, m_size));
#else
std::copy(arr->m_data.get(), arr->m_data.get() + arraySize, m_data.get() + location);
Expand All @@ -111,7 +111,7 @@ namespace Aws
{
m_data.reset(Aws::NewArray<T>(m_size, ARRAY_ALLOCATION_TAG));

#ifdef _WIN32
#if defined(_WIN32) && !defined(__MINGW32__)
std::copy(other.m_data.get(), other.m_data.get() + other.m_size, stdext::checked_array_iterator< T * >(m_data.get(), m_size));
#else
std::copy(other.m_data.get(), other.m_data.get() + other.m_size, m_data.get());
Expand Down Expand Up @@ -144,7 +144,7 @@ namespace Aws
{
m_data.reset(Aws::NewArray<T>(m_size, ARRAY_ALLOCATION_TAG));

#ifdef _WIN32
#if defined(_WIN32) && !defined(__MINGW32__)
std::copy(other.m_data.get(), other.m_data.get() + other.m_size, stdext::checked_array_iterator< T * >(m_data.get(), m_size));
#else
std::copy(other.m_data.get(), other.m_data.get() + other.m_size, m_data.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@ namespace Aws
{
namespace Crypto
{
#ifdef __MINGW32__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#endif
static const char* SecureRandom_BCrypt_Tag = "SecureRandom_BCrypt";
#ifdef __MINGW32__
#pragma GCC diagnostic pop
#endif

class SecureRandomBytes_BCrypt : public SecureRandomBytes
{
Expand Down
10 changes: 10 additions & 0 deletions aws-cpp-sdk-core/include/aws/core/utils/event/EventHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
#include <aws/event-stream/event_stream.h>
#include <cassert>

#ifdef __MINGW32__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#pragma GCC diagnostic ignored "-Wuninitialized"
#endif

namespace Aws
{
namespace Utils
Expand Down Expand Up @@ -319,3 +325,7 @@ namespace Aws
}
}
}

#ifdef __MINGW32__
#pragma GCC diagnostic pop
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ bool WinHttpSyncHttpClient::DoQueryHeaders(void* hHttpRequest, std::shared_ptr<H
wmemset(contentTypeStr, 0, static_cast<size_t>(dwSize / sizeof(wchar_t)));

WinHttpQueryHeaders(hHttpRequest, WINHTTP_QUERY_CONTENT_TYPE, nullptr, &contentTypeStr, &dwSize, 0);
if (contentTypeStr[0] != NULL)
if (contentTypeStr[0] != 0)
{
Aws::String contentStr = StringUtils::FromWString(contentTypeStr);
response->SetContentType(contentStr);
Expand Down Expand Up @@ -298,7 +298,7 @@ bool WinHttpSyncHttpClient::DoQueryHeaders(void* hHttpRequest, std::shared_ptr<H

bool WinHttpSyncHttpClient::DoSendRequest(void* hHttpRequest) const
{
return (WinHttpSendRequest(hHttpRequest, NULL, NULL, 0, 0, 0, NULL) != 0);
return (WinHttpSendRequest(hHttpRequest, NULL, 0, 0, 0, 0, 0) != 0);
}

bool WinHttpSyncHttpClient::DoReadData(void* hHttpRequest, char* body, uint64_t size, uint64_t& read) const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ bool WinINetSyncHttpClient::DoQueryHeaders(void* hHttpRequest, std::shared_ptr<H
char contentTypeStr[1024];
dwSize = sizeof(contentTypeStr);
HttpQueryInfoA(hHttpRequest, HTTP_QUERY_CONTENT_TYPE, &contentTypeStr, &dwSize, 0);
if (contentTypeStr[0] != NULL)
if (contentTypeStr[0] != 0)
{
response->SetContentType(contentTypeStr);
AWS_LOGSTREAM_DEBUG(GetLogTag(), "Received content type " << contentTypeStr);
Expand Down
2 changes: 1 addition & 1 deletion aws-cpp-sdk-core/source/http/windows/WinSyncHttpClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ void WinSyncHttpClient::MakeRequestInternal(HttpRequest& request,
}
}

if (!success && !IsRequestProcessingEnabled() || !ContinueRequest(request))
if (!success && (!IsRequestProcessingEnabled() || !ContinueRequest(request)))
{
response->SetClientErrorType(CoreErrors::USER_CANCELLED);
response->SetClientErrorMessage("Request processing disabled or continuation cancelled by user's continuation handler.");
Expand Down
5 changes: 5 additions & 0 deletions aws-cpp-sdk-core/source/platform/windows/Environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ that would need to be manually freed in all the client functions, just copy it i
*/
Aws::String GetEnv(const char *variableName)
{
#ifdef _MSC_VER
char* variableValue = nullptr;
std::size_t valueSize = 0;
auto queryResult = _dupenv_s(&variableValue, &valueSize, variableName);
Expand All @@ -41,6 +42,10 @@ Aws::String GetEnv(const char *variableName)
}

return result;
#else // __MINGW32__
auto variableValue = std::getenv(variableName);
return Aws::String( variableValue ? variableValue : "" );
#endif
}

} // namespace Environment
Expand Down
7 changes: 6 additions & 1 deletion aws-cpp-sdk-core/source/platform/windows/FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
#include <iostream>
#include <Userenv.h>

#pragma warning( disable : 4996)
#ifdef _MSC_VER
# pragma warning( disable : 4996)
#endif

using namespace Aws::Utils;
namespace Aws
Expand Down Expand Up @@ -314,6 +316,9 @@ Aws::String CreateTempFilePath()
{
#ifdef _MSC_VER
#pragma warning(disable: 4996) // _CRT_SECURE_NO_WARNINGS
#else
// Definition from the MSVC stdio.h
#define L_tmpnam_s (sizeof("\\") + 16)
#endif
char s_tempName[L_tmpnam_s+1];

Expand Down
2 changes: 2 additions & 0 deletions aws-cpp-sdk-core/source/platform/windows/OSVersionInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@

#include <iomanip>

#ifdef _MSC_VER
#pragma warning(disable: 4996)
#endif
#include <windows.h>
#include <stdio.h>
namespace Aws
Expand Down
4 changes: 2 additions & 2 deletions aws-cpp-sdk-core/source/utils/crypto/factory/Factories.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ std::shared_ptr<Aws::Utils::Crypto::HMAC> Aws::Utils::Crypto::CreateSha256HMACIm
return s_Sha256HMACFactory->CreateImplementation();
}

#ifdef _WIN32
#ifdef _MSC_VER
#pragma warning( push )
#pragma warning( disable : 4702 )
#endif
Expand Down Expand Up @@ -840,7 +840,7 @@ std::shared_ptr<SymmetricCipher> Aws::Utils::Crypto::CreateAES_KeyWrapImplementa
return s_AES_KeyWrapFactory->CreateImplementation(key);
}

#ifdef _WIN32
#ifdef _MSC_VER
#pragma warning(pop)
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
#include <aws/testing/TestingEnvironment.h>
#include <fstream>

#ifdef _WIN32
#ifdef _MSC_VER
#pragma warning(disable: 4127)
#endif //_WIN32
#endif //_MSC_VER

#include <aws/core/http/standard/StandardHttpRequest.h>

Expand Down
6 changes: 6 additions & 0 deletions cmake/compiler_settings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ else()
set(COMPILER_CLANG 1)
else()
set(COMPILER_GCC 1)
if(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES MATCHES "mingw32")
set(COMPILER_MINGW 1)
endif()
endif()
set(USE_GCC_FLAGS 1)
endif()
Expand All @@ -34,6 +37,9 @@ endfunction()

macro(set_gcc_flags)
list(APPEND AWS_COMPILER_FLAGS "-fno-exceptions" "-std=c++${CPP_STANDARD}")
if(COMPILER_IS_MINGW)
list(APPEND AWS_COMPILER_FLAGS -D__USE_MINGW_ANSI_STDIO=1)
endif()

if(NOT BUILD_SHARED_LIBS)
list(APPEND AWS_COMPILER_FLAGS "-fPIC")
Expand Down
2 changes: 2 additions & 0 deletions testing-resources/source/platform/windows/PlatformTesting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@

#include <aws/testing/platform/PlatformTesting.h>

#ifdef _MSC_VER
#pragma warning(disable: 4996)
#endif
#include <windows.h>
#include <aws/core/utils/memory/stl/AWSStringStream.h>

Expand Down