1
0
Fork 0

Updated cmake sources to TDesktop version 2.7.10+5519bb35

This commit is contained in:
Eric Kotato 2021-06-25 22:55:11 +03:00
commit 10efb6461f
27 changed files with 1398 additions and 318 deletions

View file

@ -8,3 +8,11 @@ add_subdirectory(external)
if (DESKTOP_APP_USE_GLIBC_WRAPS)
add_subdirectory(linux_glibc_wraps)
endif()
if (LINUX
AND NOT DESKTOP_APP_USE_PACKAGED
AND Qt5WaylandClient_FOUND)
add_subdirectory(linux_wayland_helper)
endif()
if (DESKTOP_APP_USE_ALLOCATION_TRACER)
add_subdirectory(linux_allocation_tracer)
endif()

View file

@ -41,6 +41,9 @@ if (LINUX AND NOT DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION)
add_checked_subdirectory(kwayland)
endif()
add_checked_subdirectory(lz4)
if (LINUX)
add_checked_subdirectory(mallocng)
endif()
add_checked_subdirectory(minizip)
if (LINUX)
add_checked_subdirectory(nimf_qt5)
@ -49,22 +52,16 @@ add_checked_subdirectory(openal)
add_checked_subdirectory(openssl)
add_checked_subdirectory(opus)
add_checked_subdirectory(qt)
if (LINUX)
add_checked_subdirectory(qt5ct_support)
endif()
add_checked_subdirectory(qr_code_generator)
add_checked_subdirectory(ranges)
add_checked_subdirectory(rlottie)
if (APPLE)
add_checked_subdirectory(sp_media_key_tap)
endif()
add_checked_subdirectory(rnnoise)
if (LINUX AND NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION)
add_checked_subdirectory(statusnotifieritem)
endif()
add_checked_subdirectory(ton)
add_checked_subdirectory(variant)
add_checked_subdirectory(webrtc)
add_checked_subdirectory(webview)
if (LINUX AND NOT DESKTOP_APP_DISABLE_X11_INTEGRATION)
add_checked_subdirectory(xcb)
endif()

View file

@ -34,7 +34,7 @@ else()
)
find_package(PkgConfig REQUIRED)
pkg_search_module(GTK REQUIRED gtk+-2.0 gtk+-3.0)
pkg_check_modules(GTK REQUIRED gtk+-3.0)
target_include_directories(external_hime_im_client
PUBLIC
@ -52,6 +52,7 @@ else()
UNIX=1
FREEBSD=0
CLIENT_LIB=1
GTK_DISABLE_DEPRECATED
)
target_link_libraries(external_hime_im_client

View file

@ -25,14 +25,10 @@ else()
/usr/local/include/KF5/KWayland/Client
)
target_link_static_libraries(external_kwayland
INTERFACE
wayland-client
ffi
)
target_link_libraries(external_kwayland
INTERFACE
desktop-app::linux_wayland_helper
$<TARGET_FILE:desktop-app::linux_wayland_helper>
${qt_loc}/lib/libQt5Concurrent.a
desktop-app::external_qt
)

46
external/mallocng/CMakeLists.txt vendored Normal file
View file

@ -0,0 +1,46 @@
# This file is part of Desktop App Toolkit,
# a set of libraries for developing nice desktop applications.
#
# For license and copyright information please follow this link:
# https://github.com/desktop-app/legal/blob/master/LEGAL
add_library(external_mallocng INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_mallocng ALIAS external_mallocng)
add_library(external_mallocng_bundled STATIC)
init_target(external_mallocng_bundled "(external)")
set(mallocng_loc ${third_party_loc}/mallocng)
nice_target_sources(external_mallocng_bundled ${mallocng_loc}
PRIVATE
malloc.c
calloc.c
free.c
realloc.c
aligned_alloc.c
posix_memalign.c
memalign.c
malloc_usable_size.c
meta.h
glue.h
valloc.c
pvalloc.c
)
target_compile_options(external_mallocng_bundled
PRIVATE
-Wno-unused-value
)
target_include_directories(external_mallocng_bundled
PRIVATE
${mallocng_loc}
)
target_link_libraries(external_mallocng
INTERFACE
-Wl,--whole-archive
external_mallocng_bundled
-Wl,--no-whole-archive
)

View file

