1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-10-06 09:17:07 +02:00

Add sentry support for macos

Fix cmake apple define because apple
is a unix system.
This commit is contained in:
Elias Steurer 2021-06-12 15:17:38 +02:00
parent dd1e5e614d
commit e118fa235c
7 changed files with 36 additions and 43 deletions

View File

@ -12,7 +12,7 @@ set(CMAKE_CXX_STANDARD 20)
if(WIN32)
set(VCPKG_ARCH "x64-windows")
elseif(UNIX)
elseif(UNIX AND NOT APPLE)
set(VCPKG_ARCH "x64-linux")
elseif(APPLE)
set(VCPKG_ARCH "x64-osx")

View File

@ -16,13 +16,16 @@ find_package(
WebSockets
REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(benchmark CONFIG REQUIRED)
find_package(doctest CONFIG REQUIRED)
if(WIN32)
find_package(sentry CONFIG REQUIRED)
endif()
# CURL must be included before sentry
# because sentry needs the module
# and does not include it itself on macos...
find_package(CURL CONFIG REQUIRED)
find_package(sentry CONFIG REQUIRED)
set(src
main.cpp
@ -74,8 +77,8 @@ set(l10n
translations/ScreenPlay_vi.ts)
set_source_files_properties(${l10n} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/translations")
qt5_add_translation(qmFiles ${l10n})
qt5_add_translation(qmFiles ${l10n})
qt5_add_big_resources(fonts fonts.qrc)
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
@ -86,25 +89,6 @@ endif()
add_executable(${PROJECT_NAME} ${src} ${headers} ${resources} ${qml} ${fonts})
if(WIN32)
# Icon
target_sources(${PROJECT_NAME} PRIVATE ScreenPlay.rc)
target_link_libraries(${PROJECT_NAME} PRIVATE sentry::sentry)
# Disable console window on Windows
# https://stackoverflow.com/questions/8249028/how-do-i-keep-my-qt-c-program-from-opening-a-console-in-windows
set_property(TARGET ${PROJECT_NAME} PROPERTY WIN32_EXECUTABLE true)
# Copy ffmpeg. If the ffmpeg files are missing, start the install_dependencies_XXX for your system!
file(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/*")
foreach(filename ${files})
configure_file(${filename} ${CMAKE_BINARY_DIR}/bin/ COPYONLY)
endforeach()
configure_file(${VCPKG_INSTALLED_PATH}/tools/sentry-native/crashpad_handler.exe ${CMAKE_BINARY_DIR}/bin/ COPYONLY)
endif()
target_compile_definitions(${PROJECT_NAME} PRIVATE "GIT_VERSION=${GIT_VERSION}")
target_link_libraries(
@ -120,16 +104,28 @@ target_link_libraries(
ScreenPlayUtil
benchmark::benchmark
benchmark::benchmark_main
doctest::doctest)
doctest::doctest
sentry::sentry)
if(WIN32)
target_link_libraries(${PROJECT_NAME} PRIVATE sentry::sentry)
# Icon
target_sources(${PROJECT_NAME} PRIVATE ScreenPlay.rc)
# Disable console window on Windows
# https://stackoverflow.com/questions/8249028/how-do-i-keep-my-qt-c-program-from-opening-a-console-in-windows
set_property(TARGET ${PROJECT_NAME} PROPERTY WIN32_EXECUTABLE true)
# Copy ffmpeg. If the ffmpeg files are missing, start the install_dependencies_XXX for your system!
file(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/*")
foreach(filename ${files})
configure_file(${filename} ${CMAKE_BINARY_DIR}/bin/ COPYONLY)
endforeach()
configure_file(${VCPKG_INSTALLED_PATH}/tools/sentry-native/crashpad_handler.exe ${CMAKE_BINARY_DIR}/bin/ COPYONLY)
endif()
if(APPLE)
# Creates a ScreenPlay.app
set_target_properties(${PROJECT_NAME} PROPERTIES
OUTPUT_NAME ${PROJECT_NAME}
@ -158,5 +154,10 @@ if(APPLE)
${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/ffprobe
${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/ )
add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${VCPKG_INSTALLED_PATH}/tools/sentry-native/crashpad_handler
${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/ )
endif()

View File

@ -156,18 +156,20 @@ void App::init()
// Only create anonymousTelemetry if user did not disallow!
if (m_settings->anonymousTelemetry()) {
#ifdef Q_OS_WIN
sentry_options_t* options = sentry_options_new();
sentry_options_set_dsn(options, "https://425ea0b77def4f91a5a9decc01b36ff4@o428218.ingest.sentry.io/5373419");
const QString appPath = QGuiApplication::applicationDirPath();
sentry_options_set_handler_path(options, QString(appPath + "/crashpad_handler.exe").toStdString().c_str());
QString exectuableFileEnding = "";
#ifdef Q_OS_WIN
exectuableFileEnding = ".exe";
#endif
sentry_options_set_handler_path(options, QString(appPath + "/crashpad_handler" + exectuableFileEnding).toStdString().c_str());
sentry_options_set_database_path(options, appPath.toStdString().c_str());
const int sentryInitStatus = sentry_init(options);
if (sentryInitStatus != 0) {
qWarning() << "Unable to inti sentry crashhandler with statuscode: " << sentryInitStatus;
}
#endif
}
m_create = make_unique<Create>(m_globalVariables);

View File

@ -62,10 +62,7 @@
#include "src/wizards.h"
#include <memory>
#ifdef Q_OS_WIN
#include <sentry.h>
#endif
class ScreenPlayWorkshopPlugin;

View File

@ -36,9 +36,7 @@
#include <QApplication>
#include <QCommandLineParser>
#include <QDebug>
#ifdef Q_OS_WIN
#include <sentry.h>
#endif
#define DOCTEST_CONFIG_IMPLEMENT
#define DOCTEST_CONFIG_SUPER_FAST_ASSERTS
#include <doctest/doctest.h>
@ -67,13 +65,9 @@ int main(int argc, char* argv[])
if (app.m_isAnotherScreenPlayInstanceRunning) {
return 0;
} else {
app.init();
const int status = qtGuiApp.exec();
#ifdef Q_OS_WIN
sentry_shutdown();
#endif
return status;
}
}

View File

@ -221,7 +221,6 @@ void Util::logToGui(QtMsgType type, const QMessageLogContext& context, const QSt
if (utilPointer != nullptr)
utilPointer->appendDebugMessages(log);
#ifdef Q_OS_WIN
sentry_value_t crumb
= sentry_value_new_breadcrumb("default", qUtf8Printable(msg));
@ -239,7 +238,6 @@ void Util::logToGui(QtMsgType type, const QMessageLogContext& context, const QSt
sentry_value_set_by_key(crumb, "data", location);
sentry_add_breadcrumb(crumb);
#endif
}
/*!

View File

@ -52,6 +52,7 @@ if __name__ == "__main__":
vcpkg_triplet = "x64-windows"
elif sys.platform == "darwin":
vcpkg_packages_list.append("infoware[opencl]")
vcpkg_packages_list.append("curl") # Hidden dependency from sentry
execute("chmod +x bootstrap-vcpkg.sh", vcpkg_path)
execute("./bootstrap-vcpkg.sh", vcpkg_path, False)
execute("chmod +x vcpkg", vcpkg_path)