Skip to content

Commit

Permalink
Packed resources
Browse files Browse the repository at this point in the history
Dynamically load packed resources from a separate file. This
reduces amount of main memory required for linking stage.
  • Loading branch information
mymedia2 committed Dec 25, 2021
1 parent 4b03fd0 commit b986736
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
13 changes: 11 additions & 2 deletions Telegram/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ if (WIN32)
endif()

set_target_properties(Telegram PROPERTIES AUTOMOC ON)
target_prepare_qrc(Telegram)
if (LINUX)
# Do not repeat app name in path of a resource archive.
target_prepare_qrc(Telegram tresources.rcc)
else()
target_prepare_qrc(Telegram)
endif()

target_link_libraries(Telegram
PRIVATE
Expand Down Expand Up @@ -1528,7 +1533,11 @@ if (LINUX AND DESKTOP_APP_USE_PACKAGED)
include(GNUInstallDirs)
configure_file("../lib/xdg/telegramdesktop.metainfo.xml.in" "${CMAKE_CURRENT_BINARY_DIR}/telegramdesktop.metainfo.xml" @ONLY)
generate_appdata_changelog(Telegram "${CMAKE_SOURCE_DIR}/changelog.txt" "${CMAKE_CURRENT_BINARY_DIR}/telegramdesktop.metainfo.xml")
install(TARGETS Telegram RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" BUNDLE DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(TARGETS Telegram
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
BUNDLE DESTINATION "${CMAKE_INSTALL_BINDIR}"
RESOURCE DESTINATION "${CMAKE_INSTALL_DATADIR}/TelegramDesktop"
)
install(FILES "Resources/art/icon16.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/16x16/apps" RENAME "telegram.png")
install(FILES "Resources/art/icon32.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/32x32/apps" RENAME "telegram.png")
install(FILES "Resources/art/icon48.png" DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/icons/hicolor/48x48/apps" RENAME "telegram.png")
Expand Down
3 changes: 3 additions & 0 deletions Telegram/SourceFiles/platform/linux/launcher_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ For license and copyright information please follow this link:
*/
#include "platform/linux/launcher_linux.h"

#include "base/base_file_utilities.h"
#include "core/crash_reports.h"
#include "core/update_checker.h"
#include "webview/platform/linux/webview_linux_webkit2gtk.h"
Expand Down Expand Up @@ -82,6 +83,8 @@ void Launcher::initHook() {

return qsl(QT_STRINGIFY(TDESKTOP_LAUNCHER_BASENAME) ".desktop");
}());

base::RegisterResourceArchive(u"tresources.rcc"_q);
}

bool Launcher::launchUpdater(UpdaterLaunch action) {
Expand Down
2 changes: 1 addition & 1 deletion Telegram/SourceFiles/platform/mac/launcher_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
// macOS Retina display support is working fine, others are not.
QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling, false);

base::RegisterBundledResources(u"Telegram.rcc"_q);
base::RegisterResourceArchive(u"Telegram.rcc"_q);
}

bool Launcher::launchUpdater(UpdaterLaunch action) {
Expand Down

0 comments on commit b986736

Please sign in to comment.