mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
use libc++ and clang toolchain
This commit is contained in:
parent
aea60692de
commit
47f15f6ad8
4 changed files with 69 additions and 30 deletions
|
@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.2)
|
||||||
if (USE_ANDROID_TOOLCHAIN)
|
if (USE_ANDROID_TOOLCHAIN)
|
||||||
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/android/android.toolchain.cmake")
|
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/android/android.toolchain.cmake")
|
||||||
set(ANDROID_NATIVE_API_LEVEL 19)
|
set(ANDROID_NATIVE_API_LEVEL 19)
|
||||||
|
set(ANDROID_TOOLCHAIN_NAME arm-linux-androideabi-clang3.5)
|
||||||
|
set(ANDROID_STL c++_static)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
|
@ -64,7 +66,7 @@ if (WIN32)
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEBUG /OPT:REF /OPT:ICF")
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /DEBUG /OPT:REF /OPT:ICF")
|
||||||
else ()
|
else ()
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fno-strict-aliasing -Wno-unused-parameter")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fno-strict-aliasing -Wno-unused-parameter")
|
||||||
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
|
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb -Woverloaded-virtual -Wdouble-promotion")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb -Woverloaded-virtual -Wdouble-promotion")
|
||||||
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "5.1") # gcc 5.1 and on have suggest-override
|
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "5.1") # gcc 5.1 and on have suggest-override
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsuggest-override")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsuggest-override")
|
||||||
|
@ -72,18 +74,23 @@ else ()
|
||||||
endif ()
|
endif ()
|
||||||
endif(WIN32)
|
endif(WIN32)
|
||||||
|
|
||||||
if ((NOT MSVC12) AND (NOT MSVC14))
|
if (NOT ANDROID)
|
||||||
include(CheckCXXCompilerFlag)
|
if ((NOT MSVC12) AND (NOT MSVC14))
|
||||||
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
|
include(CheckCXXCompilerFlag)
|
||||||
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
|
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
|
||||||
|
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
|
||||||
|
|
||||||
if (COMPILER_SUPPORTS_CXX11)
|
if (COMPILER_SUPPORTS_CXX11)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||||
elseif(COMPILER_SUPPORTS_CXX0X)
|
elseif(COMPILER_SUPPORTS_CXX0X)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||||
else()
|
else()
|
||||||
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
|
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
|
||||||
endif()
|
endif()
|
||||||
|
endif ()
|
||||||
|
else ()
|
||||||
|
# assume that the toolchain selected for android has C++11 support
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
|
|
|
@ -154,6 +154,8 @@
|
||||||
# Implies -frtti -fno-exceptions.
|
# Implies -frtti -fno-exceptions.
|
||||||
# Available for NDK r7b and newer.
|
# Available for NDK r7b and newer.
|
||||||
# Silently degrades to gnustl_static if not available.
|
# Silently degrades to gnustl_static if not available.
|
||||||
|
# c++_static -> Use the LLVM libc++ runtime as a static library.
|
||||||
|
# c++_shared -> Use the LLVM libc++ runtime as a shared library.
|
||||||
#
|
#
|
||||||
# ANDROID_STL_FORCE_FEATURES=ON - turn rtti and exceptions support based on
|
# ANDROID_STL_FORCE_FEATURES=ON - turn rtti and exceptions support based on
|
||||||
# chosen runtime. If disabled, then the user is responsible for settings
|
# chosen runtime. If disabled, then the user is responsible for settings
|
||||||
|
@ -833,7 +835,7 @@ set( ANDROID_STL_FORCE_FEATURES ON CACHE BOOL "automatically configure rtti and
|
||||||
mark_as_advanced( ANDROID_STL ANDROID_STL_FORCE_FEATURES )
|
mark_as_advanced( ANDROID_STL ANDROID_STL_FORCE_FEATURES )
|
||||||
|
|
||||||
if( BUILD_WITH_ANDROID_NDK )
|
if( BUILD_WITH_ANDROID_NDK )
|
||||||
if( NOT "${ANDROID_STL}" MATCHES "^(none|system|system_re|gabi\\+\\+_static|gabi\\+\\+_shared|stlport_static|stlport_shared|gnustl_static|gnustl_shared)$")
|
if( NOT "${ANDROID_STL}" MATCHES "^(none|system|system_re|gabi\\+\\+_static|gabi\\+\\+_shared|stlport_static|stlport_shared|gnustl_static|gnustl_shared|c\\+\\+_static|c\\+\\+_shared)$")
|
||||||
message( FATAL_ERROR "ANDROID_STL is set to invalid value \"${ANDROID_STL}\".
|
message( FATAL_ERROR "ANDROID_STL is set to invalid value \"${ANDROID_STL}\".
|
||||||
The possible values are:
|
The possible values are:
|
||||||
none -> Do not configure the runtime.
|
none -> Do not configure the runtime.
|
||||||
|
@ -845,6 +847,8 @@ The possible values are:
|
||||||
stlport_shared -> Use the STLport runtime as a shared library.
|
stlport_shared -> Use the STLport runtime as a shared library.
|
||||||
gnustl_static -> (default) Use the GNU STL as a static library.
|
gnustl_static -> (default) Use the GNU STL as a static library.
|
||||||
gnustl_shared -> Use the GNU STL as a shared library.
|
gnustl_shared -> Use the GNU STL as a shared library.
|
||||||
|
c++_static -> Use the LLVM libc++ runtime as a static library.
|
||||||
|
c++_shared -> Use the LLVM libc++ runtime as a shared library.
|
||||||
" )
|
" )
|
||||||
endif()
|
endif()
|
||||||
elseif( BUILD_WITH_STANDALONE_TOOLCHAIN )
|
elseif( BUILD_WITH_STANDALONE_TOOLCHAIN )
|
||||||
|
@ -1026,6 +1030,34 @@ if( BUILD_WITH_ANDROID_NDK )
|
||||||
else()
|
else()
|
||||||
set( __libstl "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" )
|
set( __libstl "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/libstdc++.a" )
|
||||||
endif()
|
endif()
|
||||||
|
elseif( ANDROID_STL MATCHES "c\\+\\+_shared" OR ANDROID_STL MATCHES "c\\+\\+_static" )
|
||||||
|
set( ANDROID_EXCEPTIONS ON )
|
||||||
|
set( ANDROID_RTTI ON )
|
||||||
|
set( ANDROID_CXX_ROOT "${ANDROID_NDK}/sources/cxx-stl/" )
|
||||||
|
set( ANDROID_LLVM_ROOT "${ANDROID_CXX_ROOT}/llvm-libc++" )
|
||||||
|
|
||||||
|
if( X86 )
|
||||||
|
set( ANDROID_ABI_INCLUDE_DIRS "${ANDROID_CXX_ROOT}/gabi++/include" )
|
||||||
|
else()
|
||||||
|
set( ANDROID_ABI_INCLUDE_DIRS "${ANDROID_CXX_ROOT}/llvm-libc++abi/include" )
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_LLVM_ROOT}/libcxx/include" "${ANDROID_ABI_INCLUDE_DIRS}" )
|
||||||
|
|
||||||
|
# android support sfiles
|
||||||
|
include_directories ( SYSTEM ${ANDROID_NDK}/sources/android/support/include )
|
||||||
|
|
||||||
|
if(ANDROID_STL MATCHES "c\\+\\+_shared")
|
||||||
|
set ( LLVM_LIBRARY_NAME "libc++_shared.so")
|
||||||
|
else()
|
||||||
|
set ( LLVM_LIBRARY_NAME "libc++_static.a" )
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if( EXISTS "${ANDROID_LLVM_ROOT}/libs/${ANDROID_NDK_ABI_NAME}/${LLVM_LIBRARY_NAME}" )
|
||||||
|
set( __libstl "${ANDROID_LLVM_ROOT}/libs/${ANDROID_NDK_ABI_NAME}/${LLVM_LIBRARY_NAME}" )
|
||||||
|
else()
|
||||||
|
message( FATAL_ERROR "Could not find libc++ library" )
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
message( FATAL_ERROR "Unknown runtime: ${ANDROID_STL}" )
|
message( FATAL_ERROR "Unknown runtime: ${ANDROID_STL}" )
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -56,7 +56,7 @@ JSONCallbackParameters::JSONCallbackParameters(QObject* jsonCallbackReceiver, co
|
||||||
updateReciever(updateReceiver),
|
updateReciever(updateReceiver),
|
||||||
updateSlot(updateSlot)
|
updateSlot(updateSlot)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject AccountManager::dataObjectFromResponse(QNetworkReply &requestReply) {
|
QJsonObject AccountManager::dataObjectFromResponse(QNetworkReply &requestReply) {
|
||||||
|
@ -85,7 +85,7 @@ AccountManager::AccountManager(UserAgentGetter userAgentGetter) :
|
||||||
|
|
||||||
qRegisterMetaType<QNetworkAccessManager::Operation>("QNetworkAccessManager::Operation");
|
qRegisterMetaType<QNetworkAccessManager::Operation>("QNetworkAccessManager::Operation");
|
||||||
qRegisterMetaType<JSONCallbackParameters>("JSONCallbackParameters");
|
qRegisterMetaType<JSONCallbackParameters>("JSONCallbackParameters");
|
||||||
|
|
||||||
qRegisterMetaType<QHttpMultiPart*>("QHttpMultiPart*");
|
qRegisterMetaType<QHttpMultiPart*>("QHttpMultiPart*");
|
||||||
|
|
||||||
qRegisterMetaType<AccountManagerAuth::Type>();
|
qRegisterMetaType<AccountManagerAuth::Type>();
|
||||||
|
@ -143,7 +143,7 @@ void AccountManager::setAuthURL(const QUrl& authURL) {
|
||||||
_authURL = authURL;
|
_authURL = authURL;
|
||||||
|
|
||||||
qCDebug(networking) << "AccountManager URL for authenticated requests has been changed to" << qPrintable(_authURL.toString());
|
qCDebug(networking) << "AccountManager URL for authenticated requests has been changed to" << qPrintable(_authURL.toString());
|
||||||
|
|
||||||
// check if there are existing access tokens to load from settings
|
// check if there are existing access tokens to load from settings
|
||||||
QFile accountsFile { accountFilePath() };
|
QFile accountsFile { accountFilePath() };
|
||||||
bool loadedMap = false;
|
bool loadedMap = false;
|
||||||
|
@ -434,9 +434,9 @@ void AccountManager::removeAccountFromFile() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AccountManager::hasValidAccessToken() {
|
bool AccountManager::hasValidAccessToken() {
|
||||||
|
|
||||||
if (_accountInfo.getAccessToken().token.isEmpty() || _accountInfo.getAccessToken().isExpired()) {
|
if (_accountInfo.getAccessToken().token.isEmpty() || _accountInfo.getAccessToken().isExpired()) {
|
||||||
|
|
||||||
if (VERBOSE_HTTP_REQUEST_DEBUGGING) {
|
if (VERBOSE_HTTP_REQUEST_DEBUGGING) {
|
||||||
qCDebug(networking) << "An access token is required for requests to" << qPrintable(_authURL.toString());
|
qCDebug(networking) << "An access token is required for requests to" << qPrintable(_authURL.toString());
|
||||||
}
|
}
|
||||||
|
@ -468,7 +468,7 @@ void AccountManager::setAccessTokenForCurrentAuthURL(const QString& accessToken)
|
||||||
} else if (!_accountInfo.getAccessToken().token.isEmpty()) {
|
} else if (!_accountInfo.getAccessToken().token.isEmpty()) {
|
||||||
qCDebug(networking) << "Clearing AccountManager OAuth token.";
|
qCDebug(networking) << "Clearing AccountManager OAuth token.";
|
||||||
}
|
}
|
||||||
|
|
||||||
_accountInfo.setAccessToken(newOAuthToken);
|
_accountInfo.setAccessToken(newOAuthToken);
|
||||||
|
|
||||||
persistAccountToFile();
|
persistAccountToFile();
|
||||||
|
@ -553,7 +553,7 @@ void AccountManager::requestAccessTokenFinished() {
|
||||||
_accountInfo.setAccessTokenFromJSON(rootObject);
|
_accountInfo.setAccessTokenFromJSON(rootObject);
|
||||||
|
|
||||||
emit loginComplete(rootURL);
|
emit loginComplete(rootURL);
|
||||||
|
|
||||||
persistAccountToFile();
|
persistAccountToFile();
|
||||||
|
|
||||||
requestProfile();
|
requestProfile();
|
||||||
|
@ -576,7 +576,7 @@ void AccountManager::requestProfile() {
|
||||||
|
|
||||||
QUrl profileURL = _authURL;
|
QUrl profileURL = _authURL;
|
||||||
profileURL.setPath("/api/v1/user/profile");
|
profileURL.setPath("/api/v1/user/profile");
|
||||||
|
|
||||||
QNetworkRequest profileRequest(profileURL);
|
QNetworkRequest profileRequest(profileURL);
|
||||||
profileRequest.setHeader(QNetworkRequest::UserAgentHeader, _userAgentGetter());
|
profileRequest.setHeader(QNetworkRequest::UserAgentHeader, _userAgentGetter());
|
||||||
profileRequest.setRawHeader(ACCESS_TOKEN_AUTHORIZATION_HEADER, _accountInfo.getAccessToken().authorizationHeaderValue());
|
profileRequest.setRawHeader(ACCESS_TOKEN_AUTHORIZATION_HEADER, _accountInfo.getAccessToken().authorizationHeaderValue());
|
||||||
|
@ -602,7 +602,7 @@ void AccountManager::requestProfileFinished() {
|
||||||
|
|
||||||
// store the whole profile into the local settings
|
// store the whole profile into the local settings
|
||||||
persistAccountToFile();
|
persistAccountToFile();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// TODO: error handling
|
// TODO: error handling
|
||||||
qCDebug(networking) << "Error in response for profile";
|
qCDebug(networking) << "Error in response for profile";
|
||||||
|
@ -658,14 +658,14 @@ void AccountManager::generateNewKeypair(bool isUserKeypair, const QUuid& domainI
|
||||||
connect(generateThread, &QThread::finished, generateThread, &QThread::deleteLater);
|
connect(generateThread, &QThread::finished, generateThread, &QThread::deleteLater);
|
||||||
|
|
||||||
keypairGenerator->moveToThread(generateThread);
|
keypairGenerator->moveToThread(generateThread);
|
||||||
|
|
||||||
qCDebug(networking) << "Starting worker thread to generate 2048-bit RSA keypair.";
|
qCDebug(networking) << "Starting worker thread to generate 2048-bit RSA keypair.";
|
||||||
generateThread->start();
|
generateThread->start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountManager::processGeneratedKeypair() {
|
void AccountManager::processGeneratedKeypair() {
|
||||||
|
|
||||||
qCDebug(networking) << "Generated 2048-bit RSA keypair. Uploading public key now.";
|
qCDebug(networking) << "Generated 2048-bit RSA keypair. Uploading public key now.";
|
||||||
|
|
||||||
RSAKeypairGenerator* keypairGenerator = qobject_cast<RSAKeypairGenerator*>(sender());
|
RSAKeypairGenerator* keypairGenerator = qobject_cast<RSAKeypairGenerator*>(sender());
|
||||||
|
@ -716,7 +716,7 @@ void AccountManager::processGeneratedKeypair() {
|
||||||
|
|
||||||
sendRequest(uploadPath, AccountManagerAuth::Optional, QNetworkAccessManager::PutOperation,
|
sendRequest(uploadPath, AccountManagerAuth::Optional, QNetworkAccessManager::PutOperation,
|
||||||
callbackParameters, QByteArray(), requestMultiPart);
|
callbackParameters, QByteArray(), requestMultiPart);
|
||||||
|
|
||||||
keypairGenerator->deleteLater();
|
keypairGenerator->deleteLater();
|
||||||
} else {
|
} else {
|
||||||
qCWarning(networking) << "Expected processGeneratedKeypair to be called by a live RSAKeypairGenerator"
|
qCWarning(networking) << "Expected processGeneratedKeypair to be called by a live RSAKeypairGenerator"
|
||||||
|
|
|
@ -32,25 +32,25 @@ PacketQueue::PacketPointer PacketQueue::takePacket() {
|
||||||
if (isEmpty()) {
|
if (isEmpty()) {
|
||||||
return PacketPointer();
|
return PacketPointer();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find next non empty channel
|
// Find next non empty channel
|
||||||
if (_channels[nextIndex()].empty()) {
|
if (_channels[nextIndex()].empty()) {
|
||||||
nextIndex();
|
nextIndex();
|
||||||
}
|
}
|
||||||
auto& channel = _channels[_currentIndex];
|
auto& channel = _channels[_currentIndex];
|
||||||
Q_ASSERT(!channel.empty());
|
Q_ASSERT(!channel.empty());
|
||||||
|
|
||||||
// Take front packet
|
// Take front packet
|
||||||
auto packet = std::move(channel.front());
|
auto packet = std::move(channel.front());
|
||||||
channel.pop_front();
|
channel.pop_front();
|
||||||
|
|
||||||
// Remove now empty channel (Don't remove the main channel)
|
// Remove now empty channel (Don't remove the main channel)
|
||||||
if (channel.empty() && _currentIndex != 0) {
|
if (channel.empty() && _currentIndex != 0) {
|
||||||
channel.swap(_channels.back());
|
channel.swap(_channels.back());
|
||||||
_channels.pop_back();
|
_channels.pop_back();
|
||||||
--_currentIndex;
|
--_currentIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ void PacketQueue::queuePacketList(PacketListPointer packetList) {
|
||||||
if (packetList->isOrdered()) {
|
if (packetList->isOrdered()) {
|
||||||
packetList->preparePackets(getNextMessageNumber());
|
packetList->preparePackets(getNextMessageNumber());
|
||||||
}
|
}
|
||||||
|
|
||||||
LockGuard locker(_packetsLock);
|
LockGuard locker(_packetsLock);
|
||||||
_channels.push_back(std::move(packetList->_packets));
|
_channels.push_back(std::move(packetList->_packets));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue