From 6bfdd9894c005a6e9bd3aad0e085c7ce2aa7c080 Mon Sep 17 00:00:00 2001 From: Elias Steurer Date: Sat, 18 Dec 2021 13:24:03 +0100 Subject: [PATCH] Fix steam plugin loading --- ScreenPlay/app.cpp | 5 +--- ScreenPlay/app.h | 2 -- ScreenPlayWallpaper/CMakeLists.txt | 1 + ScreenPlayWorkshop/CMakeLists.txt | 40 ++++++++++++++---------------- Tools/build.py | 6 +---- 5 files changed, 22 insertions(+), 32 deletions(-) diff --git a/ScreenPlay/app.cpp b/ScreenPlay/app.cpp index d73ded68..0cdde83b 100644 --- a/ScreenPlay/app.cpp +++ b/ScreenPlay/app.cpp @@ -209,11 +209,8 @@ void App::init() } qmlRegisterSingletonInstance("ScreenPlay", 1, 0, "ScreenPlay", this); + QGuiApplication::instance()->addLibraryPath(QGuiApplication::instance()->applicationDirPath()); -#ifdef Q_OS_MACOS - // Needed for macos .app files - m_mainWindowEngine->addPluginPath(QGuiApplication::instance()->applicationDirPath()); -#endif m_mainWindowEngine->load(QUrl(QStringLiteral("qrc:/ScreenPlay/main.qml"))); // Must be called last to display a error message on startup by the qml engine diff --git a/ScreenPlay/app.h b/ScreenPlay/app.h index 40efdd7a..b78f56f0 100644 --- a/ScreenPlay/app.h +++ b/ScreenPlay/app.h @@ -64,7 +64,6 @@ #include #include -class ScreenPlayWorkshopPlugin; namespace ScreenPlay { @@ -217,7 +216,6 @@ public slots: } private: - QPluginLoader m_workshopPlugin; QNetworkAccessManager m_networkAccessManager; QElapsedTimer m_continuousIntegrationMetricsTimer; std::unique_ptr m_mainWindowEngine; diff --git a/ScreenPlayWallpaper/CMakeLists.txt b/ScreenPlayWallpaper/CMakeLists.txt index 3d7a1dc0..43a2fb15 100644 --- a/ScreenPlayWallpaper/CMakeLists.txt +++ b/ScreenPlayWallpaper/CMakeLists.txt @@ -71,6 +71,7 @@ target_link_libraries( if(APPLE) 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") + file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin/${PROJECT_NAME}.app/Contents/MacOS/) add_custom_command( TARGET ${PROJECT_NAME} POST_BUILD diff --git a/ScreenPlayWorkshop/CMakeLists.txt b/ScreenPlayWorkshop/CMakeLists.txt index 915b1401..bb6cce28 100644 --- a/ScreenPlayWorkshop/CMakeLists.txt +++ b/ScreenPlayWorkshop/CMakeLists.txt @@ -42,6 +42,7 @@ if(WIN32) set(STEAM_BIN "${STEAM_LIB_PATH}/win64/steam_api64.dll") elseif(APPLE) set(WORKSHOP_PLUGIN_DIR ${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/Workshop) + set(MACOS_FRAMEWORKS_DIR ${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/Frameworks/) set(STEAM_LIB "${STEAM_LIB_PATH}/osx/libsteam_api.dylib") set(STEAM_BIN ${STEAM_LIB}) elseif(UNIX) @@ -50,38 +51,35 @@ elseif(UNIX) set(STEAM_BIN ${STEAM_LIB}) endif() +add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADER}) +target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Core Qt6::Quick ${STEAM_LIB} ScreenPlayUtil SteamSDK) + qt_add_qml_module( ${PROJECT_NAME} - OUTPUT_DIRECTORY ${WORKSHOP_PLUGIN_DIR} + OUTPUT_DIRECTORY + ${WORKSHOP_PLUGIN_DIR} URI "Workshop" SOURCES ${SOURCES} ${HEADER} VERSION 1.0) -if(APPLE) - if(${SCREENPLAY_STEAM}) - add_custom_command( - TARGET ${PROJECT_NAME} - POST_BUILD - COMMENT "Copying steam_appid.txt into ScreenPlay.app bundle. This is for development only!" - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/steam_appid.txt - ${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/) - add_custom_command( - TARGET ${PROJECT_NAME} - POST_BUILD - COMMENT "Copying libsteam_api.dylib into ScreenPlay.app bundle." - COMMAND ${CMAKE_COMMAND} -E copy ${STEAM_LIB} - ${WORKSHOP_PLUGIN_DIR}) - endif() -else() - if(${SCREENPLAY_STEAM}) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/steam_appid.txt ${CMAKE_BINARY_DIR}/bin/steam_appid.txt COPYONLY) - configure_file(${STEAM_BIN} ${CMAKE_BINARY_DIR}/bin/ COPYONLY) +if(${SCREENPLAY_STEAM}) + if(APPLE) + file(MAKE_DIRECTORY ${WORKSHOP_PLUGIN_DIR}) + file(MAKE_DIRECTORY ${MACOS_FRAMEWORKS_DIR}) + + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/steam_appid.txt ${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/ COPYONLY) + configure_file(${STEAM_BIN} ${WORKSHOP_PLUGIN_DIR} COPYONLY) + + set_target_properties(${PROJECT_NAME} PROPERTIES + LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/Workshop) + else() + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/steam_appid.txt ${CMAKE_BINARY_DIR}/bin/steam_appid.txt COPYONLY) + configure_file(${STEAM_BIN} ${CMAKE_BINARY_DIR}/bin/ COPYONLY) endif() endif() - # Needed by the automatic generated target missing includes # https://github.com/qt/qtdeclarative/blob/7a7064e14f094e843e1ee832cc927e86f887621a/src/qml/Qt6QmlMacros.cmake#L2042 target_include_directories(${PROJECT_NAME} PUBLIC src/) diff --git a/Tools/build.py b/Tools/build.py index 0afdf09b..10744e42 100644 --- a/Tools/build.py +++ b/Tools/build.py @@ -49,8 +49,7 @@ if not args.build_type: qt_version = "6.2.1" steam_build = "OFF" if args.steam_build: - if args.steam_build: - steam_build = "ON" + steam_build = "ON" print("Starting build with type %s. Qt Version: %s" % (args.build_type, qt_version)) @@ -142,9 +141,6 @@ execute(deploy_command.format( executable_file_ending=executable_file_ending)) if platform == "darwin" and args.sign_build: - print("Remove workshop build folder (macos only).") - shutil.rmtree(build_folder + "/bin/workshop") - execute("codesign --deep -f -s \"Developer ID Application: Elias Steurer (V887LHYKRH)\" --timestamp --options \"runtime\" -f --entitlements \"../../ScreenPlay/entitlements.plist\" --deep \"ScreenPlay.app/\"") execute("codesign --deep -f -s \"Developer ID Application: Elias Steurer (V887LHYKRH)\" --timestamp --options \"runtime\" -f --deep \"ScreenPlayWallpaper.app/\"") execute("codesign --deep -f -s \"Developer ID Application: Elias Steurer (V887LHYKRH)\" --timestamp --options \"runtime\" -f --deep \"ScreenPlayWidget.app/\"")