diff --git a/CMakeLists.txt b/CMakeLists.txt index 93546d80..2662c813 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") @@ -78,3 +78,13 @@ add_subdirectory(ScreenPlayUtil) if(WIN32) add_subdirectory(ScreenPlaySysInfo) endif() + +#if(APPLE) +#add_custom_target(CopyDependencies DEPENDS ScreenPlay) +#add_custom_command(TARGET CopyDependencies POST_BUILD +# COMMAND "ScreenPlayWallpaper" -E copy_directory +# "$" +# "${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/$/" +# COMMENT "Copying into ScreenPlay.app bundle") +#endif() + diff --git a/ScreenPlay/CMakeLists.txt b/ScreenPlay/CMakeLists.txt index fcbf9871..4c631b4d 100644 --- a/ScreenPlay/CMakeLists.txt +++ b/ScreenPlay/CMakeLists.txt @@ -6,12 +6,12 @@ set(CMAKE_AUTOMOC ON) find_package( QT NAMES Qt6 Qt5 - COMPONENTS Quick Widgets Gui LinguistTools WebSockets WebEngine QuickCompiler + COMPONENTS Quick Widgets Gui LinguistTools Svg WebSockets WebEngine QuickCompiler REQUIRED) find_package( Qt${QT_VERSION_MAJOR} - COMPONENTS Quick Widgets Gui LinguistTools WebSockets WebEngine QuickCompiler + COMPONENTS Quick Widgets Gui LinguistTools Svg WebSockets WebEngine QuickCompiler REQUIRED) message(STATUS "[PROJECT] QT_VERSION_MAJOR = ${QT_VERSION_MAJOR}") @@ -20,9 +20,11 @@ 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,28 +76,17 @@ set(l10n translations/ScreenPlay_vi.ts) set_source_files_properties(${l10n} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/translations") -qt_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") - qt_add_resources(qml qml.qrc Resources.qrc) + qt5_add_resources(qml qml.qrc assets.qrc) else() - qtquick_compiler_add_resources(qml qml.qrc Resources.qrc) + qtquick_compiler_add_resources(qml qml.qrc assets.qrc) endif() -add_executable(${PROJECT_NAME} ${src} ${headers} ${resources} ${qml}) - -if(APPLE) - set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE true) -endif() - -if(WIN32) - # 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) -endif() +add_executable(${PROJECT_NAME} ${src} ${headers} ${resources} ${qml} ${fonts}) target_compile_definitions(${PROJECT_NAME} PRIVATE "GIT_VERSION=${GIT_VERSION}") @@ -107,25 +98,65 @@ target_link_libraries( Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::WebSockets Qt${QT_VERSION_MAJOR}::WebEngine + Qt${QT_VERSION_MAJOR}::Svg ScreenPlaySDK ScreenPlayUtil benchmark::benchmark benchmark::benchmark_main - doctest::doctest) + doctest::doctest + sentry::sentry) if(WIN32) - target_link_libraries(${PROJECT_NAME} PRIVATE sentry::sentry) -endif() -file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin/assets/fonts) -configure_file(assets/fonts/NotoSansCJKkr-Regular.otf ${CMAKE_BINARY_DIR}/bin/assets/fonts COPYONLY) + # Icon + target_sources(${PROJECT_NAME} PRIVATE ScreenPlay.rc) -# Copy ffmpeg. If the ffmpeg files are missing, start the install_dependencies_XXX for your system! -if(WIN32) + # 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} + MACOSX_BUNDLE TRUE + MACOSX_RPATH TRUE + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist + MACOSX_FRAMEWORK_IDENTIFIER screen-play.app + XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@loader_path/Libraries" + RESOURCE "${RESOURCE_FILES}" + XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME TRUE + XCODE_ATTRIBUTE_EXECUTABLE_NAME ${PROJECT_NAME} + ) + + # Needed for the Steam Workshop qml plugin + file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/Workshop) + + add_custom_command( + TARGET ${PROJECT_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${CMAKE_CURRENT_SOURCE_DIR}/../Common/ffmpeg/ffmpeg + ${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/ ) + + add_custom_command( + TARGET ${PROJECT_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + ${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() diff --git a/ScreenPlay/Info.plist b/ScreenPlay/Info.plist new file mode 100644 index 00000000..f9f46ff3 --- /dev/null +++ b/ScreenPlay/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFile + + CFBundleIdentifier + app.screen-play + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleVersion + 1.0 + CFBundleDisplayName + ScreenPlay + + diff --git a/ScreenPlay/app.cpp b/ScreenPlay/app.cpp index 7892e623..2cb253a7 100644 --- a/ScreenPlay/app.cpp +++ b/ScreenPlay/app.cpp @@ -56,7 +56,7 @@ App::App() QGuiApplication::setWindowIcon(QIcon(":/assets/icons/app.ico")); QGuiApplication::setOrganizationName("ScreenPlay"); - QGuiApplication::setOrganizationDomain("https://screen-play.app"); + QGuiApplication::setOrganizationDomain("screen-play.app"); QGuiApplication::setApplicationName("ScreenPlay"); QGuiApplication::setApplicationVersion("0.13.3"); QGuiApplication::setQuitOnLastWindowClosed(false); @@ -74,9 +74,7 @@ App::App() QFontDatabase::addApplicationFont(":/assets/fonts/NotoSans-Medium.ttf"); QFontDatabase::addApplicationFont(":/assets/fonts/NotoSans-Light.ttf"); - if (-1 == QFontDatabase::addApplicationFont(QGuiApplication::applicationDirPath() + "/assets/fonts/NotoSansCJKkr-Regular.otf")) { - qWarning() << "Could not load korean font from: " << QGuiApplication::applicationDirPath() + "/assets/fonts/NotoSansCJKkr-Regular.otf"; - } + QFontDatabase::addApplicationFont(":/assets/fonts/NotoSansCJKkr-Regular.otf"); QQuickWindow::setTextRenderType(QQuickWindow::TextRenderType::NativeTextRendering); @@ -158,7 +156,6 @@ 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"); QString environment = QGuiApplication::applicationVersion() + ""; @@ -167,11 +164,12 @@ void App::init() const QString appPath = QGuiApplication::applicationDirPath(); sentry_options_set_handler_path(options, QString(appPath + "/crashpad_handler.exe").toStdString().c_str()); sentry_options_set_database_path(options, appPath.toStdString().c_str()); + sentry_options_set_handler_path(options, QString(QGuiApplication::applicationDirPath() + "/crashpad_handler" + ScreenPlayUtil::executableBinEnding()).toStdString().c_str()); + sentry_options_set_database_path(options, QGuiApplication::applicationDirPath().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(m_globalVariables); diff --git a/ScreenPlay/app.h b/ScreenPlay/app.h index 2bccbdd8..6091ba9e 100644 --- a/ScreenPlay/app.h +++ b/ScreenPlay/app.h @@ -48,6 +48,7 @@ #include #include #include +#include #include "src/create.h" #include "src/globalvariables.h" @@ -61,10 +62,7 @@ #include "src/wizards.h" #include - -#ifdef Q_OS_WIN #include -#endif class ScreenPlayWorkshopPlugin; diff --git a/ScreenPlay/Resources.qrc b/ScreenPlay/assets.qrc similarity index 92% rename from ScreenPlay/Resources.qrc rename to ScreenPlay/assets.qrc index 7e0f5a9b..bc4034ee 100644 --- a/ScreenPlay/Resources.qrc +++ b/ScreenPlay/assets.qrc @@ -1,16 +1,6 @@ assets/WorkshopPreview.html - assets/fonts/LibreBaskerville-Italic.ttf - assets/fonts/NotoSans-Light.ttf - assets/fonts/NotoSans-Medium.ttf - assets/fonts/NotoSans-Regular.ttf - assets/fonts/NotoSans-Thin.ttf - assets/fonts/Roboto-Light.ttf - assets/fonts/Roboto-Regular.ttf - assets/fonts/Roboto-Thin.ttf - assets/fonts/RobotoMono-Light.ttf - assets/fonts/RobotoMono-Thin.ttf assets/icons/app.ico assets/icons/brand_github.svg assets/icons/brand_gitlab.svg @@ -139,5 +129,6 @@ assets/icons/icon_sort-down-solid.svg assets/icons/brand_reddit.svg assets/icons/steam_default_avatar.png + assets/macos/app.screenplay.plist diff --git a/ScreenPlay/assets/macos/app.screenplay.plist b/ScreenPlay/assets/macos/app.screenplay.plist new file mode 100644 index 00000000..40befa52 --- /dev/null +++ b/ScreenPlay/assets/macos/app.screenplay.plist @@ -0,0 +1,19 @@ + + + + + Label + app.screenplay + ProgramArguments + + {{SCREENPLAY_PATH}} + -silent + + ProcessType + Interactive + RunAtLoad + <{{SCREENPLAY_AUTOSTART}}/> + KeepAlive + + + diff --git a/ScreenPlay/fonts.qrc b/ScreenPlay/fonts.qrc new file mode 100644 index 00000000..76558247 --- /dev/null +++ b/ScreenPlay/fonts.qrc @@ -0,0 +1,15 @@ + + + assets/fonts/LibreBaskerville-Italic.ttf + assets/fonts/NotoSans-Light.ttf + assets/fonts/NotoSans-Medium.ttf + assets/fonts/NotoSans-Regular.ttf + assets/fonts/NotoSans-Thin.ttf + assets/fonts/NotoSansCJKkr-Regular.otf + assets/fonts/Roboto-Light.ttf + assets/fonts/Roboto-Regular.ttf + assets/fonts/Roboto-Thin.ttf + assets/fonts/RobotoMono-Light.ttf + assets/fonts/RobotoMono-Thin.ttf + + diff --git a/ScreenPlay/main.cpp b/ScreenPlay/main.cpp index 4062c117..074f0453 100644 --- a/ScreenPlay/main.cpp +++ b/ScreenPlay/main.cpp @@ -37,9 +37,7 @@ #include #include #include -#ifdef Q_OS_WIN #include -#endif #define DOCTEST_CONFIG_IMPLEMENT #define DOCTEST_CONFIG_SUPER_FAST_ASSERTS #include @@ -68,13 +66,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; } } diff --git a/ScreenPlay/src/createimportvideo.cpp b/ScreenPlay/src/createimportvideo.cpp index 3db4ad62..2e0cb1ab 100644 --- a/ScreenPlay/src/createimportvideo.cpp +++ b/ScreenPlay/src/createimportvideo.cpp @@ -33,14 +33,19 @@ CreateImportVideo::CreateImportVideo(const QString& videoPath, const QString& ex : QObject(parent) , m_quality(quality) { - m_videoPath = videoPath; m_exportPath = exportPath; m_codec = codec; - m_process = std::make_unique(this); + m_ffprobeExecutable = QApplication::applicationDirPath() + "/ffprobe" + ScreenPlayUtil::executableBinEnding(); + m_ffmpegExecutable = QApplication::applicationDirPath() + "/ffmpeg" + ScreenPlayUtil::executableBinEnding(); - m_ffprobeExecutable = QApplication::applicationDirPath() + "/ffprobe" + ScreenPlayUtil::executableEnding(); - m_ffmpegExecutable = QApplication::applicationDirPath() + "/ffmpeg" + ScreenPlayUtil::executableEnding(); + if (!QFileInfo::exists(m_ffprobeExecutable)) { + qFatal("FFPROBE executable not found!"); + } + + if (!QFileInfo::exists(m_ffmpegExecutable)) { + qFatal("FFMPEG executable not found!"); + } } /*! @@ -58,7 +63,7 @@ CreateImportVideo::CreateImportVideo(const QString& videoPath, const QString& ex void CreateImportVideo::process() { - qInfo() << "createWallpaperInfo()"; + qInfo() << "createWallpaperInfo()" << m_videoPath << m_exportPath << m_codec << m_ffmpegExecutable << m_ffprobeExecutable; if (!createWallpaperInfo() || QThread::currentThread()->isInterruptionRequested()) { emit abortAndCleanup(); return; @@ -264,7 +269,7 @@ bool CreateImportVideo::analyzeVideo(const QJsonObject& obj) QJsonObject videoStream; - for (const auto stream : arrayStream) { + for (const auto& stream : arrayStream) { QString codec_type = stream.toObject().value("codec_type").toString(); if (codec_type == "video") { videoStream = stream.toObject(); @@ -747,19 +752,42 @@ QString CreateImportVideo::waitForFinished( const Executable executable) { + m_process = std::make_unique(); + QObject::connect(m_process.get(), &QProcess::errorOccurred, [=](QProcess::ProcessError error) { + qDebug() << "error enum val = " << error << m_process->errorString(); + emit createWallpaperStateChanged(ImportVideoState::AnalyseVideoError); + m_process->terminate(); + if (!m_process->waitForFinished(1000)) { + m_process->kill(); + } + }); if (executable == Executable::FFMPEG) { m_process->setProgram(m_ffmpegExecutable); } else { m_process->setProgram(m_ffprobeExecutable); } + +#ifdef Q_OS_OSX + QProcess changeChmod; + changeChmod.setProgram("chmod"); + changeChmod.setArguments({ "+x", m_process->program() }); + changeChmod.start(); + if (!changeChmod.waitForFinished()) { + qCritical() << "Unable to change permission " << m_process->program() << " to be exectuable"; + } +#endif + m_process->setProcessChannelMode(processChannelMode); m_process->setArguments(args); + m_process->setWorkingDirectory(QApplication::applicationDirPath()); m_process->start(); - while (!m_process->waitForFinished(100)) //Wake up every 10ms and check if we must exit + qInfo() << m_process->workingDirectory() << m_process->program() << m_process->arguments(); + + while (!m_process->waitForFinished(10)) //Wake up every 10ms and check if we must exit { if (QThread::currentThread()->isInterruptionRequested()) { - qDebug() << "Interrupt thread"; + qInfo() << "Interrupt thread"; m_process->terminate(); if (!m_process->waitForFinished(1000)) { m_process->kill(); diff --git a/ScreenPlay/src/screenplaymanager.cpp b/ScreenPlay/src/screenplaymanager.cpp index 7f2c65dd..2d8a421d 100644 --- a/ScreenPlay/src/screenplaymanager.cpp +++ b/ScreenPlay/src/screenplaymanager.cpp @@ -381,6 +381,7 @@ void ScreenPlayManager::newConnection() for (int i = 0; i < m_screenPlayWallpapers.size(); ++i) { if (m_screenPlayWallpapers.at(i)->appID() == matchingConnection->appID()) { + qInfo() << "Matching Wallpaper found!"; m_screenPlayWallpapers.at(i)->setSDKConnection(std::move(matchingConnection)); return; } @@ -388,6 +389,7 @@ void ScreenPlayManager::newConnection() for (int i = 0; i < m_screenPlayWidgets.size(); ++i) { if (m_screenPlayWidgets.at(i)->appID() == matchingConnection->appID()) { + qInfo() << "Matching Widget found!"; m_screenPlayWidgets.at(i)->setSDKConnection(std::move(matchingConnection)); return; } diff --git a/ScreenPlay/src/screenplaywallpaper.cpp b/ScreenPlay/src/screenplaywallpaper.cpp index 0cfedea6..e980e0bc 100644 --- a/ScreenPlay/src/screenplaywallpaper.cpp +++ b/ScreenPlay/src/screenplaywallpaper.cpp @@ -15,8 +15,9 @@ namespace ScreenPlay { */ ScreenPlayWallpaper::~ScreenPlayWallpaper() { - qInfo() << "Remove wallpaper " << m_appID; m_connection->close(); + qInfo() << "Remove wallpaper " << m_appID; + } /*! @@ -106,6 +107,7 @@ bool ScreenPlayWallpaper::start() const bool success = m_process.startDetached(); qInfo() << "Starting ScreenPlayWallpaper detached: " << (success ? "success" : "failed!"); if (!success) { + qInfo() << m_process.program() << m_appArgumentsList; emit error(QString("Could not start Wallpaper: " + m_process.errorString())); } return success; diff --git a/ScreenPlay/src/screenplaywidget.cpp b/ScreenPlay/src/screenplaywidget.cpp index 1af492a9..a27620c8 100644 --- a/ScreenPlay/src/screenplaywidget.cpp +++ b/ScreenPlay/src/screenplaywidget.cpp @@ -50,9 +50,10 @@ ScreenPlayWidget::ScreenPlayWidget( QVariant::fromValue(m_type).toString(), QString::number(m_position.x()), QString::number(m_position.y()), - }; +}; } + bool ScreenPlayWidget::start() { m_process.setArguments(m_appArgumentsList); @@ -65,6 +66,7 @@ bool ScreenPlayWidget::start() qInfo() << "Starting ScreenPlayWidget detached: " << (success ? "success" : "failed!"); if (!success) { emit error(QString("Could not start Widget: " + m_process.errorString())); + return false; } return success; } diff --git a/ScreenPlay/src/screenplaywidget.h b/ScreenPlay/src/screenplaywidget.h index 57bf3eec..d6852092 100644 --- a/ScreenPlay/src/screenplaywidget.h +++ b/ScreenPlay/src/screenplaywidget.h @@ -69,11 +69,11 @@ public: const QString& absolutePath, const QString& previewImage, const QJsonObject& properties, const InstalledType::InstalledType type); + ~ScreenPlayWidget(); bool start(); ScreenPlayWidget() { } - ~ScreenPlayWidget(); QString previewImage() const { return m_previewImage; } QPoint position() const { return m_position; } diff --git a/ScreenPlay/src/settings.cpp b/ScreenPlay/src/settings.cpp index 6bd5facb..8f4c0472 100644 --- a/ScreenPlay/src/settings.cpp +++ b/ScreenPlay/src/settings.cpp @@ -1,6 +1,7 @@ #include "settings.h" #include "ScreenPlayUtil/util.h" +#include namespace ScreenPlay { @@ -39,6 +40,16 @@ Settings::Settings(const std::shared_ptr& globalVariables, : QObject(parent) , m_globalVariables { globalVariables } { +#ifdef Q_OS_WIN + setDesktopEnvironment(DesktopEnvironment::Windows); +#endif +#ifdef Q_OS_OSX + setDesktopEnvironment(DesktopEnvironment::OSX); +#endif +#ifdef Q_OS_LINUX + // We only support KDE for now + setDesktopEnvironment(DesktopEnvironment::KDE); +#endif qRegisterMetaType("Settings::Language"); qRegisterMetaType("Settings::Theme"); @@ -47,15 +58,15 @@ Settings::Settings(const std::shared_ptr& globalVariables, qmlRegisterUncreatableType("Settings", 1, 0, "Settings", "Error only for enums"); if (!m_qSettings.contains("Autostart")) { -#ifdef Q_OS_WIN - QSettings settings("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat); - if (!m_qSettings.value("Autostart").toBool()) { - if (!settings.contains("ScreenPlay")) { + if (desktopEnvironment() == DesktopEnvironment::Windows) { + QSettings settings("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat); + if (!m_qSettings.value("Autostart").toBool()) { + if (!settings.contains("ScreenPlay")) { + } } + settings.setValue("ScreenPlay", QDir::toNativeSeparators(QCoreApplication::applicationFilePath()) + " -silent"); + settings.sync(); } - settings.setValue("ScreenPlay", QDir::toNativeSeparators(QCoreApplication::applicationFilePath()) + " -silent"); - settings.sync(); -#endif m_qSettings.setValue("Autostart", true); m_qSettings.sync(); } else { @@ -87,54 +98,10 @@ Settings::Settings(const std::shared_ptr& globalVariables, writeJsonFileFromResource("profiles"); } - //If empty use steam workshop location - if (QString(m_qSettings.value("ScreenPlayContentPath").toString()).isEmpty()) { - - /* - * ! We must use this (ugly) method, because to stay FOSS we cannot call the steamAPI here ! - * - * We start with the assumption that when we go up 2 folder. - * So that there must be at least a common folder: - * Windows example: - * From -> C:\Program Files (x86)\Steam\steamapps\common\ScreenPlay - * To -> C:\Program Files (x86)\Steam\steamapps\ - * Dest.-> C:\Program Files (x86)\Steam\steamapps\workshop\content\672870 - * - * When we reach the folder it _can_ contain a workshop folder when the user - * previously installed any workshop content. If the folder does not exsist we - * need to create it by hand. Normally Steam will create this folder but we need to - * set it here at this point so that the QFileSystemWatcher in InstalledListModel does - * not generate warnings. - */ - QDir dir; - QString path = QApplication::instance()->applicationDirPath() + "/../../workshop/content/672870"; - if (!dir.mkpath(path)) { - qWarning() << "Could not create steam workshop path for path: " << path; - } else { - m_globalVariables->setLocalStoragePath(QUrl::fromUserInput(path)); - m_qSettings.setValue("ScreenPlayContentPath", dir.cleanPath(path)); - m_qSettings.sync(); - } - - } else { - m_globalVariables->setLocalStoragePath(QUrl::fromUserInput(m_qSettings.value("ScreenPlayContentPath").toString())); - } + initInstalledPath(); setupWidgetAndWindowPaths(); setGitBuildHash(COMPILE_INFO); - -#ifdef Q_OS_WIN - setDesktopEnvironment(DesktopEnvironment::Windows); -#endif - -#ifdef Q_OS_OSX - setDesktopEnvironment(DesktopEnvironment::OSX); -#endif - -#ifdef Q_OS_LINUX - // We only support KDE for now - setDesktopEnvironment(DesktopEnvironment::KDE); -#endif } /*! @@ -173,16 +140,28 @@ void Settings::writeJsonFileFromResource(const QString& filename) void Settings::setupWidgetAndWindowPaths() { QDir workingDir(QGuiApplication::applicationDirPath()); - -#if defined(Q_OS_WIN) || defined(Q_OS_LINUX) - m_globalVariables->setWidgetExecutablePath(QUrl(workingDir.path() + "/ScreenPlayWidget" + ScreenPlayUtil::executableEnding())); - m_globalVariables->setWallpaperExecutablePath(QUrl(workingDir.path() + "/ScreenPlayWallpaper" + ScreenPlayUtil::executableEnding())); +#ifdef Q_OS_WIN + m_globalVariables->setWidgetExecutablePath(QUrl(workingDir.path() + "/ScreenPlayWidget" + ScreenPlayUtil::executableBinEnding())); + m_globalVariables->setWallpaperExecutablePath(QUrl(workingDir.path() + "/ScreenPlayWallpaper" + ScreenPlayUtil::executableBinEnding())); #endif -#if defined(Q_OS_OSX) - m_globalVariables->setWidgetExecutablePath(QUrl::fromUserInput(workingDir.path() + "ScreenPlayWidget.app/Contents/MacOS/ScreenPlayWidget").toLocalFile()); - m_globalVariables->setWallpaperExecutablePath(QUrl::fromUserInput(workingDir.path() + "ScreenPlayWallpaper.app/Contents/MacOS/ScreenPlayWallpaper").toLocalFile()); +#ifdef Q_OS_OSX + + workingDir.cdUp(); + workingDir.cdUp(); + workingDir.cdUp(); + + m_globalVariables->setWidgetExecutablePath(QUrl::fromUserInput(workingDir.path() + "/ScreenPlayWidget.app/Contents/MacOS/ScreenPlayWidget").toLocalFile()); + m_globalVariables->setWallpaperExecutablePath(QUrl::fromUserInput(workingDir.path() + "/ScreenPlayWallpaper.app/Contents/MacOS/ScreenPlayWallpaper").toLocalFile()); + #endif + + if (!QFileInfo::exists(m_globalVariables->widgetExecutablePath().toString())) { + qFatal("widget executable not found!"); + } + if (!QFileInfo::exists(m_globalVariables->wallpaperExecutablePath().toString())) { + qFatal("wallpaper executable not found!"); + } } /*! @@ -200,6 +179,53 @@ void Settings::restoreDefault(const QString& appConfigLocation, const QString& s writeJsonFileFromResource(settingsFileType); } +void Settings::initInstalledPath() +{ + //If empty use steam workshop location + qInfo() << m_qSettings.value("ScreenPlayContentPath").toString(); + if (QString(m_qSettings.value("ScreenPlayContentPath").toString()).isEmpty()) { + + /* + * ! We must use this (ugly) method, because to stay FOSS we cannot call the steamAPI here ! + * + * We start with the assumption that when we go up 2 folder. + * So that there must be at least a common folder: + * Windows example: + * From -> C:\Program Files (x86)\Steam\steamapps\common\ScreenPlay + * To -> C:\Program Files (x86)\Steam\steamapps\ + * Dest.-> C:\Program Files (x86)\Steam\steamapps\workshop\content\672870 + * + * When we reach the folder it _can_ contain a workshop folder when the user + * previously installed any workshop content. If the folder does not exsist we + * need to create it by hand. Normally Steam will create this folder but we need to + * set it here at this point so that the QFileSystemWatcher in InstalledListModel does + * not generate warnings. + */ + QDir dir; + QString appBasePath = QApplication::instance()->applicationDirPath(); + if (desktopEnvironment() == DesktopEnvironment::OSX) { + appBasePath += "/../../.."; + } + QString path = appBasePath + "/../../workshop/content/672870"; + qInfo() << path; + + if (!dir.mkpath(path)) { + qWarning() << "Could not create steam workshop path for path: " << path; + } + + if (QDir(path).exists()) { + m_globalVariables->setLocalStoragePath(QUrl::fromUserInput(path)); + m_qSettings.setValue("ScreenPlayContentPath", dir.cleanPath(path)); + m_qSettings.sync(); + } else { + qWarning() << "The following path could not be resolved to search for workshop content: " << path; + } + + } else { + m_globalVariables->setLocalStoragePath(QUrl::fromUserInput(m_qSettings.value("ScreenPlayContentPath").toString())); + } +} + /*! \brief Checks if there is already a saved language. If not we try to use the system langauge. If we do not support the system language we use english. diff --git a/ScreenPlay/src/settings.h b/ScreenPlay/src/settings.h index 48c48b27..2ca8ec6f 100644 --- a/ScreenPlay/src/settings.h +++ b/ScreenPlay/src/settings.h @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -185,19 +186,48 @@ public slots: void setAutostart(bool autostart) { - if (m_autostart == autostart) - return; + if (desktopEnvironment() == DesktopEnvironment::Windows) { -#ifdef Q_OS_WIN - QSettings settings("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat); - if (autostart) { - settings.setValue("ScreenPlay", QDir::toNativeSeparators(QCoreApplication::applicationFilePath()) + " -silent"); - settings.sync(); - } else { - settings.remove("ScreenPlay"); + QSettings settings("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat); + if (autostart) { + settings.setValue("ScreenPlay", QDir::toNativeSeparators(QCoreApplication::applicationFilePath()) + " -silent"); + settings.sync(); + } else { + settings.remove("ScreenPlay"); + } } -#endif + if (desktopEnvironment() == DesktopEnvironment::OSX) { + const QString plistFileName = "app.screenplay.plist"; + QFile defaultPListFile(":/assets/macos/" + plistFileName); + defaultPListFile.open(QIODevice::ReadOnly); + QString settingsPlistContent = defaultPListFile.readAll(); + if(!settingsPlistContent.contains("{{SCREENPLAY_PATH}}")){ + qCritical() << "Unable to load plist settings template from qrc to set autostart!"; + } + QDir workingDir(QGuiApplication::applicationDirPath()); + workingDir.cdUp(); + workingDir.cdUp(); + workingDir.cdUp(); + const QString screenPlayPath = QUrl::fromUserInput(workingDir.path() + "/ScreenPlay.app/Contents/MacOS/ScreenPlay").toLocalFile(); + settingsPlistContent.replace("{{SCREENPLAY_PATH}}", screenPlayPath); + settingsPlistContent.replace("{{SCREENPLAY_AUTOSTART}}", autostart ? "true":"false"); + + const QString homePath = QDir::homePath(); + QFile settingsPlist(homePath + "/Library/LaunchAgents/" + plistFileName); + if (settingsPlist.exists()) { + if(!settingsPlist.remove()){ + qCritical() << "Unable to remove: " << settingsPlist; + } + } + + settingsPlist.open(QIODevice::WriteOnly | QIODevice::Truncate); + QTextStream out(&settingsPlist); + out.setCodec("UTF-8"); + out << settingsPlistContent; + settingsPlist.flush(); + settingsPlist.close(); + } setqSetting("Autostart", autostart); m_autostart = autostart; @@ -371,6 +401,7 @@ public slots: private: void restoreDefault(const QString& appConfigLocation, const QString& settingsFileType); + void initInstalledPath(); private: QSettings m_qSettings; diff --git a/ScreenPlay/src/util.cpp b/ScreenPlay/src/util.cpp index 6188326f..b9968c68 100644 --- a/ScreenPlay/src/util.cpp +++ b/ScreenPlay/src/util.cpp @@ -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 } /*! diff --git a/ScreenPlaySDK/src/screenplaysdk.cpp b/ScreenPlaySDK/src/screenplaysdk.cpp index 22e51ba8..619960a1 100644 --- a/ScreenPlaySDK/src/screenplaysdk.cpp +++ b/ScreenPlaySDK/src/screenplaysdk.cpp @@ -149,6 +149,7 @@ void ScreenPlaySDK::readyRead() void ScreenPlaySDK::error(QLocalSocket::LocalSocketError socketError) { + Q_UNUSED(socketError) emit sdkDisconnected(); } diff --git a/ScreenPlayShader/CMakeLists.txt b/ScreenPlayShader/CMakeLists.txt index 709245b3..c81f5658 100644 --- a/ScreenPlayShader/CMakeLists.txt +++ b/ScreenPlayShader/CMakeLists.txt @@ -43,8 +43,18 @@ file(MAKE_DIRECTORY ${DESTDIR}) configure_file(qmldir ${DESTDIR} COPYONLY) -# Copies ScreenPlayShader.* into qt qml plugins folder -add_custom_command( - TARGET ${PROJECT_NAME} - POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ ${DESTDIR}/$) +if(APPLE) +add_custom_command(TARGET ${PROJECT_NAME} + POST_BUILD + COMMENT "Copying into ScreenPlay.app bundle" + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/bin/$ + ${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/$) +else() + # Copies ScreenPlayShader.* into qt qml plugins folder + add_custom_command( + TARGET ${PROJECT_NAME} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + $ + ${DESTDIR}/$) +endif() diff --git a/ScreenPlayUtil/inc/public/ScreenPlayUtil/util.h b/ScreenPlayUtil/inc/public/ScreenPlayUtil/util.h index fcd691b2..bf9acc11 100644 --- a/ScreenPlayUtil/inc/public/ScreenPlayUtil/util.h +++ b/ScreenPlayUtil/inc/public/ScreenPlayUtil/util.h @@ -56,7 +56,8 @@ bool copyPreviewThumbnail(QJsonObject& obj, const QString& previewThumbnail, con QString toString(const QStringList& list); QString toLocal(const QString& url); QString generateRandomString(quint32 length = 32); -QString executableEnding(); +QString executableAppEnding(); +QString executableBinEnding(); QStringList getAvailableWallpaper(); QStringList getAvailableWidgets(); QStringList getAvailableTypes(); diff --git a/ScreenPlayUtil/src/util.cpp b/ScreenPlayUtil/src/util.cpp index f03b6b61..5f92d39b 100644 --- a/ScreenPlayUtil/src/util.cpp +++ b/ScreenPlayUtil/src/util.cpp @@ -114,13 +114,26 @@ QString generateRandomString(quint32 length) /*! \brief Return .exe on windows otherwise empty string. */ -QString executableEnding() +QString executableBinEnding() { #ifdef Q_OS_WIN return ".exe"; -#else - return ""; #endif + return ""; +} + +/*! + \brief Return .exe on windows, .app on osx otherwise empty string. +*/ +QString executableAppEnding() +{ +#ifdef Q_OS_WIN + return ".exe"; +#endif +#ifdef Q_OS_OSX + return ".app"; +#endif + return ""; } /*! diff --git a/ScreenPlayWallpaper/CMakeLists.txt b/ScreenPlayWallpaper/CMakeLists.txt index 024ee309..beee0328 100644 --- a/ScreenPlayWallpaper/CMakeLists.txt +++ b/ScreenPlayWallpaper/CMakeLists.txt @@ -41,8 +41,13 @@ if(WIN32) target_link_libraries(${PROJECT_NAME} PRIVATE shcore.lib) endif() +target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Quick Qt5::Gui Qt5::Widgets Qt5::Core Qt5::WebEngine ScreenPlaySDK ScreenPlayUtil) + if(APPLE) - set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE true) + set_target_properties(${PROJECT_NAME} PROPERTIES + MACOSX_BUNDLE TRUE + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist + ) target_link_libraries(${PROJECT_NAME} PRIVATE "-framework Cocoa") endif() @@ -56,3 +61,4 @@ target_link_libraries( shcore.lib ScreenPlaySDK ScreenPlayUtil) + diff --git a/ScreenPlayWallpaper/Info.plist b/ScreenPlayWallpaper/Info.plist new file mode 100644 index 00000000..c7789c62 --- /dev/null +++ b/ScreenPlayWallpaper/Info.plist @@ -0,0 +1,28 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFile + + CFBundleIdentifier + app.screen-play.wallpaper + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleVersion + 1.0 + CFBundleDisplayName + ScreenPlayWallpaper + NSUIElement + 1 + LSUIElement + 1 + + diff --git a/ScreenPlayWallpaper/Wallpaper.qml b/ScreenPlayWallpaper/Wallpaper.qml index c3c743a2..7428eb5c 100644 --- a/ScreenPlayWallpaper/Wallpaper.qml +++ b/ScreenPlayWallpaper/Wallpaper.qml @@ -136,8 +136,10 @@ Rectangle { source: { if (Qt.platform.os === "windows") return Qt.resolvedUrl("file:///" + Wallpaper.windowsDesktopProperties.wallpaperPath); - + else + return "" } + Component.onCompleted: { if (Qt.platform.os !== "windows") { root.canFadeByWallpaperFillMode = false; @@ -308,7 +310,12 @@ Rectangle { } Text { - text: "imgCover.source " + Qt.resolvedUrl("file:///" + Wallpaper.windowsDesktopProperties.wallpaperPath) + text: { + if (Qt.platform.os === "windows") + return "imgCover.source " + Qt.resolvedUrl("file:///" + Wallpaper.windowsDesktopProperties.wallpaperPath) + else + return "" + } font.pointSize: 14 } diff --git a/ScreenPlayWallpaper/main.cpp b/ScreenPlayWallpaper/main.cpp index 2227a9d2..d2621af7 100644 --- a/ScreenPlayWallpaper/main.cpp +++ b/ScreenPlayWallpaper/main.cpp @@ -38,7 +38,7 @@ int main(int argc, char* argv[]) #elif defined(Q_OS_LINUX) LinuxWindow window({ 0 }, "test", "appid", "1", "fill", false); #elif defined(Q_OS_OSX) - MacWindow window({ 0 }, "test", "appid", "1", "fill"); + MacWindow window({ 0 }, "test", "appID=test", "1", "fill","videoWallpaper", true, true); #endif return app.exec(); } @@ -89,12 +89,14 @@ int main(int argc, char* argv[]) checkWallpaperVisible); #elif defined(Q_OS_OSX) MacWindow window( - activeScreensList.value(), - projectPath, - appID, - fillmode, - volume, - checkWallpaperVisible); + activeScreensList.value(), + projectFilePath, + appID, + volume, + fillmode, + type, + checkWallpaperVisible, + debugMode); #endif return app.exec(); diff --git a/ScreenPlayWallpaper/src/basewindow.cpp b/ScreenPlayWallpaper/src/basewindow.cpp index 4fc3a29f..b6fc599c 100644 --- a/ScreenPlayWallpaper/src/basewindow.cpp +++ b/ScreenPlayWallpaper/src/basewindow.cpp @@ -32,6 +32,7 @@ BaseWindow::BaseWindow( , m_debugMode(debugMode) , m_sdk(std::make_unique(appID, type)) { + qInfo() << "parent"; QApplication::instance()->installEventFilter(this); qRegisterMetaType(); diff --git a/ScreenPlayWallpaper/src/macwindow.cpp b/ScreenPlayWallpaper/src/macwindow.cpp index 909cc52d..bf983b1a 100644 --- a/ScreenPlayWallpaper/src/macwindow.cpp +++ b/ScreenPlayWallpaper/src/macwindow.cpp @@ -2,46 +2,56 @@ MacWindow::MacWindow( const QVector& activeScreensList, - const QString& projectPath, - const QString& id, + const QString& projectFilePath, + const QString& appID, const QString& volume, - const QString& fillmode) - : BaseWindow(projectPath, activeScreensList, false) + const QString& fillmode, + const QString& type, + const bool checkWallpaperVisible, + const bool debugMode) + : BaseWindow( + activeScreensList, + projectFilePath, + type, + checkWallpaperVisible, + appID, + debugMode) { - setAppID(id); + + connect(sdk(), &ScreenPlaySDK::sdkDisconnected, this, &MacWindow::destroyThis); + connect(sdk(), &ScreenPlaySDK::incommingMessage, this, &MacWindow::messageReceived); + connect(sdk(), &ScreenPlaySDK::replaceWallpaper, this, &MacWindow::replaceWallpaper); + bool ok = false; float volumeParsed = volume.toFloat(&ok); if (!ok) { qFatal("Could not parse volume"); } setVolume(volumeParsed); + setFillMode(fillmode); // Ether for one Screen or for all if ((QApplication::screens().length() == activeScreensList.length()) && (activeScreensList.length() != 1)) { //setupWallpaperForAllScreens(); } else if (activeScreensList.length() == 1) { - //setupWallpaperForOneScreen(activeScreensList.at(0)); - auto* screen = QGuiApplication::screens().at(0); - m_window.setWidth(screen->geometry().width()); - m_window.setHeight(screen->geometry().height()); + auto* screen = QGuiApplication::screens().at(activeScreensList.at(0)); + m_window.setGeometry(screen->geometry()); } else if (activeScreensList.length() > 1) { - //setupWallpaperForMultipleScreens(activeScreensList); } + qmlRegisterSingletonInstance("ScreenPlayWallpaper", 1, 0, "Wallpaper", this); + // WARNING: Setting Window flags must be called *here*! Qt::WindowFlags flags = m_window.flags(); m_window.setFlags(flags | Qt::FramelessWindowHint | Qt::Desktop); - m_window.setResizeMode(QQuickView::ResizeMode::SizeRootObjectToView); - m_window.rootContext()->setContextProperty("window", this); - // Instead of setting "renderType: Text.NativeRendering" every time - - // we can set it here once :) m_window.setTextRenderType(QQuickWindow::TextRenderType::NativeTextRendering); m_window.setSource(QUrl("qrc:/Wallpaper.qml")); MacIntegration* macIntegration = new MacIntegration(this); macIntegration->SetBackgroundLevel(&m_window); + + sdk()->start(); } void MacWindow::setVisible(bool show) diff --git a/ScreenPlayWallpaper/src/macwindow.h b/ScreenPlayWallpaper/src/macwindow.h index ad4ae00d..d47591fe 100644 --- a/ScreenPlayWallpaper/src/macwindow.h +++ b/ScreenPlayWallpaper/src/macwindow.h @@ -51,12 +51,14 @@ class MacWindow : public BaseWindow { Q_OBJECT public: - explicit MacWindow( - const QVector& activeScreensList, - const QString& projectPath, - const QString& id, + explicit MacWindow(const QVector& activeScreensList, + const QString& projectFilePath, + const QString& appID, const QString& volume, - const QString& fillmode); + const QString& fillmode, + const QString& type, + const bool checkWallpaperVisible, + const bool debugMode); signals: diff --git a/ScreenPlayWidget/CMakeLists.txt b/ScreenPlayWidget/CMakeLists.txt index 14376f4a..e7e4840e 100644 --- a/ScreenPlayWidget/CMakeLists.txt +++ b/ScreenPlayWidget/CMakeLists.txt @@ -31,7 +31,10 @@ if(WIN32) endif() if(APPLE) - set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE true) + set_target_properties(${PROJECT_NAME} PROPERTIES + MACOSX_BUNDLE TRUE + MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist + ) endif() target_link_libraries(${PROJECT_NAME} PRIVATE Qt${QT_VERSION_MAJOR}::Quick Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Widgets diff --git a/ScreenPlayWidget/Info.plist b/ScreenPlayWidget/Info.plist new file mode 100644 index 00000000..3efa504f --- /dev/null +++ b/ScreenPlayWidget/Info.plist @@ -0,0 +1,28 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIconFile + + CFBundleIdentifier + app.screen-play.widget + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + APPL + CFBundleVersion + 1.0 + CFBundleDisplayName + ScreenPlayWidget + NSUIElement + 1 + LSUIElement + 1 + + diff --git a/ScreenPlayWidget/src/widgetwindow.h b/ScreenPlayWidget/src/widgetwindow.h index 74ddcbf3..33b58c18 100644 --- a/ScreenPlayWidget/src/widgetwindow.h +++ b/ScreenPlayWidget/src/widgetwindow.h @@ -50,6 +50,7 @@ #include #include #include +#include #ifdef Q_OS_WIN #include diff --git a/Tools/Readme.md b/Tools/Readme.md new file mode 100644 index 00000000..a9afdecd --- /dev/null +++ b/Tools/Readme.md @@ -0,0 +1,15 @@ +## Tools + +This folder contains serveral python tools to help with development: +#### setup.py +- Installs third party dependencies for all platforms +#### build.py +- Build ScreenPlay locally +#### clang_format.py +- Invokers clang-format for all .cpp and .h files +#### qdoc.py +- Builds documentation for all projects into Docs/html +#### download_ffmpeg.py +- Donwload ffmpeg for macos only for now +#### qml_format.py +- Calls qmlformat for all qml files diff --git a/Tools/download_ffmpeg.py b/Tools/download_ffmpeg.py new file mode 100644 index 00000000..29780640 --- /dev/null +++ b/Tools/download_ffmpeg.py @@ -0,0 +1,36 @@ +import zipfile +from urllib.request import urlopen +import os + + +def download_and_extract(file_base_path, name): + print("Download: ", name) + + download_server_base_url = 'https://evermeet.cx/ffmpeg/' + filedata = urlopen(download_server_base_url + name) + datatowrite = filedata.read() + path_and_filename = os.path.join(file_base_path, name) + + print("Save tmp file: ", path_and_filename) + with open(path_and_filename, 'wb') as f: + f.write(datatowrite) + + extraction_path = os.path.join(file_base_path, "../Common/ffmpeg") + + print("Extract to:", extraction_path) + with zipfile.ZipFile(path_and_filename,"r") as zip_ref: + zip_ref.extractall(extraction_path) + + print("Delete tmp file: ", path_and_filename) + os.remove(path_and_filename) + +ffmpeg_7zip_name = 'ffmpeg-4.4.zip' +ffprobe_7zip_name = 'ffprobe-4.4.zip' +current_path = os.path.join(os.path.abspath(os.getcwd()),"") +extraction_path = os.path.abspath(os.path.join(current_path, "../Common/ffmpeg")) + +if not os.path.exists(extraction_path): + os.makedirs(extraction_path) + +download_and_extract(current_path, ffmpeg_7zip_name) +download_and_extract(current_path, ffprobe_7zip_name) diff --git a/Tools/setup.py b/Tools/setup.py index e4f6a27d..99e1f53d 100644 --- a/Tools/setup.py +++ b/Tools/setup.py @@ -30,7 +30,7 @@ if __name__ == "__main__": vcpkg_path = os.path.join(project_source_parent_path, "ScreenPlay-vcpkg") print("vcpkg_path: ", vcpkg_path) - vcpkg_version = "5568f11" # https://github.com/microsoft/vcpkg/releases/tag/2021.05.12 + vcpkg_version = "680b27d15f4d62bc6181fd33dc5259482b0890b1" # Master 10.06.2021 print("Build vcpkg ", vcpkg_version) execute("git fetch", vcpkg_path) execute("git checkout {}".format(vcpkg_version), vcpkg_path) @@ -39,7 +39,6 @@ if __name__ == "__main__": "openssl-unix", "sentry-native", "doctest", - "benchmark", ] vcpkg_triplet = "" @@ -53,18 +52,21 @@ if __name__ == "__main__": vcpkg_triplet = "x64-windows" elif sys.platform == "darwin": vcpkg_packages_list.append("infoware[opencl]") - execute("bootstrap-vcpkg.sh", vcpkg_path, False) - execute("chmod +x vcpkg", vcpkg_path) - vcpkg_triplet = "x64-linux" - elif sys.platform == "linux": - vcpkg_packages_list.append("infoware[opencl]") - execute("bootstrap-vcpkg.sh", vcpkg_path, False) + 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) vcpkg_triplet = "x64-osx" + elif sys.platform == "linux": + vcpkg_packages_list.append("infoware[opencl]") + execute("chmod +x bootstrap-vcpkg.sh", vcpkg_path) + execute("./bootstrap-vcpkg.sh", vcpkg_path, False) + execute("chmod +x vcpkg", vcpkg_path) + vcpkg_triplet = "x64-linux" vcpkg_packages = " ".join(vcpkg_packages_list) - execute("vcpkg{} update".format(executable_file_suffix), vcpkg_path, False) - execute("vcpkg{} upgrade --no-dry-run".format(executable_file_suffix), + execute("./vcpkg{} update".format(executable_file_suffix), vcpkg_path, False) + execute("./vcpkg{} upgrade --no-dry-run".format(executable_file_suffix), vcpkg_path, False) - execute("vcpkg{} install {} --triplet {} --recurse".format(executable_file_suffix, + execute("./vcpkg{} install {} --triplet {} --recurse".format(executable_file_suffix, vcpkg_packages, vcpkg_triplet), vcpkg_path, False)