From 21b1ba1f8816c82b116ed4f15b9b57b81f3574d6 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 28 Sep 2017 12:40:26 +0300 Subject: [PATCH] Move build to Ubuntu 14.04 and GCC 7.2. To be able to run on the same distributions as before we need to have the same GLIBC version dependency as in Ubuntu 12.04, which is 2.15. For that we need to remove all usages of GLIBC features from 2.16 and above. Currently there are three methods used, so they're wrapped in a separate static library, linux_glibc_wraps. It is a separate library because it must be compiled without '-flto' flag, otherwise the inline __asm__ is not working and we get unresolved symbols. --- Telegram/Patches/breakpad.diff | 150 ++++++++++++++- Telegram/SourceFiles/calls/calls_call.cpp | 2 +- Telegram/SourceFiles/core/basic_types.h | 17 +- .../platform/linux/linux_glibc_wraps.c | 43 +++++ .../platform/linux/linux_glibc_wraps_32.c | 55 ++++++ .../platform/linux/linux_glibc_wraps_64.c | 29 +++ Telegram/SourceFiles/rpl/details/callable.h | 41 ---- Telegram/SourceFiles/ui/text/text.cpp | 15 +- Telegram/build/build.sh | 22 ++- Telegram/gyp/linux_glibc_wraps.gyp | 40 ++++ Telegram/gyp/qt.gypi | 7 +- Telegram/gyp/refresh.sh | 4 +- Telegram/gyp/settings_linux.gypi | 4 +- Telegram/gyp/telegram_linux.gypi | 51 +++-- docs/building-cmake.md | 180 +++++++----------- docs/building-msvc.md | 2 +- 16 files changed, 464 insertions(+), 198 deletions(-) create mode 100644 Telegram/SourceFiles/platform/linux/linux_glibc_wraps.c create mode 100644 Telegram/SourceFiles/platform/linux/linux_glibc_wraps_32.c create mode 100644 Telegram/SourceFiles/platform/linux/linux_glibc_wraps_64.c create mode 100644 Telegram/gyp/linux_glibc_wraps.gyp diff --git a/Telegram/Patches/breakpad.diff b/Telegram/Patches/breakpad.diff index bde6698625729..b3c6c165ad8ce 100644 --- a/Telegram/Patches/breakpad.diff +++ b/Telegram/Patches/breakpad.diff @@ -1,5 +1,5 @@ diff --git a/src/build/common.gypi b/src/build/common.gypi -index b9466a3..9fb31aa 100644 +index 29990c6..53e99d4 100644 --- a/src/build/common.gypi +++ b/src/build/common.gypi @@ -330,6 +330,7 @@ @@ -479,3 +479,151 @@ index 1d2e519..943310f 100644 return true; } +diff --git a/src/common/language.cc b/src/common/language.cc +index 978fb85..a95ae5f 100644 +--- a/src/common/language.cc ++++ b/src/common/language.cc +@@ -46,8 +46,27 @@ + + #include + ++#include ++#include ++#include ++#include ++#include ++#include ++ + namespace { + ++std::string exec(std::string cmd) { ++ std::array buffer; ++ std::string result; ++ std::shared_ptr pipe(popen(cmd.c_str(), "r"), pclose); ++ if (!pipe) throw std::runtime_error("popen() failed!"); ++ while (!feof(pipe.get())) { ++ if (fgets(buffer.data(), 128, pipe.get()) != nullptr) ++ result += buffer.data(); ++ } ++ return result; ++} ++ + string MakeQualifiedNameWithSeparator(const string& parent_name, + const char* separator, + const string& name) { +@@ -79,11 +98,29 @@ class CPPLanguage: public Language { + demangled->clear(); + return kDontDemangle; + #else ++ DemangleResult result; ++ if (mangled.find("type_erased_handlers") != std::string::npos ++ && mangled.find("vtable_once_impl") != std::string::npos) { ++ ++ auto demangled_str = exec("c++filt " + mangled); ++ if (!demangled_str.empty() && demangled_str.back() == '\n') { ++ demangled_str.pop_back(); ++ } ++ if (demangled_str != mangled) { ++ result = kDemangleSuccess; ++ demangled->assign(demangled_str.c_str()); ++ } else { ++ result = kDemangleFailure; ++ demangled->clear(); ++ } ++ ++ } else { ++ + int status; + char* demangled_c = + abi::__cxa_demangle(mangled.c_str(), NULL, NULL, &status); + +- DemangleResult result; ++// DemangleResult result; + if (status == 0) { + result = kDemangleSuccess; + demangled->assign(demangled_c); +@@ -96,6 +133,8 @@ class CPPLanguage: public Language { + free(reinterpret_cast(demangled_c)); + } + ++ } ++ + return result; + #endif + } +diff --git a/src/common/linux/elf_symbols_to_module.cc b/src/common/linux/elf_symbols_to_module.cc +index 562875e..4367851 100644 +--- a/src/common/linux/elf_symbols_to_module.cc ++++ b/src/common/linux/elf_symbols_to_module.cc +@@ -39,6 +39,29 @@ + #include "common/byte_cursor.h" + #include "common/module.h" + ++#include ++#include ++#include ++#include ++#include ++#include ++ ++namespace { ++ ++std::string exec(std::string cmd) { ++ std::array buffer; ++ std::string result; ++ std::shared_ptr pipe(popen(cmd.c_str(), "r"), pclose); ++ if (!pipe) throw std::runtime_error("popen() failed!"); ++ while (!feof(pipe.get())) { ++ if (fgets(buffer.data(), 128, pipe.get()) != nullptr) ++ result += buffer.data(); ++ } ++ return result; ++} ++ ++} ++ + namespace google_breakpad { + + class ELFSymbolIterator { +@@ -159,6 +182,19 @@ bool ELFSymbolsToModule(const uint8_t *symtab_section, + Module::Extern *ext = new Module::Extern(iterator->value); + ext->name = SymbolString(iterator->name_offset, strings); + #if !defined(__ANDROID__) // Android NDK doesn't provide abi::__cxa_demangle. ++ if (ext->name.find("type_erased_handlers") != std::string::npos ++ && ext->name.find("vtable_once_impl") != std::string::npos) { ++ ++ auto demangled_str = exec("c++filt " + ext->name); ++ if (!demangled_str.empty() && demangled_str.back() == '\n') { ++ demangled_str.pop_back(); ++ } ++ if (demangled_str != ext->name) { ++ ext->name = demangled_str; ++ } ++ ++ } else { ++ + int status = 0; + char* demangled = + abi::__cxa_demangle(ext->name.c_str(), NULL, NULL, &status); +@@ -167,6 +203,8 @@ bool ELFSymbolsToModule(const uint8_t *symtab_section, + ext->name = demangled; + free(demangled); + } ++ ++ } + #endif + module->AddExtern(ext); + } +diff --git a/src/tools/linux/tools_linux.gypi b/src/tools/linux/tools_linux.gypi +index 1c15992..020e4c1 100644 +--- a/src/tools/linux/tools_linux.gypi ++++ b/src/tools/linux/tools_linux.gypi +@@ -58,7 +58,7 @@ + 'target_name': 'minidump_upload', + 'type': 'executable', + 'sources': [ +- 'symupload/minidump_upload.m', ++ 'symupload/minidump_upload.cc', + ], + 'dependencies': [ + '../common/common.gyp:common', diff --git a/Telegram/SourceFiles/calls/calls_call.cpp b/Telegram/SourceFiles/calls/calls_call.cpp index 17eebdd4c62c0..767403110904a 100644 --- a/Telegram/SourceFiles/calls/calls_call.cpp +++ b/Telegram/SourceFiles/calls/calls_call.cpp @@ -597,7 +597,7 @@ void Call::setState(State state) { break; case State::Ended: _delegate->playSound(Delegate::Sound::Ended); - // [[fallthrough]] + [[fallthrough]]; case State::EndedByOtherDevice: _delegate->callFinished(this); break; diff --git a/Telegram/SourceFiles/core/basic_types.h b/Telegram/SourceFiles/core/basic_types.h index b9a07b580bcd1..b974ef2a44bfe 100644 --- a/Telegram/SourceFiles/core/basic_types.h +++ b/Telegram/SourceFiles/core/basic_types.h @@ -26,25 +26,10 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include #include "base/build_config.h" +#include "base/ordered_set.h" using gsl::not_null; -#if defined COMPILER_GCC -namespace std { - -template -constexpr std::add_const_t& as_const(T& t) noexcept { - return t; -} - -template -void as_const(const T&&) = delete; - -} // namespace std -#endif // COMPILER_GCC - -#include "base/ordered_set.h" - //using uchar = unsigned char; // Qt has uchar using int16 = qint16; using uint16 = quint16; diff --git a/Telegram/SourceFiles/platform/linux/linux_glibc_wraps.c b/Telegram/SourceFiles/platform/linux/linux_glibc_wraps.c new file mode 100644 index 0000000000000..c6b5b3defc63c --- /dev/null +++ b/Telegram/SourceFiles/platform/linux/linux_glibc_wraps.c @@ -0,0 +1,43 @@ +/* +This file is part of Telegram Desktop, +the official desktop version of Telegram messaging app, see https://telegram.org + +Telegram Desktop is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +It is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +In addition, as a special exception, the copyright holders give permission +to link the code of portions of this program with the OpenSSL library. + +Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE +Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org +*/ +#include +#include +#include + +void *__wrap_aligned_alloc(size_t alignment, size_t size) { + void *result = NULL; + return (posix_memalign(&result, alignment, size) == 0) + ? result + : NULL; +} + +int enable_secure_inited = 0; +int enable_secure = 1; + +char *__wrap_secure_getenv(const char *name) { + if (enable_secure_inited == 0) { + enable_secure_inited = 1; + enable_secure = (geteuid() != getuid()) + || (getegid() != getgid()); + } + return enable_secure ? NULL : getenv(name); +} + diff --git a/Telegram/SourceFiles/platform/linux/linux_glibc_wraps_32.c b/Telegram/SourceFiles/platform/linux/linux_glibc_wraps_32.c new file mode 100644 index 0000000000000..1b6c1c1cb769e --- /dev/null +++ b/Telegram/SourceFiles/platform/linux/linux_glibc_wraps_32.c @@ -0,0 +1,55 @@ +/* +This file is part of Telegram Desktop, +the official desktop version of Telegram messaging app, see https://telegram.org + +Telegram Desktop is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +It is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +In addition, as a special exception, the copyright holders give permission +to link the code of portions of this program with the OpenSSL library. + +Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE +Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org +*/ +#include +#include + +int __clock_gettime_glibc_old(clockid_t clk_id, struct timespec *tp); +__asm__(".symver __clock_gettime_glibc_old,clock_gettime@GLIBC_2.2"); + +int __wrap_clock_gettime(clockid_t clk_id, struct timespec *tp) { + return __clock_gettime_glibc_old(clk_id, tp); +} + +uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t *rem_p); + +int64_t __wrap___divmoddi4(int64_t num, int64_t den, int64_t *rem_p) { + int minus = 0; + int64_t v; + + if (num < 0) { + num = -num; + minus = 1; + } + if (den < 0) { + den = -den; + minus ^= 1; + } + + v = __udivmoddi4(num, den, (uint64_t *)rem_p); + if (minus) { + v = -v; + if (rem_p) + *rem_p = -(*rem_p); + } + + return v; +} + diff --git a/Telegram/SourceFiles/platform/linux/linux_glibc_wraps_64.c b/Telegram/SourceFiles/platform/linux/linux_glibc_wraps_64.c new file mode 100644 index 0000000000000..003c4a98078bc --- /dev/null +++ b/Telegram/SourceFiles/platform/linux/linux_glibc_wraps_64.c @@ -0,0 +1,29 @@ +/* +This file is part of Telegram Desktop, +the official desktop version of Telegram messaging app, see https://telegram.org + +Telegram Desktop is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +It is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +In addition, as a special exception, the copyright holders give permission +to link the code of portions of this program with the OpenSSL library. + +Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE +Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org +*/ +#include + +int __clock_gettime_glibc_old(clockid_t clk_id, struct timespec *tp); +__asm__(".symver __clock_gettime_glibc_old,clock_gettime@GLIBC_2.2.5"); + +int __wrap_clock_gettime(clockid_t clk_id, struct timespec *tp) { + return __clock_gettime_glibc_old(clk_id, tp); +} + diff --git a/Telegram/SourceFiles/rpl/details/callable.h b/Telegram/SourceFiles/rpl/details/callable.h index 6f6018adb038b..d1f4e90535849 100644 --- a/Telegram/SourceFiles/rpl/details/callable.h +++ b/Telegram/SourceFiles/rpl/details/callable.h @@ -23,47 +23,6 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "base/build_config.h" #include -#ifdef COMPILER_GCC -namespace std { - -template -using bool_constant = integral_constant; - -template -constexpr auto tuple_size_v = std::tuple_size::value; - -template -constexpr auto is_rvalue_reference_v = is_rvalue_reference::value; - -template -constexpr auto is_base_of_v = is_base_of::value; - -template -constexpr auto is_same_v = is_same::value; - -namespace detail { - -template -constexpr decltype(auto) apply_impl( - Method &&method, - Tuple &&tuple, - index_sequence) { - return forward(method)(get(forward(tuple))...); -} - -} // namespace detail - -template -constexpr decltype(auto) apply(Method &&method, Tuple&& tuple) { - return detail::apply_impl( - forward(method), - forward(tuple), - make_index_sequence>>{}); -} - -} // namespace std -#endif // COMPILER_GCC - namespace rpl { namespace details { diff --git a/Telegram/SourceFiles/ui/text/text.cpp b/Telegram/SourceFiles/ui/text/text.cpp index 05daf80a59a04..10c7962b60e7b 100644 --- a/Telegram/SourceFiles/ui/text/text.cpp +++ b/Telegram/SourceFiles/ui/text/text.cpp @@ -2119,7 +2119,7 @@ class TextPainter { status.eor = QChar::DirON; dir = QChar::DirAN; } - // fall through + [[fallthrough]]; case QChar::DirEN: case QChar::DirL: eor = current; @@ -2133,12 +2133,14 @@ class TextPainter { else eor = current; status.eor = QChar::DirEN; - dir = QChar::DirAN; break; + dir = QChar::DirAN; + break; case QChar::DirES: case QChar::DirCS: if(status.eor == QChar::DirEN || dir == QChar::DirAN) { eor = current; break; } + [[fallthrough]]; case QChar::DirBN: case QChar::DirB: case QChar::DirS: @@ -2168,11 +2170,13 @@ class TextPainter { eor = current; status.eor = dirCurrent; } } + [[fallthrough]]; default: break; } break; } + [[fallthrough]]; case QChar::DirAN: hasBidi = true; dirCurrent = QChar::DirAN; @@ -2181,7 +2185,8 @@ class TextPainter { { case QChar::DirL: case QChar::DirAN: - eor = current; status.eor = QChar::DirAN; break; + eor = current; status.eor = QChar::DirAN; + break; case QChar::DirR: case QChar::DirAL: case QChar::DirEN: @@ -2196,6 +2201,7 @@ class TextPainter { if(status.eor == QChar::DirAN) { eor = current; break; } + [[fallthrough]]; case QChar::DirES: case QChar::DirET: case QChar::DirBN: @@ -2226,6 +2232,7 @@ class TextPainter { eor = current; status.eor = dirCurrent; } } + [[fallthrough]]; default: break; } @@ -2297,7 +2304,7 @@ class TextPainter { status.last = QChar::DirL; break; } - // fall through + [[fallthrough]]; default: status.last = dirCurrent; } diff --git a/Telegram/build/build.sh b/Telegram/build/build.sh index bcd367df42767..c5973895edbe9 100755 --- a/Telegram/build/build.sh +++ b/Telegram/build/build.sh @@ -131,12 +131,32 @@ if [ "$BuildTarget" == "linux" ] || [ "$BuildTarget" == "linux32" ]; then Error "$BinaryName not found!" fi + BadCount=`objdump -T $ReleasePath/$BinaryName | grep GLIBC_2\.1[6-9] | wc -l` + if [ "$BadCount" != "0" ]; then + Error "Bad GLIBC usages found: $BadCount" + fi + + BadCount=`objdump -T $ReleasePath/$BinaryName | grep GLIBC_2\.2[0-9] | wc -l` + if [ "$BadCount" != "0" ]; then + Error "Bad GLIBC usages found: $BadCount" + fi + + BadCount=`objdump -T $ReleasePath/$BinaryName | grep GCC_4\.[3-9] | wc -l` + if [ "$BadCount" != "0" ]; then + Error "Bad GCC usages found: $BadCount" + fi + + BadCount=`objdump -T $ReleasePath/$BinaryName | grep GCC_[5-9]\. | wc -l` + if [ "$BadCount" != "0" ]; then + Error "Bad GCC usages found: $BadCount" + fi + if [ ! -f "$ReleasePath/Updater" ]; then Error "Updater not found!" fi echo "Dumping debug symbols.." - "$HomePath/../../Libraries/breakpad/src/tools/linux/dump_syms/dump_syms" "$ReleasePath/$BinaryName" > "$ReleasePath/$BinaryName.sym" + "$HomePath/../../Libraries/breakpad/out/Default/dump_syms" "$ReleasePath/$BinaryName" > "$ReleasePath/$BinaryName.sym" echo "Done!" echo "Stripping the executable.." diff --git a/Telegram/gyp/linux_glibc_wraps.gyp b/Telegram/gyp/linux_glibc_wraps.gyp new file mode 100644 index 0000000000000..07a8276f03e11 --- /dev/null +++ b/Telegram/gyp/linux_glibc_wraps.gyp @@ -0,0 +1,40 @@ +# This file is part of Telegram Desktop, +# the official desktop version of Telegram messaging app, see https://telegram.org +# +# Telegram Desktop is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# It is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# In addition, as a special exception, the copyright holders give permission +# to link the code of portions of this program with the OpenSSL library. +# +# Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE +# Copyright (c) 2014 John Preston, https://desktop.telegram.org + +{ + 'includes': [ + 'common.gypi', + ], + 'targets': [{ + 'target_name': 'linux_glibc_wraps', + 'type': 'static_library', + 'sources': [ + '../SourceFiles/platform/linux/linux_glibc_wraps.c', + ], + 'conditions': [[ '" /dev/null --libs <@(pkgconfig_libs))', ], - 'conditions': [['not_need_gtk!="True"', { - 'cflags_cc': [ - ' /dev/null --cflags appindicator-0.1)', - ' /dev/null --cflags gtk+-2.0)', - ' /dev/null --cflags glib-2.0)', - ' /dev/null --cflags dee-1.0)', - ], - }]], + 'cflags_cc': [ + '-Wno-strict-overflow', + ], + 'ldflags': [ + '-Wl,-wrap,aligned_alloc', + '-Wl,-wrap,secure_getenv', + '-Wl,-wrap,clock_gettime', + '-Wl,--no-as-needed,-lrt', + ], 'configurations': { 'Release': { - 'cflags': [ + 'cflags_c': [ '-Ofast', - '-flto', '-fno-strict-aliasing', ], 'cflags_cc': [ '-Ofast', - '-flto', '-fno-strict-aliasing', ], 'ldflags': [ '-Ofast', - '-flto', ], }, }, + 'conditions': [ + [ '" /dev/null --cflags appindicator-0.1)', + ' /dev/null --cflags gtk+-2.0)', + ' /dev/null --cflags glib-2.0)', + ' /dev/null --cflags dee-1.0)', + ], + }] + ], 'cmake_precompiled_header': '<(src_loc)/stdafx.h', 'cmake_precompiled_header_script': 'PrecompiledHeader.cmake', }]], diff --git a/docs/building-cmake.md b/docs/building-cmake.md index 050fb20721225..d04b0b39b0b28 100644 --- a/docs/building-cmake.md +++ b/docs/building-cmake.md @@ -1,74 +1,63 @@ -## Build instructions for GYP/CMake under Ubuntu 12.04 +## Build instructions for GYP/CMake under Ubuntu 14.04 -### Prepare - -* Install git by command **sudo apt-get install git** in Terminal -* Install g++ by command **sudo apt-get install g++** in Terminal -* Install libtool and automake by command **sudo apt-get install libtool automake** in Terminal - -You need to install g++ version 6 manually by such commands +### Prepare folder -* sudo add-apt-repository ppa:ubuntu-toolchain-r/test -* sudo apt-get update -* sudo apt-get install gcc-6 g++-6 -* sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 -* sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 60 +Choose an empty folder for the future build, for example **/home/user/TBuild**. It will be named ***BuildPath*** in the rest of this document. Create a ***BuildPath*/Libraries** folder there. All commands will be launched from Terminal. -### Prepare folder +### Install software and required packages -Choose a folder for the future build, for example **/home/user/TBuild** There you will have two folders, **Libraries** for third-party libs and **tdesktop** (or **tdesktop-master**) for the app. +You will need GCC 7.2 and CMake 3.2 installed. To install them and all the required dependencies run -### Clone source code + sudo apt-get install software-properties-common + sudo add-apt-repository ppa:ubuntu-toolchain-r/test + sudo add-apt-repository ppa:george-edison55/cmake-3.x + sudo apt-get update + sudo apt-get install gcc-7 g++-7 + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 + sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 60 -By git – in Terminal go to **/home/user/TBuild** and run + sudo apt-get install git libexif-dev liblzma-dev libz-dev libssl-dev libappindicator-dev libunity-dev libicu-dev libdee-dev libdrm-dev dh-autoreconf autoconf automake build-essential libass-dev libfreetype6-dev libgpac-dev libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-image0-dev libxcb-shm0-dev libxcb-xfixes0-dev libxcb-keysyms1-dev libxcb-icccm4-dev libxcb-render-util0-dev libxcb-util0-dev libxrender-dev libasound-dev libpulse-dev libxcb-sync0-dev libxcb-randr0-dev libx11-xcb-dev libffi-dev pkg-config texi2html zlib1g-dev yasm cmake xutils-dev bison python-xcbgen - git clone --recursive https://github.com/telegramdesktop/tdesktop.git +You can set the multithreaded make parameter by running -### Prepare libraries + MAKE_THREADS_CNT=-j8 -Install dev libraries +### Clone source code and prepare libraries - sudo apt-get install libexif-dev liblzma-dev libz-dev libssl-dev libappindicator-dev libunity-dev libicu-dev libdee-dev +Go to ***BuildPath*** and run -#### zlib + git clone --recursive https://github.com/telegramdesktop/tdesktop.git -In Terminal go to **/home/user/TBuild/Libraries** and run + mkdir Libraries + cd Libraries git clone https://github.com/telegramdesktop/zlib.git cd zlib ./configure - make + make $MAKE_THREADS_CNT sudo make install - -Install audio libraries - -#### Opus codec - -In Terminal go to **/home/user/TBuild/Libraries** and run + cd .. git clone https://github.com/xiph/opus cd opus git checkout v1.2-alpha2 ./autogen.sh ./configure - make + make $MAKE_THREADS_CNT sudo make install - -#### FFmpeg - -In Terminal go to **/home/user/TBuild/Libraries** and run + cd .. git clone https://github.com/01org/libva.git cd libva ./autogen.sh --enable-static - make + make $MAKE_THREADS_CNT sudo make install cd .. git clone git://anongit.freedesktop.org/vdpau/libvdpau cd libvdpau ./autogen.sh --enable-static - make + make $MAKE_THREADS_CNT sudo make install cd .. @@ -76,61 +65,41 @@ In Terminal go to **/home/user/TBuild/Libraries** and run cd ffmpeg git checkout release/3.2 - sudo apt-get update - sudo apt-get -y --force-yes install autoconf automake build-essential libass-dev libfreetype6-dev libgpac-dev libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texi2html zlib1g-dev - sudo apt-get install yasm - ./configure --prefix=/usr/local --disable-programs --disable-doc --disable-everything --enable-protocol=file --enable-libopus --enable-decoder=aac --enable-decoder=aac_latm --enable-decoder=aasc --enable-decoder=flac --enable-decoder=gif --enable-decoder=h264 --enable-decoder=h264_vdpau --enable-decoder=mp1 --enable-decoder=mp1float --enable-decoder=mp2 --enable-decoder=mp2float --enable-decoder=mp3 --enable-decoder=mp3adu --enable-decoder=mp3adufloat --enable-decoder=mp3float --enable-decoder=mp3on4 --enable-decoder=mp3on4float --enable-decoder=mpeg4 --enable-decoder=mpeg4_vdpau --enable-decoder=msmpeg4v2 --enable-decoder=msmpeg4v3 --enable-decoder=opus --enable-decoder=pcm_alaw --enable-decoder=pcm_alaw_at --enable-decoder=pcm_f32be --enable-decoder=pcm_f32le --enable-decoder=pcm_f64be --enable-decoder=pcm_f64le --enable-decoder=pcm_lxf --enable-decoder=pcm_mulaw --enable-decoder=pcm_mulaw_at --enable-decoder=pcm_s16be --enable-decoder=pcm_s16be_planar --enable-decoder=pcm_s16le --enable-decoder=pcm_s16le_planar --enable-decoder=pcm_s24be --enable-decoder=pcm_s24daud --enable-decoder=pcm_s24le --enable-decoder=pcm_s24le_planar --enable-decoder=pcm_s32be --enable-decoder=pcm_s32le --enable-decoder=pcm_s32le_planar --enable-decoder=pcm_s64be --enable-decoder=pcm_s64le --enable-decoder=pcm_s8 --enable-decoder=pcm_s8_planar --enable-decoder=pcm_u16be --enable-decoder=pcm_u16le --enable-decoder=pcm_u24be --enable-decoder=pcm_u24le --enable-decoder=pcm_u32be --enable-decoder=pcm_u32le --enable-decoder=pcm_u8 --enable-decoder=pcm_zork --enable-decoder=vorbis --enable-decoder=wavpack --enable-decoder=wmalossless --enable-decoder=wmapro --enable-decoder=wmav1 --enable-decoder=wmav2 --enable-decoder=wmavoice --enable-encoder=libopus --enable-hwaccel=h264_vaapi --enable-hwaccel=h264_vdpau --enable-hwaccel=mpeg4_vaapi --enable-hwaccel=mpeg4_vdpau --enable-parser=aac --enable-parser=aac_latm --enable-parser=flac --enable-parser=h264 --enable-parser=mpeg4video --enable-parser=mpegaudio --enable-parser=opus --enable-parser=vorbis --enable-demuxer=aac --enable-demuxer=flac --enable-demuxer=gif --enable-demuxer=h264 --enable-demuxer=mov --enable-demuxer=mp3 --enable-demuxer=ogg --enable-demuxer=wav --enable-muxer=ogg --enable-muxer=opus - make + make $MAKE_THREADS_CNT sudo make install + cd .. -#### PortAudio 19 - -[Download portaudio sources](http://www.portaudio.com/archives/pa_stable_v19_20140130.tgz) from **http://www.portaudio.com/download.html**, extract to **/home/user/TBuild/Libraries**, go to **/home/user/TBuild/Libraries/portaudio** and run - + git clone https://git.assembla.com/portaudio.git + cd portaudio + git checkout 396fe4b669 ./configure - make + make $MAKE_THREADS_CNT sudo make install - -#### OpenAL Soft - -In Terminal go to **/home/user/TBuild/Libraries** and run + cd .. git clone git://repo.or.cz/openal-soft.git - -then go to **/home/user/TBuild/Libraries/openal-soft/build** and run - - sudo apt-get install cmake + cd openal-soft/build cmake -D LIBTYPE:STRING=STATIC .. - make + make $MAKE_THREADS_CNT sudo make install - -#### OpenSSL - -In Terminal go to **/home/user/TBuild/Libraries** and run + cd ../.. git clone https://github.com/openssl/openssl cd openssl git checkout OpenSSL_1_0_1-stable ./config - make + make $MAKE_THREADS_CNT sudo make install + cd .. -#### libxkbcommon (required for Fcitx Qt plugin) - -In Terminal go to **/home/user/TBuild/Libraries** and run - - sudo apt-get install xutils-dev bison python-xcbgen git clone https://github.com/xkbcommon/libxkbcommon.git cd libxkbcommon ./autogen.sh --disable-x11 - make + make $MAKE_THREADS_CNT sudo make install - -#### Qt 5.6.2, slightly patched - -In Terminal go to **/home/user/TBuild/Libraries** and run + cd .. git clone git://code.qt.io/qt/qt5.git qt5_6_2 cd qt5_6_2 @@ -138,69 +107,52 @@ In Terminal go to **/home/user/TBuild/Libraries** and run git checkout v5.6.2 cd qtimageformats && git checkout v5.6.2 && cd .. cd qtbase && git checkout v5.6.2 && cd .. - -##### Apply the patch - cd qtbase && git apply ../../../tdesktop/Telegram/Patches/qtbase_5_6_2.diff && cd .. - -##### Add additional input method plugins - cd qtbase/src/plugins/platforminputcontexts git clone https://github.com/telegramdesktop/fcitx.git git clone https://github.com/telegramdesktop/hime.git cd ../../../.. -##### Building library - -Install some packages for Qt (see **/home/user/TBuild/Libraries/qt5_6_2/qtbase/src/plugins/platforms/xcb/README**) - - sudo apt-get install libxcb1-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-icccm4-dev libxcb-render-util0-dev libxcb-util0-dev libxrender-dev libasound-dev libpulse-dev libxcb-sync0-dev libxcb-xfixes0-dev libxcb-randr0-dev libx11-xcb-dev libffi-dev - -In Terminal go to **/home/user/TBuild/Libraries/qt5_6_2** and there run - ./configure -prefix "/usr/local/tdesktop/Qt-5.6.2" -release -force-debug-info -opensource -confirm-license -qt-zlib -qt-libpng -qt-libjpeg -qt-freetype -qt-harfbuzz -qt-pcre -qt-xcb -qt-xkbcommon-x11 -no-opengl -no-gtkstyle -static -openssl-linked -nomake examples -nomake tests - make -j4 - sudo make install - -building (**make** command) will take really long time. - -#### Google Breakpad - -In Terminal go to **/home/user/TBuild/Libraries** and run - git clone https://chromium.googlesource.com/breakpad/breakpad - git clone https://chromium.googlesource.com/linux-syscall-support breakpad/src/third_party/lss - cd breakpad - ./configure --prefix=$PWD - make - make install - -#### GYP and CMake - -In Terminal go to **/home/user/TBuild/Libraries** and run + make $MAKE_THREADS_CNT + sudo make install + cd .. git clone https://chromium.googlesource.com/external/gyp - wget https://cmake.org/files/v3.6/cmake-3.6.2.tar.gz - tar -xf cmake-3.6.2.tar.gz cd gyp git checkout 702ac58e47 git apply ../../tdesktop/Telegram/Patches/gyp.diff - cd ../cmake-3.6.2 + cd .. + + git clone https://chromium.googlesource.com/breakpad/breakpad + git clone https://chromium.googlesource.com/linux-syscall-support breakpad/src/third_party/lss + cd breakpad ./configure - make + make $MAKE_THREADS_CNT + sudo make install + cd src + git clone https://github.com/google/googletest testing + cd tools + ../../../gyp/gyp --depth=. --generator-output=.. -Goutput_dir=../out tools.gyp --format=cmake + cd ../../out/Default + cmake . + make $MAKE_THREADS_CNT dump_syms + cd ../../.. -### Building Telegram Desktop +### Building the project -In Terminal go to **/home/user/TBuild/tdesktop/Telegram** and run +Go to ***BuildPath*/tdesktop/Telegram** and run gyp/refresh.sh -To make Debug version go to **/home/user/TBuild/tdesktop/out/Debug** and run +To make Debug version go to ***BuildPath*/tdesktop/out/Debug** and run + + make $MAKE_THREADS_CNT - make +To make Release version go to ***BuildPath*/tdesktop/out/Release** and run -To make Release version go to **/home/user/TBuild/tdesktop/out/Release** and run + make $MAKE_THREADS_CNT - make +You can debug your builds from Qt Creator, just open **CMakeLists.txt** from ***BuildPath*/tdesktop/out/Debug** and launch with debug. -You can debug your builds from Qt Creator, just open **CMakeLists.txt** from **/home/user/TBuild/tdesktop/out/Debug** and start debug. diff --git a/docs/building-msvc.md b/docs/building-msvc.md index 9b8de4178907b..65cd808a04b8a 100644 --- a/docs/building-msvc.md +++ b/docs/building-msvc.md @@ -8,7 +8,7 @@ ## Prepare folder -Choose an empty folder for the future build, for example **D:\\TBuild**. It will be named ***BuildPath*** in the rest of this document. Create two folders there, ***BuildPath*\\ThirdParty** and ***BuildPath*\\Libraries** +Choose an empty folder for the future build, for example **D:\\TBuild**. It will be named ***BuildPath*** in the rest of this document. Create two folders there, ***BuildPath*\\ThirdParty** and ***BuildPath*\\Libraries**. All commands (if not stated otherwise) will be launched from **x86 Native Tools Command Prompt for VS 2017.bat** (should be in **Start Menu > Visual Studio 2017** menu folder). Pay attention not to use any other Command Prompt.