Added Guideline Support Library as a dependency.

See https://github.com/Microsoft/GSL for information.
This commit is contained in:
John Preston 2017-03-04 11:59:10 +03:00
parent 0838d21a05
commit 12bbd971b3
13 changed files with 78 additions and 20 deletions

View File

@ -28,6 +28,9 @@ GOTO:EOF
git clone -q --branch=master https://github.com/telegramdesktop/dependencies_windows.git %LIB_DIR%
cd %LIB_DIR%
call:logInfo "Clone GSL"
git clone https://github.com/Microsoft/GSL.git
call prepare.bat
GOTO:EOF

View File

@ -81,6 +81,9 @@ build() {
# Patched GYP (supports cmake precompiled headers)
getGYP
# Guideline Support Library
getGSL
# Configure the build
if [[ $BUILD_VERSION == *"disable_autoupdate"* ]]; then
GYP_DEFINES+=",TDESKTOP_DISABLE_AUTOUPDATE"
@ -539,6 +542,11 @@ buildCustomQt() {
sudo make install
}
getGSL() {
cd "$EXTERNAL"
git clone https://github.com/Microsoft/GSL.git
}
getGYP() {
travisStartFold "Getting patched GYP"
@ -594,6 +602,7 @@ buildTelegram() {
cd "$UPSTREAM/Telegram/gyp"
"$GYP_PATH/gyp" \
-Dbuild_defines=${GYP_DEFINES:1} \
-Dlinux_path_gsl=$EXTERNAL/GSL \
-Dlinux_path_xkbcommon=$XKB_PATH \
-Dlinux_path_va=$VA_PATH \
-Dlinux_path_vdpau=$VDPAU_PATH \

View File

@ -31,6 +31,7 @@ The source code is published under GPLv3 with OpenSSL exception, the license is
* OpenAL Soft ([LGPL](http://kcat.strangesoft.net/openal.html))
* Opus codec ([BSD license](http://www.opus-codec.org/license/))
* FFmpeg ([LGPL](https://www.ffmpeg.org/legal.html))
* Guideline Support Library ([MIT License](https://github.com/Microsoft/GSL/blob/master/LICENSE))
* Open Sans font ([Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0.html))
## Build instructions

View File

@ -24,6 +24,34 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
#include <array>
#include <algorithm>
#include <set>
#include <gsl/gsl>
// Release build assertions.
inline void t_noop() {
}
inline void t_assert_fail(const char *message, const char *file, int32 line) {
auto info = qsl("%1 %2:%3").arg(message).arg(file).arg(line);
LOG(("Assertion Failed! ") + info);
SignalHandlers::setCrashAnnotation("Assertion", info);
volatile int *t_assert_nullptr = nullptr;
*t_assert_nullptr = 0;
}
#define t_assert_full(condition, message, file, line) ((GSL_UNLIKELY(!(condition))) ? t_assert_fail(message, file, line) : t_noop())
#define t_assert_c(condition, comment) t_assert_full(condition, "\"" #condition "\" (" comment ")", __FILE__, __LINE__)
#define t_assert(condition) t_assert_full(condition, "\"" #condition "\"", __FILE__, __LINE__)
// Declare our own versions of Expects() and Ensures().
// Let them crash with reports and logging.
#ifdef Expects
#undef Expects
#define Expects(condition) t_assert_full(condition, "\"" #condition "\"", __FILE__, __LINE__)
#endif // Expects
#ifdef Ensures
#undef Ensures
#define Ensures(condition) t_assert_full(condition, "\"" #condition "\"", __FILE__, __LINE__)
#endif // Ensures
namespace base {
@ -133,6 +161,14 @@ using set_of_unique_ptr = std::set<std::unique_ptr<T>, base::pointer_comparator<
template <typename T>
using set_of_shared_ptr = std::set<std::shared_ptr<T>, base::pointer_comparator<T>>;
using byte_span = gsl::span<gsl::byte>;
using const_byte_span = gsl::span<const gsl::byte>;
inline void copy_bytes(byte_span destination, const_byte_span source) {
Expects(destination.size() >= source.size());
memcpy(destination.data(), source.data(), source.size());
}
} // namespace base
// using for_const instead of plain range-based for loop to ensure usage of const_iterator
@ -192,18 +228,6 @@ inline void accumulate_max(T &a, const T &b) { if (a < b) a = b; }
template <typename T>
inline void accumulate_min(T &a, const T &b) { if (a > b) a = b; }
static volatile int *t_assert_nullptr = nullptr;
inline void t_noop() {}
inline void t_assert_fail(const char *message, const char *file, int32 line) {
QString info(qsl("%1 %2:%3").arg(message).arg(file).arg(line));
LOG(("Assertion Failed! %1 %2:%3").arg(info));
SignalHandlers::setCrashAnnotation("Assertion", info);
*t_assert_nullptr = 0;
}
#define t_assert_full(condition, message, file, line) ((!(condition)) ? t_assert_fail(message, file, line) : t_noop())
#define t_assert_c(condition, comment) t_assert_full(condition, "\"" #condition "\" (" comment ")", __FILE__, __LINE__)
#define t_assert(condition) t_assert_full(condition, "\"" #condition "\"", __FILE__, __LINE__)
class Exception : public std::exception {
public:
Exception(const QString &msg, bool isFatal = true) : _fatal(isFatal), _msg(msg.toUtf8()) {

View File

@ -748,15 +748,13 @@ namespace internal {
};
std::unique_ptr<SomeAllocatedMemoryChunk> SomeAllocatedMemory;
void OperatorNewHandler() {
std::set_new_handler(nullptr);
SomeAllocatedMemory.reset();
t_assert(!"Could not allocate!");
}
void InstallOperatorNewHandler() {
SomeAllocatedMemory = std::make_unique<SomeAllocatedMemoryChunk>();
std::set_new_handler(OperatorNewHandler);
std::set_new_handler([] {
std::set_new_handler(nullptr);
SomeAllocatedMemory.reset();
t_assert(!"Could not allocate!");
});
}
Qt::HANDLE ReportingThreadId = nullptr;

View File

@ -4481,7 +4481,7 @@ DataIsLoadedResult allDataLoadedForMessage(const MTPMessage &msg) {
}
switch (d.vaction.type()) {
case mtpc_messageActionChatAddUser: {
for_const(const MTPint &userId, d.vaction.c_messageActionChatAddUser().vusers.c_vector().v) {
for_const (const MTPint &userId, d.vaction.c_messageActionChatAddUser().vusers.c_vector().v) {
if (!App::userLoaded(peerFromUser(userId))) {
return DataIsLoadedResult::NotLoaded;
}

View File

@ -94,6 +94,7 @@
'<(libs_loc)/openal-soft/include',
'<(minizip_loc)',
'<(sp_media_key_tap_loc)',
'<(libs_loc)/GSL/include',
],
'sources': [
'<@(qrc_files)',

View File

@ -33,12 +33,14 @@
'linux_path_va%': '/usr/local',
'linux_path_vdpau%': '/usr/local',
'linux_path_breakpad%': '<(libs_loc)/breakpad',
'linux_path_gsl%': '<(libs_loc)/GSL',
},
'include_dirs': [
'/usr/local/include',
'<(linux_path_ffmpeg)/include',
'<(linux_path_openal)/include',
'<(linux_path_breakpad)/include/breakpad',
'<(linux_path_gsl)/include',
],
'library_dirs': [
'/usr/local/lib',

View File

@ -29,6 +29,10 @@ Install dev libraries
sudo apt-get install libexif-dev liblzma-dev libz-dev libssl-dev libappindicator-dev libunity-dev libicu-dev libdee-dev
From **/home/user/TBuild/Libraries** run
git clone https://github.com/Microsoft/GSL.git
####zlib 1.2.8
http://www.zlib.net/ > Download [**zlib source code, version 1.2.8, zipfile format**](http://zlib.net/zlib128.zip)

View File

@ -51,6 +51,10 @@ and run
## Prepare libraries
From **D:\\TBuild\\Libraries** run
git clone https://github.com/Microsoft/GSL.git
### OpenSSL
Go to **D:\\TBuild\\Libraries** and run

View File

@ -32,6 +32,10 @@ Install dev libraries
sudo apt-get install libexif-dev liblzma-dev libz-dev libssl-dev libappindicator-dev libunity-dev
From **/home/user/TBuild/Libraries** run
git clone https://github.com/Microsoft/GSL.git
####zlib 1.2.8
http://www.zlib.net/ > Download [**zlib source code, version 1.2.8, zipfile format**](http://zlib.net/zlib128.zip)

View File

@ -32,6 +32,10 @@ In your build Terminal run
to set minimal supported OS version to 10.6 for future console builds.
From **/Users/user/TBuild/Libraries** run
git clone https://github.com/Microsoft/GSL.git
####custom build of libc++
From **/Users/user/TBuild/Libraries/macold** run

View File

@ -22,6 +22,10 @@ In your build Terminal run:
to set minimal supported OS version to 10.8 for future console builds.
From **/Users/user/TBuild/Libraries** run
git clone https://github.com/Microsoft/GSL.git
####zlib 1.2.8
http://www.zlib.net/ > Download [**zlib source code, version 1.2.8**](http://www.zlib.net/fossils/zlib-1.2.8.tar.gz)