From 7e418a16aee02509257bf89459d3d2c45db2a072 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sun, 1 Jun 2025 06:29:08 +0000 Subject: [PATCH] Fix packaged conditions in lib_ffmpeg and Packer --- Telegram/CMakeLists.txt | 4 ++++ Telegram/SourceFiles/_other/packer.cpp | 2 +- Telegram/SourceFiles/_other/packer.h | 2 +- Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp | 14 +++++++------- Telegram/cmake/lib_ffmpeg.cmake | 4 ++++ 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index 2a86806efa..82dbdfd5b3 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -1989,6 +1989,10 @@ if (NOT DESKTOP_APP_DISABLE_AUTOUPDATE AND NOT build_macstore AND NOT build_wins desktop-app::external_openssl ) + if (DESKTOP_APP_USE_PACKAGED) + target_compile_definitions(Packer PRIVATE PACKER_USE_PACKAGED) + endif() + set_target_properties(Packer PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${output_folder}) endif() elseif (build_winstore) diff --git a/Telegram/SourceFiles/_other/packer.cpp b/Telegram/SourceFiles/_other/packer.cpp index e563e16753..4df8b23800 100644 --- a/Telegram/SourceFiles/_other/packer.cpp +++ b/Telegram/SourceFiles/_other/packer.cpp @@ -283,7 +283,7 @@ int main(int argc, char *argv[]) cout << "Compression start, size: " << resultSize << "\n"; QByteArray compressed, resultCheck; -#if defined Q_OS_WIN && !defined TDESKTOP_USE_PACKAGED // use Lzma SDK for win +#if defined Q_OS_WIN && !defined PACKER_USE_PACKAGED // use Lzma SDK for win const int32 hSigLen = 128, hShaLen = 20, hPropsLen = LZMA_PROPS_SIZE, hOriginalSizeLen = sizeof(int32), hSize = hSigLen + hShaLen + hPropsLen + hOriginalSizeLen; // header compressed.resize(hSize + resultSize + 1024 * 1024); // rsa signature + sha1 + lzma props + max compressed size diff --git a/Telegram/SourceFiles/_other/packer.h b/Telegram/SourceFiles/_other/packer.h index 4e5fbfc7ac..2c200eefd7 100644 --- a/Telegram/SourceFiles/_other/packer.h +++ b/Telegram/SourceFiles/_other/packer.h @@ -27,7 +27,7 @@ extern "C" { #include } // extern "C" -#if defined Q_OS_WIN && !defined TDESKTOP_USE_PACKAGED // use Lzma SDK for win +#if defined Q_OS_WIN && !defined PACKER_USE_PACKAGED // use Lzma SDK for win #include #else #include diff --git a/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp b/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp index 3811cbc860..5c489596e5 100644 --- a/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp +++ b/Telegram/SourceFiles/ffmpeg/ffmpeg_utility.cpp @@ -10,10 +10,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/algorithm.h" #include "logs.h" -#if !defined TDESKTOP_USE_PACKAGED && !defined Q_OS_WIN && !defined Q_OS_MAC +#ifdef LIB_FFMPEG_USE_IMPLIB #include "base/platform/linux/base_linux_library.h" #include -#endif // !TDESKTOP_USE_PACKAGED && !Q_OS_WIN && !Q_OS_MAC +#endif // LIB_FFMPEG_USE_IMPLIB #include @@ -91,7 +91,7 @@ void PremultiplyLine(uchar *dst, const uchar *src, int intsCount) { #endif // LIB_FFMPEG_USE_QT_PRIVATE_API } -#if !defined TDESKTOP_USE_PACKAGED && !defined Q_OS_WIN && !defined Q_OS_MAC +#ifdef LIB_FFMPEG_USE_IMPLIB [[nodiscard]] auto CheckHwLibs() { auto list = std::deque{ AV_PIX_FMT_CUDA, @@ -117,7 +117,7 @@ void PremultiplyLine(uchar *dst, const uchar *src, int intsCount) { } return list; } -#endif // !TDESKTOP_USE_PACKAGED && !Q_OS_WIN && !Q_OS_MAC +#endif // LIB_FFMPEG_USE_IMPLIB [[nodiscard]] bool InitHw(AVCodecContext *context, AVHWDeviceType type) { AVCodecContext *parent = static_cast(context->opaque); @@ -160,9 +160,9 @@ void PremultiplyLine(uchar *dst, const uchar *src, int intsCount) { } return false; }; -#if !defined TDESKTOP_USE_PACKAGED && !defined Q_OS_WIN && !defined Q_OS_MAC +#ifdef LIB_FFMPEG_USE_IMPLIB static const auto list = CheckHwLibs(); -#else // !TDESKTOP_USE_PACKAGED && !Q_OS_WIN && !Q_OS_MAC +#else // LIB_FFMPEG_USE_IMPLIB const auto list = std::array{ #ifdef Q_OS_WIN AV_PIX_FMT_D3D11, @@ -176,7 +176,7 @@ void PremultiplyLine(uchar *dst, const uchar *src, int intsCount) { AV_PIX_FMT_CUDA, #endif // Q_OS_WIN || Q_OS_MAC }; -#endif // TDESKTOP_USE_PACKAGED || Q_OS_WIN || Q_OS_MAC +#endif // LIB_FFMPEG_USE_IMPLIB for (const auto format : list) { if (!has(format)) { continue; diff --git a/Telegram/cmake/lib_ffmpeg.cmake b/Telegram/cmake/lib_ffmpeg.cmake index 0da37cb096..c48a900b99 100644 --- a/Telegram/cmake/lib_ffmpeg.cmake +++ b/Telegram/cmake/lib_ffmpeg.cmake @@ -29,6 +29,10 @@ PUBLIC desktop-app::external_ffmpeg ) +if (LINUX AND NOT DESKTOP_APP_USE_PACKAGED) + target_compile_definitions(lib_ffmpeg PRIVATE LIB_FFMPEG_USE_IMPLIB) +endif() + if (DESKTOP_APP_SPECIAL_TARGET) target_compile_definitions(lib_ffmpeg PRIVATE LIB_FFMPEG_USE_QT_PRIVATE_API) endif()