@ -28,35 +28,6 @@ if (DESKTOP_APP_USE_PACKAGED)
target_link_libraries(external_qt INTERFACE Qt5::DBus)
endif()
if (LINUX AND DESKTOP_APP_USE_PACKAGED_LAZY_PLATFORMTHEMES)
find_library(Qt5ThemeSupport_LIBRARY
NAMES
Qt5ThemeSupport
REQUIRED
)
find_path(Qt5ThemeSupport_INCLUDE_DIR
NAMES
QtThemeSupport/private/qgenericunixthemes_p.h
HINTS
${Qt5Gui_INCLUDE_DIRS}
PATH_SUFFIXES
QtThemeSupport/${Qt5Gui_VERSION}
REQUIRED
)
target_link_libraries(external_qt
INTERFACE
${Qt5ThemeSupport_LIBRARY}
)
target_include_directories(external_qt
INTERFACE
${Qt5ThemeSupport_INCLUDE_DIR}
${Qt5ThemeSupport_INCLUDE_DIR}/QtThemeSupport
)
endif()
if (Qt5XkbCommonSupport_FOUND)
target_link_libraries(external_qt INTERFACE Qt5::XkbCommonSupport)
@ -69,18 +40,10 @@ if (DESKTOP_APP_USE_PACKAGED)
if (Qt5WaylandClient_FOUND)
target_link_libraries(external_qt INTERFACE Qt5::WaylandClient)
if (DESKTOP_APP_QTWAYLANDCLIENT_PRIVATE_HEADERS)
target_include_directories(external_qt
INTERFACE
${DESKTOP_APP_QTWAYLANDCLIENT_PRIVATE_HEADERS}
${DESKTOP_APP_QTWAYLANDCLIENT_PRIVATE_HEADERS}/QtWaylandClient
)
else()
target_include_directories(external_qt
INTERFACE
${Qt5WaylandClient_PRIVATE_INCLUDE_DIRS}
)
endif()
target_include_directories(external_qt
INTERFACE
${Qt5WaylandClient_PRIVATE_INCLUDE_DIRS}
)
endif()
else()
target_include_directories(external_qt SYSTEM
@ -120,15 +83,6 @@ else()
)
endif()
if (LINUX)
target_include_directories(external_qt SYSTEM
INTERFACE
${qt_loc}/include/QtThemeSupport
${qt_loc}/include/QtThemeSupport/${qt_version}
${qt_loc}/include/QtThemeSupport/${qt_version}/QtThemeSupport
)
endif()
target_compile_definitions(external_qt
INTERFACE
_REENTRANT
@ -161,13 +115,6 @@ else()
)
endif()
if (LINUX)
target_compile_definitions(external_qt
INTERFACE
QT_THEME_SUPPORT_LIB
)
endif()
if (WIN32)
set(qt_lib_prefix "")
set(qt_lib_suffix $<$<CONFIG:Debug>:d>.lib)
@ -255,7 +202,6 @@ else()
set(qt_libs_dbus_support lib/${qt_lib_prefix}Qt5LinuxAccessibilitySupport)
set(qt_libs_dbus_plugins
plugins/platforminputcontexts/${qt_lib_prefix}ibusplatforminputcontextplugin
plugins/platformthemes/${qt_lib_prefix}qxdgdesktopportal
)
set(qt_libs_dbus_bearers
plugins/bearer/${qt_lib_prefix}qconnmanbearer
@ -267,12 +213,11 @@ else()
if (Qt5WaylandClient_FOUND)
set(qt_libs_waylandclient lib/${qt_lib_prefix}Qt5WaylandClient)
set(qt_libs_waylandclient_plugins
plugins/wayland-decoration-client/${qt_lib_prefix}bradient
plugins/wayland-shell-integration/${qt_lib_prefix}wl-shell
plugins/wayland-shell-integration/${qt_lib_prefix}xdg-shell
plugins/wayland-graphics-integration-client/${qt_lib_prefix}qt-plugin-wayland-egl
plugins/platforms/${qt_lib_prefix}qwayland-egl
plugins/platforms/${qt_lib_prefix}qwayland-generic
plugins/platforms/${qt_lib_prefix}qwayland-egl
plugins/wayland-graphics-integration-client/${qt_lib_prefix}qt-plugin-wayland-egl
plugins/wayland-shell-integration/${qt_lib_prefix}wl-shell
plugins/wayland-decoration-client/${qt_lib_prefix}bradient
)
endif()
set(qt_libs
@ -325,6 +270,23 @@ else()
-pthread
-rdynamic
)
if (DESKTOP_APP_USE_ALLOCATION_TRACER)
target_link_options(external_qt
INTERFACE
# -Wl,-wrap,__malloc
-Wl,-wrap,__libc_malloc
-Wl,-wrap,malloc
-Wl,-wrap,valloc
-Wl,-wrap,pvalloc
-Wl,-wrap,calloc
-Wl,-wrap,realloc
-Wl,-wrap,memalign
-Wl,-wrap,aligned_alloc
-Wl,-wrap,posix_memalign
-Wl,-wrap,free
-Wl,--no-as-needed,-lrt
)
endif()
if (DESKTOP_APP_USE_GLIBC_WRAPS)
target_link_options(external_qt
INTERFACE
@ -347,9 +309,7 @@ else()
endif()
target_link_static_libraries(external_qt
INTERFACE
wayland-egl
wayland-cursor
wayland-client
proxy
xkbcommon
xkbcommon-x11
xcb-glx
@ -367,8 +327,14 @@ else()
xcb-util
xcb-render-util
xcb-keysyms
ffi
)
if (DESKTOP_APP_USE_ALLOCATION_TRACER)
target_link_libraries(external_qt
INTERFACE
desktop-app::linux_allocation_tracer
$<TARGET_FILE:desktop-app::linux_allocation_tracer>
)
endif()
if (DESKTOP_APP_USE_GLIBC_WRAPS)
target_link_libraries(external_qt
INTERFACE
@ -376,6 +342,13 @@ else()
$<TARGET_FILE:desktop-app::linux_glibc_wraps>
)
endif()
if (Qt5WaylandClient_FOUND)
target_link_libraries(external_qt
INTERFACE
desktop-app::linux_wayland_helper
$<TARGET_FILE:desktop-app::linux_wayland_helper>
)
endif()
target_link_libraries(external_qt
INTERFACE
fontconfig

View file

@ -22,7 +22,6 @@ if (LINUX)
target_link_libraries(external_qt_static_plugins
PUBLIC
desktop-app::external_nimf_qt5
desktop-app::external_qt5ct_support
)
if (NOT DESKTOP_APP_DISABLE_DBUS_INTEGRATION)

View file

@ -31,15 +31,13 @@ Q_IMPORT_PLUGIN(QSvgIconPlugin)
Q_IMPORT_PLUGIN(QConnmanEnginePlugin)
Q_IMPORT_PLUGIN(QNetworkManagerEnginePlugin)
Q_IMPORT_PLUGIN(QIbusPlatformInputContextPlugin)
Q_IMPORT_PLUGIN(QXdgDesktopPortalThemePlugin)
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
#ifndef DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION
Q_IMPORT_PLUGIN(QWaylandEglClientBufferPlugin)
Q_IMPORT_PLUGIN(QWaylandWlShellIntegrationPlugin)
Q_IMPORT_PLUGIN(QWaylandXdgShellIntegrationPlugin)
Q_IMPORT_PLUGIN(QWaylandBradientDecorationPlugin)
Q_IMPORT_PLUGIN(QWaylandIntegrationPlugin)
Q_IMPORT_PLUGIN(QWaylandEglPlatformIntegrationPlugin)
Q_IMPORT_PLUGIN(QWaylandEglClientBufferPlugin)
Q_IMPORT_PLUGIN(QWaylandWlShellIntegrationPlugin)
Q_IMPORT_PLUGIN(QWaylandBradientDecorationPlugin)
#endif // !DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION
#endif // Q_OS_WIN | Q_OS_MAC | Q_OS_UNIX
#endif // !DESKTOP_APP_USE_PACKAGED
@ -55,9 +53,4 @@ Q_IMPORT_PLUGIN(QFcitx5PlatformInputContextPlugin)
Q_IMPORT_PLUGIN(QHimePlatformInputContextPlugin)
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
#endif // !DESKTOP_APP_USE_PACKAGED || DESKTOP_APP_USE_PACKAGED_LAZY
#if !defined DESKTOP_APP_USE_PACKAGED || defined DESKTOP_APP_USE_PACKAGED_LAZY_PLATFORMTHEMES
Q_IMPORT_PLUGIN(Qt5CTPlatformThemePlugin)
Q_IMPORT_PLUGIN(Qt5CTStylePlugin)
#endif // !DESKTOP_APP_USE_PACKAGED || DESKTOP_APP_USE_PACKAGED_LAZY_PLATFORMTHEMES
#endif // Q_OS_UNIX && !Q_OS_MAC

View file

@ -1,18 +0,0 @@
# This file is part of Desktop App Toolkit,
# a set of libraries for developing nice desktop applications.
#
# For license and copyright information please follow this link:
# https://github.com/desktop-app/legal/blob/master/LEGAL
add_library(external_qt5ct_support INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_qt5ct_support ALIAS external_qt5ct_support)
add_subdirectory(qt5ct)
add_subdirectory(qt5ct_qtplugin)
add_subdirectory(qt5ct_style)
target_link_libraries(external_qt5ct_support
INTERFACE
desktop-app::external_qt5ct_style
desktop-app::external_qt5ct_qtplugin
)

View file

@ -1,40 +0,0 @@
# This file is part of Desktop App Toolkit,
# a set of libraries for developing nice desktop applications.
#
# For license and copyright information please follow this link:
# https://github.com/desktop-app/legal/blob/master/LEGAL
if (DESKTOP_APP_USE_PACKAGED AND NOT DESKTOP_APP_USE_PACKAGED_LAZY_PLATFORMTHEMES)
add_library(external_qt5ct INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_qt5ct ALIAS external_qt5ct)
else()
add_library(external_qt5ct STATIC)
add_library(desktop-app::external_qt5ct ALIAS external_qt5ct)
init_target(external_qt5ct "(external)")
set(qt5ct_loc ${third_party_loc}/qt5ct)
set(qt5ct_src ${qt5ct_loc}/src/qt5ct)
set_target_properties(external_qt5ct PROPERTIES AUTOMOC ON)
nice_target_sources(external_qt5ct ${qt5ct_src}
PRIVATE
qt5ct.cpp
qt5ct.h
)
target_include_directories(external_qt5ct
PRIVATE
${qt5ct_src}
)
target_include_directories(external_qt5ct
PUBLIC
${qt5ct_loc}/src
)
target_link_libraries(external_qt5ct
PRIVATE
desktop-app::external_qt
)
endif()

View file

@ -1,42 +0,0 @@
# This file is part of Desktop App Toolkit,
# a set of libraries for developing nice desktop applications.
#
# For license and copyright information please follow this link:
# https://github.com/desktop-app/legal/blob/master/LEGAL
if (DESKTOP_APP_USE_PACKAGED AND NOT DESKTOP_APP_USE_PACKAGED_LAZY_PLATFORMTHEMES)
add_library(external_qt5ct_qtplugin INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_qt5ct_qtplugin ALIAS external_qt5ct_qtplugin)
else()
add_library(external_qt5ct_qtplugin STATIC)
add_library(desktop-app::external_qt5ct_qtplugin ALIAS external_qt5ct_qtplugin)
init_target(external_qt5ct_qtplugin "(external)")
set(qt5ct_loc ${third_party_loc}/qt5ct)
set(qt5ct_qtplugin_src ${qt5ct_loc}/src/qt5ct-qtplugin)
set_target_properties(external_qt5ct_qtplugin PROPERTIES AUTOMOC ON)
nice_target_sources(external_qt5ct_qtplugin ${qt5ct_qtplugin_src}
PRIVATE
main.cpp
qt5ctplatformtheme.cpp
qt5ctplatformtheme.h
)
target_include_directories(external_qt5ct_qtplugin
PRIVATE
${qt5ct_qtplugin_src}
)
target_compile_definitions(external_qt5ct_qtplugin
PRIVATE
QT_STATICPLUGIN
)
target_link_libraries(external_qt5ct_qtplugin
PRIVATE
desktop-app::external_qt5ct
desktop-app::external_qt
)
endif()

View file

@ -1,42 +0,0 @@
# This file is part of Desktop App Toolkit,
# a set of libraries for developing nice desktop applications.
#
# For license and copyright information please follow this link:
# https://github.com/desktop-app/legal/blob/master/LEGAL
if (DESKTOP_APP_USE_PACKAGED AND NOT DESKTOP_APP_USE_PACKAGED_LAZY_PLATFORMTHEMES)
add_library(external_qt5ct_style INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_qt5ct_style ALIAS external_qt5ct_style)
else()
add_library(external_qt5ct_style STATIC)
add_library(desktop-app::external_qt5ct_style ALIAS external_qt5ct_style)
init_target(external_qt5ct_style "(external)")
set(qt5ct_loc ${third_party_loc}/qt5ct)
set(qt5ct_style_src ${qt5ct_loc}/src/qt5ct-style)
set_target_properties(external_qt5ct_style PROPERTIES AUTOMOC ON)
nice_target_sources(external_qt5ct_style ${qt5ct_style_src}
PRIVATE
plugin.cpp
qt5ctproxystyle.cpp
qt5ctproxystyle.h
)
target_include_directories(external_qt5ct_style
PRIVATE
${qt5ct_style_src}
)
target_compile_definitions(external_qt5ct_style
PRIVATE
QT_STATICPLUGIN
)
target_link_libraries(external_qt5ct_style
PRIVATE
desktop-app::external_qt5ct
desktop-app::external_qt
)
endif()

48
external/rnnoise/CMakeLists.txt vendored Normal file
View file

@ -0,0 +1,48 @@
# This file is part of Desktop App Toolkit,
# a set of libraries for developing nice desktop applications.
#
# For license and copyright information please follow this link:
# https://github.com/desktop-app/legal/blob/master/LEGAL
if (DESKTOP_APP_USE_PACKAGED)
add_library(external_rnnoise INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_rnnoise ALIAS external_rnnoise)
find_package(PkgConfig REQUIRED)
pkg_check_modules(RNNOISE REQUIRED IMPORTED_TARGET rnnoise)
target_link_libraries(external_rnnoise INTERFACE PkgConfig::RNNOISE)
else()
add_library(external_rnnoise STATIC IMPORTED GLOBAL)
add_library(desktop-app::external_rnnoise ALIAS external_rnnoise)
set(rnnoise_lib_loc ${libs_loc}/rnnoise/out)
if (WIN32)
target_include_directories(external_rnnoise
INTERFACE
${libs_loc}/rnnoise/include
)
set_target_properties(external_rnnoise PROPERTIES
IMPORTED_LOCATION "${rnnoise_lib_loc}/Release/rnnoise.lib"
IMPORTED_LOCATION_DEBUG "${rnnoise_lib_loc}/Debug/rnnoise.lib"
)
elseif (APPLE)
target_include_directories(external_rnnoise
INTERFACE
${libs_loc}/rnnoise/include
)
set_target_properties(external_rnnoise PROPERTIES
IMPORTED_LOCATION "${rnnoise_lib_loc}/Release/librnnoise.a"
IMPORTED_LOCATION_DEBUG "${rnnoise_lib_loc}/Debug/librnnoise.a"
)
else()
target_include_directories(external_rnnoise
INTERFACE
/usr/local/include
)
find_library(RNNOISE_LIBRARY librnnoise.a)
set_target_properties(external_rnnoise PROPERTIES
IMPORTED_LOCATION "${RNNOISE_LIBRARY}"
)
endif()
endif()

View file

@ -1,26 +0,0 @@
# This file is part of Desktop App Toolkit,
# a set of libraries for developing nice desktop applications.
#
# For license and copyright information please follow this link:
# https://github.com/desktop-app/legal/blob/master/LEGAL
if (EXISTS ${third_party_loc}/SPMediaKeyTap)
add_library(external_sp_media_key_tap STATIC)
add_library(desktop-app::external_sp_media_key_tap ALIAS external_sp_media_key_tap)
init_target(external_sp_media_key_tap "(external)")
set(sp_media_key_tap_loc ${third_party_loc}/SPMediaKeyTap)
target_sources(external_sp_media_key_tap
PRIVATE
${sp_media_key_tap_loc}/SPMediaKeyTap.m
${sp_media_key_tap_loc}/SPMediaKeyTap.h
${sp_media_key_tap_loc}/SPInvocationGrabbing/NSObject+SPInvocationGrabbing.m
${sp_media_key_tap_loc}/SPInvocationGrabbing/NSObject+SPInvocationGrabbing.h
)
target_include_directories(external_sp_media_key_tap SYSTEM
INTERFACE
${sp_media_key_tap_loc}
)
endif()

View file

@ -12,7 +12,7 @@ if (DESKTOP_APP_USE_PACKAGED)
target_link_libraries(external_webrtc INTERFACE tg_owt::tg_owt)
else()
set(webrtc_loc ${libs_loc}/tg_owt/src)
set(webrtc_build_loc ${libs_loc}/tg_owt/out/$<CONFIG>)
set(webrtc_build_loc ${libs_loc}/tg_owt/out/$<IF:$<CONFIG:Debug>,Debug,Release>)
target_compile_definitions(external_webrtc
INTERFACE
@ -21,6 +21,7 @@ else()
RTC_ENABLE_VP9
HAVE_SCTP
WEBRTC_USE_H264
WEBRTC_USE_BUILTIN_ISAC_FLOAT
WEBRTC_LIBRARY_IMPL
WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=1
ABSL_ALLOCATOR_NOTHROW=1
@ -47,6 +48,8 @@ else()
target_compile_definitions(external_webrtc
INTERFACE
WEBRTC_LINUX
WEBRTC_USE_X11
WEBRTC_USE_PIPEWIRE
)
endif()
@ -60,6 +63,7 @@ else()
INTERFACE
${webrtc_loc}
${webrtc_loc}/third_party/abseil-cpp
${webrtc_loc}/third_party/libyuv/include
)
set(webrtc_libs
@ -71,13 +75,20 @@ else()
${webrtc_loc}/sdk/objc
${webrtc_loc}/sdk/objc/base
${webrtc_loc}/sdk/objc/components/video_codec
${webrtc_loc}/third_party/libyuv/include
)
endif()
foreach (lib ${webrtc_libs})
list(APPEND webrtc_libs_list "${webrtc_build_loc}/${lib}${webrtc_lib_suffix}")
endforeach()
target_link_libraries(external_webrtc
INTERFACE
${webrtc_libs_list}
desktop-app::external_openssl
desktop-app::external_jpeg
desktop-app::external_opus
)
if (WIN32)
target_link_libraries(external_webrtc
INTERFACE
@ -92,13 +103,17 @@ else()
INTERFACE
-ObjC
)
else()
# Required for desktop_capture
target_link_static_libraries(external_webrtc
INTERFACE
Xcomposite
Xdamage
Xext
Xfixes
Xrandr
Xrender
Xtst
)
endif()
target_link_libraries(external_webrtc
INTERFACE
${webrtc_libs_list}
desktop-app::external_openssl
desktop-app::external_jpeg
desktop-app::external_opus
)
endif()

View file

@ -1,39 +0,0 @@
# This file is part of Desktop App Toolkit,
# a set of libraries for developing nice desktop applications.
#
# For license and copyright information please follow this link:
# https://github.com/desktop-app/legal/blob/master/LEGAL
add_library(external_webview INTERFACE IMPORTED GLOBAL)
add_library(desktop-app::external_webview ALIAS external_webview)
add_library(external_webview_bundled INTERFACE)
set(webview_loc ${third_party_loc}/webview)
if (WIN32)
target_include_directories(external_webview_bundled
INTERFACE
${webview_loc}/script/microsoft.web.webview2.1.0.664.37/build/native/include
)
if (build_win64)
set(webview_arch x64)
else()
set(webview_arch x86)
endif()
target_link_libraries(external_webview_bundled
INTERFACE
${webview_loc}/script/microsoft.web.webview2.1.0.664.37/build/native/${webview_arch}/WebView2LoaderStatic.lib
)
endif()
target_include_directories(external_webview_bundled
INTERFACE
${webview_loc}
)
target_link_libraries(external_webview
INTERFACE
external_webview_bundled
)

View file

@ -0,0 +1,26 @@
# This file is part of Desktop App Toolkit,
# a set of libraries for developing nice desktop applications.
#
# For license and copyright information please follow this link:
# https://github.com/desktop-app/legal/blob/master/LEGAL
add_library(linux_allocation_tracer STATIC)
add_library(desktop-app::linux_allocation_tracer ALIAS linux_allocation_tracer)
nice_target_sources(linux_allocation_tracer ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE
linux_allocation_tracer.cpp
linux_allocation_tracer.h
)
add_executable(allocation_trace_reader WIN32)
init_target(allocation_trace_reader)
target_sources(allocation_trace_reader
PRIVATE
linux_allocation_trace_reader.cpp
)
target_link_options(allocation_trace_reader PRIVATE -static-libstdc++)
set_target_properties(allocation_trace_reader PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

View file

@ -0,0 +1,216 @@
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include <iostream>
#include <iomanip>
#include <locale>
#include <unordered_map>
#include <cstring>
#include <ctime>
#include <vector>
constexpr auto kBufferSize = 1024 * 1024;
char Buffer[kBufferSize];
struct Fields {
std::uint32_t time = 0;
std::size_t mallocs = 0;
std::size_t reallocs = 0;
std::size_t frees = 0;
std::size_t unknownReallocs = 0;
std::size_t unknownFrees = 0;
};
Fields State;
std::unordered_map<std::uint64_t, std::size_t> Map;
std::vector<Fields> Snapshots;
void WriteTime(std::uint32_t time) {
std::time_t t = std::time_t(time);
const auto parsed = std::localtime(&t);
std::cout
<< std::setw(2) << std::setfill('0') << parsed->tm_hour
<< ":"
<< std::setw(2) << std::setfill('0') << parsed->tm_min
<< ":"
<< std::setw(2) << std::setfill('0') << parsed->tm_sec;
}
void PrintState() {
if (!State.time) {
return;
}
WriteTime(State.time);
auto full = std::uint64_t(0);
for (const auto &[address, amount] : Map) {
full += amount;
}
class NumPunct final : public std::numpunct<char> {
protected:
char do_thousands_sep() const override { return '\''; }
std::string do_grouping() const override { return "\03"; }
};
const auto &locale = std::cout.getloc();
std::cout.imbue(std::locale(std::locale::classic(), new NumPunct()));
std::cout
<< ": "
<< std::setw(13) << std::setfill(' ') << full
<< " (unknown: "
<< State.unknownFrees
<< ")"
<< std::endl;
std::cout.imbue(locale);
}
void Add(std::uint64_t address, std::uint64_t size) {
const auto i = Map.find(address);
if (i != end(Map)) {
std::cout
<< "WARNING: Repeated entry for "
<< address
<< " (size: "
<< size
<< ")."
<< std::endl;
return;
}
Map.emplace(address, size);
}
void ParseMalloc(const char *buffer) {
const auto size = *reinterpret_cast<const std::uint64_t*>(buffer);
const auto address = *reinterpret_cast<const std::uint64_t*>(buffer + 8);
Add(address, size);
++State.mallocs;
}
void ParseRealloc(const char *buffer) {
const auto old = *reinterpret_cast<const std::uint64_t*>(buffer);
const auto size = *reinterpret_cast<const std::uint64_t*>(buffer + 8);
const auto address = *reinterpret_cast<const std::uint64_t*>(buffer + 16);
const auto i = Map.find(old);
if (i == end(Map)) {
++State.unknownReallocs;
Add(address, size);
} else if (old != address) {
Map.erase(i);
Add(address, size);
++State.reallocs;
} else {
i->second = size;
++State.reallocs;
}
}
void ParseFree(const char *buffer) {
const auto address = *reinterpret_cast<const std::uint64_t*>(buffer);
const auto i = Map.find(address);
if (i == end(Map)) {
++State.unknownFrees;
} else {
Map.erase(i);
++State.frees;
}
}
long Parse(const char *buffer, const char *end) {
auto result = 0;
while (end > buffer) {
const auto command = buffer[0];
auto entry = 0;
switch (command) {
case 1: entry = 5 + 2 * sizeof(std::uint64_t); break;
case 2: entry = 5 + 3 * sizeof(std::uint64_t); break;
case 3: entry = 5 + sizeof(std::uint64_t); break;
default:
std::cout
<< "WARNING: Garbage in trace file, command: "
<< int(command)
<< "."
<< std::endl;
return -1;
}
if (end - buffer < entry) {
break;
}
const auto time = *reinterpret_cast<const std::uint32_t*>(++buffer);
buffer += 4;
if (time > State.time) {
PrintState();
State.time = time;
} else if (time < State.time) {
std::cout
<< "WARNING: Time "
<< time
<< " after "
<< State.time
<< "."
<< std::endl;
}
switch (command) {
case 1: ParseMalloc(buffer); break;
case 2: ParseRealloc(buffer); break;
case 3: ParseFree(buffer); break;
}
buffer += entry - 5;
result += entry;
}
return result;
}
int main(int argc, char *argv[]) {
if (argc != 2) {
std::cout
<< "Usage 'allocation_trace_reader [trace_file_path]'."
<< std::endl;
return -1;
}
const auto file = fopen(argv[1], "rb");
if (!file) {
std::cout
<< "ERROR: Could not open '"
<< argv[1]
<< "'."
<< std::endl;
return -1;
}
char *data = Buffer;
while (true) {
const auto read = fread(data, 1, Buffer + kBufferSize - data, file);
if (read == 0) {
if (data != Buffer) {
std::cout
<< "WARNING: Trace file end is corrupt, could not parse: "
<< std::size_t(data - Buffer)
<< std::endl;
}
break;
}
data += read;
const auto parsed = Parse(Buffer, data);
if (parsed < 0) {
break;
}
data -= parsed;
if (data - Buffer > 0) {
std::memmove(Buffer, Buffer + parsed, data - Buffer);
}
}
PrintState();
std::cout << "Mallocs: " << State.mallocs << "." << std::endl;
std::cout << "Reallocs: " << State.reallocs << "." << std::endl;
std::cout << "Frees: " << State.frees << "." << std::endl;
if (State.unknownReallocs) {
std::cout
<< "Unknown realloc() calls: "
<< State.unknownReallocs
<< "."
<< std::endl;
}
return 0;
}

View file

@ -0,0 +1,172 @@
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "linux_allocation_tracer.h"
#include <atomic>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <malloc.h>
#include <dlfcn.h>
#include <stdio.h>
namespace {
std::atomic<void(*)(size_t, void *)> MallocLogger;
std::atomic<void(*)(size_t, void *)> VallocLogger;
std::atomic<void(*)(size_t, void *)> PVallocLogger;
std::atomic<void(*)(size_t, size_t, void *)> CallocLogger;
std::atomic<void(*)(void *, size_t, void *)> ReallocLogger;
std::atomic<void(*)(size_t, size_t, void *)> MemAlignLogger;
std::atomic<void(*)(size_t, size_t, void *)> AlignedAllocLogger;
std::atomic<void(*)(size_t, size_t, void *)> PosixMemAlignLogger;
std::atomic<void(*)(void *)> FreeLogger;
} // namespace
extern "C" {
//void *__real___malloc(size_t size);
void *__real___libc_malloc(size_t size);
void *__real_malloc(size_t size);
void *__real_valloc(size_t size);
void *__real_pvalloc(size_t size);
void *__real_calloc(size_t num, size_t size);
void *__real_realloc(void *ptr, size_t size);
void *__real_memalign(size_t alignment, size_t size);
void *__real_aligned_alloc(size_t alignment, size_t size);
int __real_posix_memalign(void **memptr, size_t alignment, size_t size);
void __real_free(void *ptr);
// void *__wrap___malloc(size_t size) {
// const auto result = __real___malloc(size);
// if (const auto logger = MallocLogger.load()) {
// logger(size, result);
// }
// return result;
// }
void *__wrap___libc_malloc(size_t size) {
const auto result = __real___libc_malloc(size);
if (const auto logger = MallocLogger.load()) {
logger(size, result);
}
return result;
}
void *__wrap_malloc(size_t size) {
const auto result = __real_malloc(size);
if (const auto logger = MallocLogger.load()) {
logger(size, result);
}
return result;
}
void *__wrap_valloc(size_t size) {
const auto result = __real_valloc(size);
if (const auto logger = VallocLogger.load()) {
logger(size, result);
}
return result;
}
void *__wrap_pvalloc(size_t size) {
const auto result = __real_pvalloc(size);
if (const auto logger = PVallocLogger.load()) {
logger(size, result);
}
return result;
}
void *__wrap_calloc(size_t num, size_t size) {
const auto result = __real_calloc(num, size);
if (const auto logger = CallocLogger.load()) {
logger(num, size, result);
}
return result;
}
void *__wrap_realloc(void *ptr, size_t size) {
const auto result = __real_realloc(ptr, size);
if (const auto logger = ReallocLogger.load()) {
logger(ptr, size, result);
}
return result;
}
void *__wrap_memalign(size_t alignment, size_t size) {
const auto result = __real_memalign(alignment, size);
if (const auto logger = MemAlignLogger.load()) {
logger(alignment, size, result);
}
return result;
}
void *__wrap_aligned_alloc(size_t alignment, size_t size) {
const auto result = __real_aligned_alloc(alignment, size);
if (const auto logger = AlignedAllocLogger.load()) {
logger(alignment, size, result);
}
return result;
}
int __wrap_posix_memalign(void **memptr, size_t alignment, size_t size) {
const auto result = __real_posix_memalign(memptr, alignment, size);
if (!result) {
if (const auto logger = PosixMemAlignLogger.load()) {
logger(alignment, size, *memptr);
}
}
return result;
}
void __wrap_free(void *ptr) {
if (const auto logger = FreeLogger.load()) {
logger(ptr);
}
__real_free(ptr);
}
} // extern "C"
void SetMallocLogger(void (*logger)(size_t, void *)) {
MallocLogger = logger;
}
void SetVallocLogger(void (*logger)(size_t, void *)) {
VallocLogger = logger;
}
void SetPVallocLogger(void (*logger)(size_t, void *)) {
PVallocLogger = logger;
}
void SetCallocLogger(void (*logger)(size_t, size_t, void *)) {
CallocLogger = logger;
}
void SetReallocLogger(void (*logger)(void *, size_t, void *)) {
ReallocLogger = logger;
}
void SetMemAlignLogger(void (*logger)(size_t, size_t, void *)) {
MemAlignLogger = logger;
}
void SetAlignedAllocLogger(void (*logger)(size_t, size_t, void *)) {
AlignedAllocLogger = logger;
}
void SetPosixMemAlignLogger(void (*logger)(size_t, size_t, void *)) {
PosixMemAlignLogger = logger;
}
void SetFreeLogger(void (*logger)(void *)) {
FreeLogger = logger;
}

View file

@ -0,0 +1,20 @@
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include <cstdlib>
void SetMallocLogger(void (*logger)(size_t, void *));
void SetVallocLogger(void (*logger)(size_t, void *));
void SetPVallocLogger(void (*logger)(size_t, void *));
void SetCallocLogger(void (*logger)(size_t, size_t, void *));
void SetReallocLogger(void (*logger)(void *, size_t, void *));
void SetMemAlignLogger(void (*logger)(size_t, size_t, void *));
void SetAlignedAllocLogger(void (*logger)(size_t, size_t, void *));
void SetPosixMemAlignLogger(void (*logger)(size_t, size_t, void *));
void SetFreeLogger(void (*logger)(void *));

View file

@ -0,0 +1,21 @@
# This file is part of Desktop App Toolkit,
# a set of libraries for developing nice desktop applications.
#
# For license and copyright information please follow this link:
# https://github.com/desktop-app/legal/blob/master/LEGAL
add_library(linux_wayland_helper STATIC)
add_library(desktop-app::linux_wayland_helper ALIAS linux_wayland_helper)
nice_target_sources(linux_wayland_helper ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE
linux_wayland_helper.cpp
)
target_compile_definitions(linux_wayland_helper PRIVATE G_LOG_DOMAIN="WaylandHelper")
target_link_libraries(linux_wayland_helper
PUBLIC
desktop-app::external_glib
desktop-app::external_gsl
)

View file

@ -0,0 +1,628 @@
// This file is part of Desktop App Toolkit,
// a set of libraries for developing nice desktop applications.
//
// For license and copyright information please follow this link:
// https://github.com/desktop-app/legal/blob/master/LEGAL
//
#include <dlfcn.h>
#include <errno.h>
#include <gsl/gsl>
#include <glib.h>
#include <wayland-egl.h>
#include <wayland-cursor.h>
#include <iostream>
#define LOAD_SYMBOL(handle, func) LoadSymbol(handle, #func, func)
namespace Wayland {
namespace {
constexpr auto WL_CLOSURE_MAX_ARGS = 20;
struct wl_egl_window *(*wl_egl_window_create)(
struct wl_surface *surface,
int width,
int height);
void (*wl_egl_window_destroy)(struct wl_egl_window *egl_window);
void (*wl_egl_window_resize)(
struct wl_egl_window *egl_window,
int width,
int height,
int dx,
int dy);
void (*wl_egl_window_get_attached_size)(
struct wl_egl_window *egl_window,
int *width,
int *height);
struct wl_buffer *(*wl_cursor_image_get_buffer)(
struct wl_cursor_image *image);
struct wl_cursor_theme *(*wl_cursor_theme_load)(
const char *name,
int size,
struct wl_shm *shm);
void (*wl_cursor_theme_destroy)(struct wl_cursor_theme *theme);
struct wl_cursor *(*wl_cursor_theme_get_cursor)(
struct wl_cursor_theme *theme,
const char *name);
int (*wl_cursor_frame_and_duration)(
struct wl_cursor *cursor,
uint32_t time,
uint32_t *duration);
void (*wl_proxy_destroy)(struct wl_proxy *proxy);
uint32_t (*wl_proxy_get_version)(struct wl_proxy *proxy);
void (*wl_array_init)(struct wl_array *array);
void (*wl_array_release)(struct wl_array *array);
void *(*wl_array_add)(struct wl_array *array, size_t size);
int (*wl_proxy_add_listener)(
struct wl_proxy *proxy,
void (**implementation)(void),
void *data);
void (*wl_proxy_set_user_data)(struct wl_proxy *proxy, void *user_data);
void *(*wl_proxy_get_user_data)(struct wl_proxy *proxy);
int (*wl_display_get_fd)(struct wl_display *display);
int (*wl_display_get_error)(struct wl_display *display);
int (*wl_display_dispatch)(struct wl_display *display);
struct wl_event_queue *(*wl_display_create_queue)(struct wl_display *display);
int (*wl_display_dispatch_queue_pending)(
struct wl_display *display,
struct wl_event_queue *queue);
int (*wl_display_prepare_read_queue)(
struct wl_display *display,
struct wl_event_queue *queue);
int (*wl_display_flush)(struct wl_display *display);
void (*wl_display_cancel_read)(struct wl_display *display);
int (*wl_display_read_events)(struct wl_display *display);
void (*wl_event_queue_destroy)(struct wl_event_queue *queue);
int (*wl_display_prepare_read)(struct wl_display *display);
int (*wl_display_dispatch_pending)(struct wl_display *display);
struct wl_display *(*wl_display_connect)(const char *name);
struct wl_display *(*wl_display_connect_to_fd)(int fd);
void (*wl_display_disconnect)(struct wl_display *display);
void *(*wl_proxy_create_wrapper)(void *proxy);
void (*wl_proxy_wrapper_destroy)(void *proxy_wrapper);
void (*wl_proxy_set_queue)(struct wl_proxy *proxy, struct wl_event_queue *queue);
int (*wl_display_roundtrip)(struct wl_display *display);
struct wl_proxy *(*wl_proxy_marshal_array_constructor)(
struct wl_proxy *proxy,
uint32_t opcode,
union wl_argument *args,
const struct wl_interface *interface);
struct wl_proxy *(*wl_proxy_marshal_array_constructor_versioned)(
struct wl_proxy *proxy,
uint32_t opcode,
union wl_argument *args,
const struct wl_interface *interface,
uint32_t version);
uint32_t (*wl_proxy_get_id)(struct wl_proxy *proxy);
const void *(*wl_proxy_get_listener)(struct wl_proxy *proxy);
struct argument_details {
char type;
int nullable;
};
const char *get_next_argument(
const char *signature,
struct argument_details *details) {
details->nullable = 0;
for(; *signature; ++signature) {
switch(*signature) {
case 'i':
case 'u':
case 'f':
case 's':
case 'o':
case 'n':
case 'a':
case 'h':
details->type = *signature;
return signature + 1;
case '?':
details->nullable = 1;
}
}
details->type = '\0';
return signature;
}
void wl_argument_from_va_list(
const char *signature,
union wl_argument *args,
int count,
va_list ap) {
int i;
const char *sig_iter;
struct argument_details arg;
sig_iter = signature;
for (i = 0; i < count; i++) {
sig_iter = get_next_argument(sig_iter, &arg);
switch(arg.type) {
case 'i':
args[i].i = va_arg(ap, int32_t);
break;
case 'u':
args[i].u = va_arg(ap, uint32_t);
break;
case 'f':
args[i].f = va_arg(ap, wl_fixed_t);
break;
case 's':
args[i].s = va_arg(ap, const char *);
break;
case 'o':
args[i].o = va_arg(ap, struct wl_object *);
break;
case 'n':
args[i].o = va_arg(ap, struct wl_object *);
break;
case 'a':
args[i].a = va_arg(ap, struct wl_array *);
break;
case 'h':
args[i].h = va_arg(ap, int32_t);
break;
case '\0':
return;
}
}
}
using Handle = void*;
bool LoadLibrary(Handle &handle, const char *name) {
handle = dlopen(name, RTLD_LAZY | RTLD_NODELETE);
if (handle) {
return true;
}
g_warning("Could not load library '%s': %s", name, dlerror());
return false;
}
template <typename Function>
inline bool LoadSymbol(Handle handle, const char *name, Function &func) {
func = handle
? reinterpret_cast<Function>(dlsym(handle, name))
: nullptr;
if (const auto error = dlerror()) {
g_warning("Failed to load function '%s': %s", name, error);
}
return (func != nullptr);
}
bool Resolve() {
static const auto loaded = [&] {
auto egl = Handle();
auto cursor = Handle();
auto client = Handle();
const auto guard = gsl::finally([&] {
if (egl) {
dlclose(egl);
}
if (cursor) {
dlclose(cursor);
}
if (client) {
dlclose(client);
}
});
return LoadLibrary(egl, "libwayland-egl.so.1")
&& LOAD_SYMBOL(egl, wl_egl_window_create)
&& LOAD_SYMBOL(egl, wl_egl_window_destroy)
&& LOAD_SYMBOL(egl, wl_egl_window_resize)
&& LOAD_SYMBOL(egl, wl_egl_window_get_attached_size)
&& LoadLibrary(cursor, "libwayland-cursor.so.0")
&& LOAD_SYMBOL(cursor, wl_cursor_image_get_buffer)
&& LOAD_SYMBOL(cursor, wl_cursor_theme_load)
&& LOAD_SYMBOL(cursor, wl_cursor_theme_destroy)
&& LOAD_SYMBOL(cursor, wl_cursor_theme_get_cursor)
&& LOAD_SYMBOL(cursor, wl_cursor_frame_and_duration)
&& LoadLibrary(client, "libwayland-client.so.0")
&& LOAD_SYMBOL(client, wl_proxy_destroy)
&& LOAD_SYMBOL(client, wl_proxy_get_version)
&& LOAD_SYMBOL(client, wl_array_init)
&& LOAD_SYMBOL(client, wl_array_release)
&& LOAD_SYMBOL(client, wl_array_add)
&& LOAD_SYMBOL(client, wl_proxy_add_listener)
&& LOAD_SYMBOL(client, wl_proxy_set_user_data)
&& LOAD_SYMBOL(client, wl_proxy_get_user_data)
&& LOAD_SYMBOL(client, wl_display_get_fd)
&& LOAD_SYMBOL(client, wl_display_get_error)
&& LOAD_SYMBOL(client, wl_display_dispatch)
&& LOAD_SYMBOL(client, wl_display_create_queue)
&& LOAD_SYMBOL(client, wl_display_dispatch_queue_pending)
&& LOAD_SYMBOL(client, wl_display_prepare_read_queue)
&& LOAD_SYMBOL(client, wl_display_flush)
&& LOAD_SYMBOL(client, wl_display_cancel_read)
&& LOAD_SYMBOL(client, wl_display_read_events)
&& LOAD_SYMBOL(client, wl_event_queue_destroy)
&& LOAD_SYMBOL(client, wl_display_prepare_read)
&& LOAD_SYMBOL(client, wl_display_dispatch_pending)
&& LOAD_SYMBOL(client, wl_display_connect)
&& LOAD_SYMBOL(client, wl_display_connect_to_fd)
&& LOAD_SYMBOL(client, wl_display_disconnect)
&& LOAD_SYMBOL(client, wl_proxy_create_wrapper)
&& LOAD_SYMBOL(client, wl_proxy_wrapper_destroy)
&& LOAD_SYMBOL(client, wl_proxy_set_queue)
&& LOAD_SYMBOL(client, wl_display_roundtrip)
&& LOAD_SYMBOL(client, wl_proxy_marshal_array_constructor)
&& LOAD_SYMBOL(client, wl_proxy_marshal_array_constructor_versioned)
&& LOAD_SYMBOL(client, wl_proxy_get_id)
&& LOAD_SYMBOL(client, wl_proxy_get_listener);
}();
return loaded;
}
} // namespace
} // namespace Wayland
namespace W = Wayland;
extern "C" {
struct wl_egl_window *wl_egl_window_create(
struct wl_surface *surface,
int width,
int height) {
Expects(W::wl_egl_window_create != nullptr);
return W::wl_egl_window_create(surface, width, height);
}
void wl_egl_window_destroy(struct wl_egl_window *egl_window) {
Expects(W::wl_egl_window_destroy != nullptr);
W::wl_egl_window_destroy(egl_window);
}
void wl_egl_window_resize(
struct wl_egl_window *egl_window,
int width,
int height,
int dx,
int dy) {
Expects(W::wl_egl_window_resize != nullptr);
W::wl_egl_window_resize(egl_window, width, height, dx, dy);
}
void wl_egl_window_get_attached_size(
struct wl_egl_window *egl_window,
int *width,
int *height) {
Expects(W::wl_egl_window_get_attached_size != nullptr);
W::wl_egl_window_get_attached_size(egl_window, width, height);
}
struct wl_buffer *wl_cursor_image_get_buffer(struct wl_cursor_image *image) {
Expects(W::wl_cursor_image_get_buffer != nullptr);
return W::wl_cursor_image_get_buffer(image);
}
struct wl_cursor_theme *wl_cursor_theme_load(
const char *name,
int size,
struct wl_shm *shm) {
Expects(W::wl_cursor_theme_load != nullptr);
return W::wl_cursor_theme_load(name, size, shm);
}
void wl_cursor_theme_destroy(struct wl_cursor_theme *theme) {
Expects(W::wl_cursor_theme_destroy != nullptr);
W::wl_cursor_theme_destroy(theme);
}
struct wl_cursor *wl_cursor_theme_get_cursor(
struct wl_cursor_theme *theme,
const char *name) {
Expects(W::wl_cursor_theme_get_cursor != nullptr);
return W::wl_cursor_theme_get_cursor(theme, name);
}
int wl_cursor_frame_and_duration(
struct wl_cursor *cursor,
uint32_t time,
uint32_t *duration) {
Expects(W::wl_cursor_frame_and_duration != nullptr);
return W::wl_cursor_frame_and_duration(cursor, time, duration);
}
void wl_proxy_destroy(struct wl_proxy *proxy) {
Expects(W::wl_proxy_destroy != nullptr);
W::wl_proxy_destroy(proxy);
}
uint32_t wl_proxy_get_version(struct wl_proxy *proxy) {
Expects(W::wl_proxy_get_version != nullptr);
return W::wl_proxy_get_version(proxy);
}
void wl_array_init(struct wl_array *array) {
Expects(W::wl_array_init != nullptr);
W::wl_array_init(array);
}
void wl_array_release(struct wl_array *array) {
Expects(W::wl_array_release != nullptr);
W::wl_array_release(array);
}
void *wl_array_add(struct wl_array *array, size_t size) {
Expects(W::wl_array_add != nullptr);
return W::wl_array_add(array, size);
}
int wl_proxy_add_listener(
struct wl_proxy *proxy,
void (**implementation)(void),
void *data) {
Expects(W::wl_proxy_add_listener != nullptr);
return W::wl_proxy_add_listener(proxy, implementation, data);
}
void wl_proxy_set_user_data(struct wl_proxy *proxy, void *user_data) {
Expects(W::wl_proxy_set_user_data != nullptr);
W::wl_proxy_set_user_data(proxy, user_data);
}
void *wl_proxy_get_user_data(struct wl_proxy *proxy) {
Expects(W::wl_proxy_get_user_data != nullptr);
return W::wl_proxy_get_user_data(proxy);
}
int wl_display_get_fd(struct wl_display *display) {
Expects(W::wl_display_get_fd != nullptr);
return W::wl_display_get_fd(display);
}
int wl_display_get_error(struct wl_display *display) {
Expects(W::wl_display_get_error != nullptr);
return W::wl_display_get_error(display);
}
int wl_display_dispatch(struct wl_display *display) {
Expects(W::wl_display_dispatch != nullptr);
return W::wl_display_dispatch(display);
}
struct wl_event_queue *wl_display_create_queue(struct wl_display *display) {
Expects(W::wl_display_create_queue != nullptr);
return W::wl_display_create_queue(display);
}
int wl_display_dispatch_queue_pending(
struct wl_display *display,
struct wl_event_queue *queue) {
Expects(W::wl_display_dispatch_queue_pending != nullptr);
return W::wl_display_dispatch_queue_pending(display, queue);
}
int wl_display_prepare_read_queue(
struct wl_display *display,
struct wl_event_queue *queue) {
Expects(W::wl_display_prepare_read_queue != nullptr);
return W::wl_display_prepare_read_queue(display, queue);
}
int wl_display_flush(struct wl_display *display) {
Expects(W::wl_display_flush != nullptr);
return W::wl_display_flush(display);
}
void wl_display_cancel_read(struct wl_display *display) {
Expects(W::wl_display_cancel_read != nullptr);
W::wl_display_cancel_read(display);
}
int wl_display_read_events(struct wl_display *display) {
Expects(W::wl_display_read_events != nullptr);
return W::wl_display_read_events(display);
}
void wl_event_queue_destroy(struct wl_event_queue *queue) {
Expects(W::wl_event_queue_destroy != nullptr);
W::wl_event_queue_destroy(queue);
}
int wl_display_prepare_read(struct wl_display *display) {
Expects(W::wl_display_prepare_read != nullptr);
return W::wl_display_prepare_read(display);
}
int wl_display_dispatch_pending(struct wl_display *display) {
Expects(W::wl_display_dispatch_pending != nullptr);
return W::wl_display_dispatch_pending(display);
}
struct wl_display *wl_display_connect(const char *name) {
if (!W::Resolve()) {
errno = ENOENT;
return nullptr;
}
return W::wl_display_connect(name);
}
struct wl_display *wl_display_connect_to_fd(int fd) {
if (!W::Resolve()) {
errno = ENOENT;
return nullptr;
}
return W::wl_display_connect_to_fd(fd);
}
void wl_display_disconnect(struct wl_display *display) {
Expects(W::wl_display_disconnect != nullptr);
W::wl_display_disconnect(display);
}
void *wl_proxy_create_wrapper(void *proxy) {
Expects(W::wl_proxy_create_wrapper != nullptr);
return W::wl_proxy_create_wrapper(proxy);
}
void wl_proxy_wrapper_destroy(void *proxy_wrapper) {
Expects(W::wl_proxy_wrapper_destroy != nullptr);
W::wl_proxy_wrapper_destroy(proxy_wrapper);
}
void wl_proxy_set_queue(
struct wl_proxy *proxy,
struct wl_event_queue *queue) {
Expects(W::wl_proxy_set_queue != nullptr);
W::wl_proxy_set_queue(proxy, queue);
}
int wl_display_roundtrip(struct wl_display *display) {
Expects(W::wl_display_roundtrip != nullptr);
return W::wl_display_roundtrip(display);
}
struct wl_proxy *wl_proxy_marshal_array_constructor(
struct wl_proxy *proxy,
uint32_t opcode,
union wl_argument *args,
const struct wl_interface *interface) {
Expects(W::wl_proxy_marshal_array_constructor != nullptr);
return W::wl_proxy_marshal_array_constructor(
proxy,
opcode,
args,
interface);
}
struct wl_proxy *wl_proxy_marshal_array_constructor_versioned(
struct wl_proxy *proxy,
uint32_t opcode,
union wl_argument *args,
const struct wl_interface *interface,
uint32_t version) {
Expects(W::wl_proxy_marshal_array_constructor_versioned != nullptr);
return W::wl_proxy_marshal_array_constructor_versioned(
proxy,
opcode,
args,
interface,
version);
}
uint32_t wl_proxy_get_id(struct wl_proxy *proxy) {
Expects(W::wl_proxy_get_id != nullptr);
return W::wl_proxy_get_id(proxy);
}
const void *wl_proxy_get_listener(struct wl_proxy *proxy) {
Expects(W::wl_proxy_get_listener != nullptr);
return W::wl_proxy_get_listener(proxy);
}
void wl_proxy_marshal(struct wl_proxy *proxy, uint32_t opcode, ...) {
union wl_argument args[W::WL_CLOSURE_MAX_ARGS];
va_list ap;
va_start(ap, opcode);
// wl_proxy { wl_object { wl_interface *, ... }, ... }
struct wl_object *object = (struct wl_object*)proxy;
struct wl_interface *interface = *((struct wl_interface**)object);
W::wl_argument_from_va_list(
interface->methods[opcode].signature,
args,
W::WL_CLOSURE_MAX_ARGS,
ap);
va_end(ap);
wl_proxy_marshal_array_constructor(proxy, opcode, args, nullptr);
}
struct wl_proxy *wl_proxy_marshal_constructor(
struct wl_proxy *proxy,
uint32_t opcode,
const struct wl_interface *interface,
...) {
union wl_argument args[W::WL_CLOSURE_MAX_ARGS];
va_list ap;
va_start(ap, interface);
// wl_proxy { wl_object { wl_interface *, ... }, ... }
struct wl_object *object = (struct wl_object*)proxy;
struct wl_interface *i = *((struct wl_interface**)object);
W::wl_argument_from_va_list(
i->methods[opcode].signature,
args,
W::WL_CLOSURE_MAX_ARGS,
ap);
va_end(ap);
return wl_proxy_marshal_array_constructor(proxy, opcode, args, interface);
}
struct wl_proxy *wl_proxy_marshal_constructor_versioned(
struct wl_proxy *proxy,
uint32_t opcode,
const struct wl_interface *interface,
uint32_t version,
...) {
union wl_argument args[W::WL_CLOSURE_MAX_ARGS];
va_list ap;
va_start(ap, version);
// wl_proxy { wl_object { wl_interface *, ... }, ... }
struct wl_object *object = (struct wl_object*)proxy;
struct wl_interface *i = *((struct wl_interface**)object);
W::wl_argument_from_va_list(
i->methods[opcode].signature,
args,
W::WL_CLOSURE_MAX_ARGS,
ap);
va_end(ap);
return wl_proxy_marshal_array_constructor_versioned(proxy, opcode,
args, interface,
version);
}
} // extern "C"

126
nuget.cmake Normal file
View file

@ -0,0 +1,126 @@
# This file is part of Desktop App Toolkit,
# a set of libraries for developing nice desktop applications.
#
# For license and copyright information please follow this link:
# https://github.com/desktop-app/legal/blob/master/LEGAL
function(nuget_add_package package_name package package_version)
get_property(nuget_exe_defined GLOBAL PROPERTY nuget_exe_path_property SET)
if (NOT nuget_exe_defined)
# Thanks https://github.com/clarkezone/flutter_win_webview/blob/master/webview_popupauth/windows/CMakeLists.txt
find_program(NUGET_EXE NAMES nuget)
if (NOT NUGET_EXE)
message("NUGET.EXE not found.")
message(FATAL_ERROR "Please install this executable, and run CMake again.")
endif()
message("Resolved NuGet executable: ${NUGET_EXE}")
set_property(GLOBAL PROPERTY nuget_exe_path_property ${NUGET_EXE})
else()
get_property(NUGET_EXE GLOBAL PROPERTY nuget_exe_path_property)
endif()
set(package_key nuget_${package_name}_version_property)
get_property(package_version_defined GLOBAL PROPERTY ${package_key} SET)
if (NOT package_version_defined)
set(packages_loc ${CMAKE_BINARY_DIR}/packages)
file(MAKE_DIRECTORY ${packages_loc})
set_property(GLOBAL PROPERTY ${package_key} ${package_version})
execute_process(
COMMAND
${NUGET_EXE}
install
${package}
-Version ${package_version}
-ExcludeVersion
-OutputDirectory ${packages_loc}
)
else()
get_property(package_version_cached GLOBAL PROPERTY ${package_key})
if (NOT (${package_version_cached} EQUAL ${package_version}))
message(FATAL_ERROR "Package ${package_name} requested with both ${package_version_cached} and ${package_version}")
endif()
endif()
set(${package_name}_loc ${CMAKE_BINARY_DIR}/packages/${package} PARENT_SCOPE)
endfunction()
function(nuget_add_webview target_name)
nuget_add_package(webview2 "Microsoft.Web.WebView2" 1.0.864.35)
set(webview2_loc_native ${webview2_loc}/build/native)
# target_link_libraries(${target_name}
# PRIVATE
# ${webview2_loc_native}/Microsoft.Web.WebView2.targets
# ${src_loc}/ForceStaticLink.targets
# )
#
# This works, but just to be sure, manually link to static library.
#
target_include_directories(${target_name}
PRIVATE
${webview2_loc_native}/include
)
if (build_win64)
set(webview2_lib_folder x64)
else()
set(webview2_lib_folder x86)
endif()
target_link_libraries(${target_name}
PRIVATE
${webview2_loc_native}/${webview2_lib_folder}/WebView2LoaderStatic.lib
)
endfunction()
function(nuget_add_winrt target_name)
nuget_add_package(winrt "Microsoft.Windows.CppWinRT" 2.0.210505.3)
set(gen_dst ${CMAKE_BINARY_DIR}/packages/gen)
file(MAKE_DIRECTORY ${gen_dst}/winrt)
set(winrt_sdk_version ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION})
set(winrt_version_key ${gen_dst}/winrt/version_key)
set(winrt_version_test ${winrt_version_key}_test)
set(sdk_version_key ${gen_dst}/winrt/sdk_version_key)
set(sdk_version_test ${sdk_version_key}_test)
execute_process(
COMMAND
${winrt_loc}/bin/cppwinrt
/?
OUTPUT_FILE
${winrt_version_test}
COMMAND_ERROR_IS_FATAL ANY
)
file(WRITE ${sdk_version_test} ${winrt_sdk_version})
execute_process(
COMMAND
${CMAKE_COMMAND} -E compare_files ${winrt_version_key} ${winrt_version_test}
RESULT_VARIABLE winrt_version_compare_result
)
execute_process(
COMMAND
${CMAKE_COMMAND} -E compare_files ${sdk_version_key} ${sdk_version_test}
RESULT_VARIABLE sdk_version_compare_result
)
if (winrt_version_compare_result EQUAL 0 AND sdk_version_compare_result EQUAL 0)
message("Using existing WinRT headers.")
else()
message("Generating new WinRT headers.")
execute_process(
COMMAND
${winrt_loc}/bin/cppwinrt
-input ${winrt_sdk_version}
-output ${gen_dst}
COMMAND_ERROR_IS_FATAL ANY
)
file(RENAME ${winrt_version_test} ${winrt_version_key})
file(RENAME ${sdk_version_test} ${sdk_version_key})
endif()
target_include_directories(${target_name}
PRIVATE
${gen_dst}
)
endfunction()

View file

@ -63,13 +63,6 @@ if (DESKTOP_APP_USE_PACKAGED_LAZY)
)
endif()
if (DESKTOP_APP_USE_PACKAGED_LAZY_PLATFORMTHEMES)
target_compile_definitions(common_options
INTERFACE
DESKTOP_APP_USE_PACKAGED_LAZY_PLATFORMTHEMES
)
endif()
if (DESKTOP_APP_USE_PACKAGED_FONTS)
target_compile_definitions(common_options
INTERFACE

View file

@ -71,12 +71,14 @@ INTERFACE
AVFoundation
CoreAudio
CoreVideo
CoreMediaIO
QuartzCore
AppKit
CoreWLAN
WebKit
IOKit
GSS
MediaPlayer
)
if (NOT build_osx)

View file

@ -39,6 +39,12 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
$<$<BOOL:${DESKTOP_APP_NO_PDB}>:/DEBUG:NONE>
)
if (NOT build_win64)
target_link_options(common_options
INTERFACE
/LARGEADDRESSAWARE # Allow more than 2 GB in 32 bit application.ß
)
endif()
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_definitions(common_options
INTERFACE

View file

@ -33,9 +33,9 @@ option(DESKTOP_APP_DISABLE_X11_INTEGRATION "Disable all code for X11 integration
option(DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION "Disable all code for Wayland integration (Linux only)." OFF)
option(DESKTOP_APP_DISABLE_GTK_INTEGRATION "Disable all code for GTK integration (Linux only)." OFF)
option(DESKTOP_APP_USE_GLIBC_WRAPS "Use wraps for new GLIBC features." OFF)
option(DESKTOP_APP_USE_ALLOCATION_TRACER "Use simple allocation tracer (Linux only)." OFF)
option(DESKTOP_APP_USE_PACKAGED "Find libraries using CMake instead of exact paths." ${no_special_target})
option(DESKTOP_APP_USE_PACKAGED_LAZY "Bundle recommended Qt plugins for self-contained packages. (Linux only)" OFF)
option(DESKTOP_APP_USE_PACKAGED_LAZY_PLATFORMTHEMES "Bundle recommended Qt platform themes for self-contained packages. (Linux only)" ${DESKTOP_APP_USE_PACKAGED_LAZY})
option(DESKTOP_APP_USE_PACKAGED_FFMPEG_STATIC "Link ffmpeg statically in packaged mode." OFF)
option(DESKTOP_APP_DISABLE_SPELLCHECK "Disable spellcheck library." ${osx_special_target})
option(DESKTOP_APP_DISABLE_CRASH_REPORTS "Disable crash report generation." ${no_special_target})
@ -43,7 +43,6 @@ option(DESKTOP_APP_DISABLE_AUTOUPDATE "Disable autoupdate." ${disable_autoupdate
option(DESKTOP_APP_USE_HUNSPELL_ONLY "Disable system spellchecker and use bundled Hunspell only. (For debugging purposes)" OFF)
option(DESKTOP_APP_USE_ENCHANT "Use Enchant instead of bundled Hunspell. (Linux only)" OFF)
option(DESKTOP_APP_NO_PDB "Disable PDB file generation. (Windows only)" OFF)
set(DESKTOP_APP_QTWAYLANDCLIENT_PRIVATE_HEADERS "" CACHE STRING "QtWaylandClient headers location.")
set(dont_bundle_fonts 0)
if (DESKTOP_APP_USE_PACKAGED AND NOT DESKTOP_APP_USE_PACKAGED_LAZY)
@ -75,6 +74,8 @@ if (WIN32)
set(build_win64 1)
set(build_winstore 1)
set(build_winstore64 1)
elseif (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(build_win64 1)
endif()
elseif (APPLE)
if (DESKTOP_APP_SPECIAL_TARGET STREQUAL "osx")