From f1877641e57d49508fbb217c60ad441922c06470 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 6 Dec 2019 14:10:44 +0300 Subject: [PATCH] Closed alpha version 1.9.1.8: Fix macOS build. --- Telegram/CMakeLists.txt | 9 +----- Telegram/SourceFiles/core/version.h | 6 ++-- .../SourceFiles/ffmpeg/ffmpeg_utility.cpp | 8 +++--- Telegram/build/build.sh | 28 +++++++++++++------ Telegram/build/updates.py | 7 +++-- Telegram/cmake/lib_ffmpeg.cmake | 4 +++ Telegram/cmake/lib_tgvoip.cmake | 10 ++++++- Telegram/cmake/telegram_options.cmake | 8 ++++++ Telegram/configure.sh | 10 +++++++ Telegram/gyp/Telegram.gyp | 2 +- Telegram/gyp/lib_ffmpeg.gyp | 2 +- cmake | 2 +- 12 files changed, 65 insertions(+), 31 deletions(-) create mode 100755 Telegram/configure.sh diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index fb17c2565..d0a99a7c0 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -988,7 +988,7 @@ elseif (APPLE) set(strings_path ${res_loc}/langs/${lang}.lproj/Localizable.strings) set_source_files_properties(${strings_path} PROPERTIES MACOSX_PACKAGE_LOCATION - Resources/${lang}.lproj/Localizable.strings + Resources/${lang}.lproj ) target_sources(Telegram PRIVATE ${strings_path}) source_group(TREE ${res_loc} PREFIX Resources FILES ${strings_path}) @@ -1101,13 +1101,6 @@ PRIVATE AL_ALEXT_PROTOTYPES ) -if (disable_autoupdate) - target_compile_definitions(Telegram - PRIVATE - TDESKTOP_DISABLE_AUTOUPDATE - ) -endif() - if (${CMAKE_GENERATOR} MATCHES "(Visual Studio|Xcode|Ninja)") set(output_folder ${CMAKE_BINARY_DIR}) else() diff --git a/Telegram/SourceFiles/core/version.h b/Telegram/SourceFiles/core/version.h index 2591a8d73..2ab04e288 100644 --- a/Telegram/SourceFiles/core/version.h +++ b/Telegram/SourceFiles/core/version.h @@ -9,11 +9,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #define TDESKTOP_REQUESTED_ALPHA_VERSION (1009001008ULL) -#ifdef TDESKTOP_OFFICIAL_TARGET +#ifdef TDESKTOP_ALLOW_CLOSED_ALPHA #define TDESKTOP_ALPHA_VERSION TDESKTOP_REQUESTED_ALPHA_VERSION -#else // TDESKTOP_OFFICIAL_TARGET +#else // TDESKTOP_ALLOW_CLOSED_ALPHA #define TDESKTOP_ALPHA_VERSION (0ULL) -#endif // TDESKTOP_OFFICIAL_TARGET +#endif // TDESKTOP_ALLOW_CLOSED_ALPHA constexpr auto AppVersion = 1009001; constexpr auto AppVersionStr = "1.9.1"; diff --git a/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp b/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp index 6329bbddf..a03d191ca 100644 --- a/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp +++ b/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp @@ -12,9 +12,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include -#ifdef TDESKTOP_OFFICIAL_TARGET +#ifdef LIB_FFMPEG_USE_QT_PRIVATE_API #include -#endif // TDESKTOP_OFFICIAL_TARGET +#endif // LIB_FFMPEG_USE_QT_PRIVATE_API extern "C" { #include @@ -51,7 +51,7 @@ void UnPremultiplyLine(uchar *dst, const uchar *src, int intsCount) { [[maybe_unused]] const auto udst = reinterpret_cast(dst); const auto usrc = reinterpret_cast(src); -#ifndef TDESKTOP_OFFICIAL_TARGET +#ifndef LIB_FFMPEG_USE_QT_PRIVATE_API for (auto i = 0; i != intsCount; ++i) { udst[i] = qUnpremultiply(usrc[i]); } @@ -68,7 +68,7 @@ void PremultiplyLine(uchar *dst, const uchar *src, int intsCount) { const auto udst = reinterpret_cast(dst); [[maybe_unused]] const auto usrc = reinterpret_cast(src); -#ifndef TDESKTOP_OFFICIAL_TARGET +#ifndef LIB_FFMPEG_USE_QT_PRIVATE_API for (auto i = 0; i != intsCount; ++i) { udst[i] = qPremultiply(usrc[i]); } diff --git a/Telegram/build/build.sh b/Telegram/build/build.sh index 325d473b2..da5439714 100755 --- a/Telegram/build/build.sh +++ b/Telegram/build/build.sh @@ -52,13 +52,15 @@ if [ "$BuildTarget" == "linux" ]; then echo "Building version $AppVersionStrFull for Linux 64bit.." UpdateFile="tlinuxupd$AppVersion" SetupFile="tsetup.$AppVersionStrFull.tar.xz" - ReleasePath="$HomePath/../out/Release" + ProjectPath="$HomePath/../out" + ReleasePath="$ProjectPath/Release" BinaryName="Telegram" elif [ "$BuildTarget" == "linux32" ]; then echo "Building version $AppVersionStrFull for Linux 32bit.." UpdateFile="tlinux32upd$AppVersion" SetupFile="tsetup32.$AppVersionStrFull.tar.xz" - ReleasePath="$HomePath/../out/Release" + ProjectPath="$HomePath/../out" + ReleasePath="$ProjectPath/Release" BinaryName="Telegram" elif [ "$BuildTarget" == "mac" ]; then echo "Building version $AppVersionStrFull for macOS 10.12+.." @@ -67,13 +69,15 @@ elif [ "$BuildTarget" == "mac" ]; then fi UpdateFile="tmacupd$AppVersion" SetupFile="tsetup.$AppVersionStrFull.dmg" - ReleasePath="$HomePath/../out/Release" + ProjectPath="$HomePath/../out" + ReleasePath="$ProjectPath/Release" BinaryName="Telegram" elif [ "$BuildTarget" == "osx" ]; then echo "Building version $AppVersionStrFull for OS X 10.10 and 10.11.." UpdateFile="tosxupd$AppVersion" SetupFile="tsetup-osx.$AppVersionStrFull.dmg" - ReleasePath="$HomePath/../out/Release" + ProjectPath="$HomePath/../out" + ReleasePath="$ProjectPath/Release" BinaryName="Telegram" elif [ "$BuildTarget" == "macstore" ]; then if [ "$AlphaVersion" != "0" ]; then @@ -81,7 +85,8 @@ elif [ "$BuildTarget" == "macstore" ]; then fi echo "Building version $AppVersionStrFull for Mac App Store.." - ReleasePath="$HomePath/../out/Release" + ProjectPath="$HomePath/../out" + ReleasePath="$ProjectPath/Release" BinaryName="Telegram Desktop" else Error "Invalid target!" @@ -123,10 +128,12 @@ if [ "$BuildTarget" == "linux" ] || [ "$BuildTarget" == "linux32" ]; then Error "Backup folder not found!" fi - gyp/refresh.sh + ./configure.sh + cd $ProjectPath + cmake --build . --config Release --target Telegram -- -j8 cd $ReleasePath - make -j4 + echo "$BinaryName build complete!" if [ ! -f "$ReleasePath/$BinaryName" ]; then @@ -253,8 +260,11 @@ if [ "$BuildTarget" == "mac" ] || [ "$BuildTarget" == "osx" ] || [ "$BuildTarget Error "Backup path not found!" fi - gyp/refresh.sh - xcodebuild -project Telegram.xcodeproj -alltargets -configuration Release build + ./configure.sh + + cd $ProjectPath + cmake --build . --config Release --target Telegram + cd $ReleasePath if [ ! -d "$ReleasePath/$BinaryName.app" ]; then Error "$BinaryName.app not found!" diff --git a/Telegram/build/updates.py b/Telegram/build/updates.py index 8ffd5e96b..226db83de 100644 --- a/Telegram/build/updates.py +++ b/Telegram/build/updates.py @@ -51,15 +51,16 @@ if building: if os.path.exists('../out/Debug/' + outputFolder): finish(1, 'Todays updates version exists.') - result = subprocess.call('gyp/refresh.sh', shell=True) + result = subprocess.call('configure.sh', shell=True) if result != 0: finish(1, 'While calling GYP.') - result = subprocess.call('xcodebuild -project Telegram.xcodeproj -alltargets -configuration Debug build', shell=True) + os.chdir('../out') + result = subprocess.call('cmake --build . --config Debug --target Telegram', shell=True) if result != 0: finish(1, 'While building Telegram.') - os.chdir('../out/Debug') + os.chdir('Debug') if not os.path.exists('Telegram.app'): finish(1, 'Telegram.app not found.') diff --git a/Telegram/cmake/lib_ffmpeg.cmake b/Telegram/cmake/lib_ffmpeg.cmake index 596b3b29c..a9985392e 100644 --- a/Telegram/cmake/lib_ffmpeg.cmake +++ b/Telegram/cmake/lib_ffmpeg.cmake @@ -24,3 +24,7 @@ PUBLIC desktop-app::lib_base desktop-app::external_ffmpeg ) + +if (DESKTOP_APP_SPECIAL_TARGET) + target_compile_definitions(lib_ffmpeg PRIVATE LIB_FFMPEG_USE_QT_PRIVATE_API) +endif() diff --git a/Telegram/cmake/lib_tgvoip.cmake b/Telegram/cmake/lib_tgvoip.cmake index f6e82ecce..493597021 100644 --- a/Telegram/cmake/lib_tgvoip.cmake +++ b/Telegram/cmake/lib_tgvoip.cmake @@ -5,9 +5,17 @@ # https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL add_library(lib_tgvoip STATIC) -init_target(lib_tgvoip) +init_target(lib_tgvoip cxx_std_11) add_library(tdesktop::lib_tgvoip ALIAS lib_tgvoip) +if (NOT APPLE) + # On macOS if you build libtgvoip with C++17 it uses std::optional + # instead of absl::optional and when it uses optional::value, the + # build fails, because optional::value is available starting with + # macOS 10.14+. This way we force using absl::optional. + target_compile_features(lib_tgvoip PUBLIC cxx_std_17) +endif() + set(tgvoip_loc ${third_party_loc}/libtgvoip) nice_target_sources(lib_tgvoip ${tgvoip_loc} diff --git a/Telegram/cmake/telegram_options.cmake b/Telegram/cmake/telegram_options.cmake index 3630369ea..a29f75c91 100644 --- a/Telegram/cmake/telegram_options.cmake +++ b/Telegram/cmake/telegram_options.cmake @@ -51,6 +51,14 @@ else() target_link_libraries(Telegram PRIVATE desktop-app::lib_spellcheck) endif() +if (disable_autoupdate) + target_compile_definitions(Telegram PRIVATE TDESKTOP_DISABLE_AUTOUPDATE) +endif() + +if (DESKTOP_APP_SPECIAL_TARGET) + target_compile_definitions(Telegram PRIVATE TDESKTOP_ALLOW_CLOSED_ALPHA) +endif() + if (TDESKTOP_FORCE_GTK_FILE_DIALOG) target_compile_definitions(Telegram PRIVATE TDESKTOP_FORCE_GTK_FILE_DIALOG) endif() diff --git a/Telegram/configure.sh b/Telegram/configure.sh new file mode 100755 index 000000000..0f87909a1 --- /dev/null +++ b/Telegram/configure.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +set -e + +pushd `dirname $0` > /dev/null +FullScriptPath=`pwd` +popd > /dev/null + +python $FullScriptPath/configure.py "$@" + +exit diff --git a/Telegram/gyp/Telegram.gyp b/Telegram/gyp/Telegram.gyp index ac05463a9..cc113bdd4 100644 --- a/Telegram/gyp/Telegram.gyp +++ b/Telegram/gyp/Telegram.gyp @@ -130,7 +130,7 @@ ], }], [ '"<(special_build_target)" != ""', { 'defines': [ - 'TDESKTOP_OFFICIAL_TARGET=<(special_build_target)', + 'TDESKTOP_ALLOW_CLOSED_ALPHA', 'TDESKTOP_FORCE_GTK_FILE_DIALOG', ], 'dependencies': [ diff --git a/Telegram/gyp/lib_ffmpeg.gyp b/Telegram/gyp/lib_ffmpeg.gyp index 306da12f6..87359f865 100644 --- a/Telegram/gyp/lib_ffmpeg.gyp +++ b/Telegram/gyp/lib_ffmpeg.gyp @@ -42,7 +42,7 @@ ], 'conditions': [[ '"<(special_build_target)" != ""', { 'defines': [ - 'TDESKTOP_OFFICIAL_TARGET=<(special_build_target)', + 'LIB_FFMPEG_USE_QT_PRIVATE_API', ], }]], }], diff --git a/cmake b/cmake index 632ed315b..b1cf242c5 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit 632ed315b2054c65954b3d4818b4b5326a0933e8 +Subproject commit b1cf242c5f381defffcdd92f5044c33e8346ac8a