1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-22 02:32:29 +01:00

Refactor mac build to be all included into ScreenPlay.app

this also is for all tests now

Fix macos ScreenPlay.app icon
This commit is contained in:
Elias Steurer 2023-11-30 09:51:12 +01:00
parent cfe0b2b3e5
commit dfe9e60c46
28 changed files with 106 additions and 86 deletions

View File

@ -61,7 +61,3 @@
- git submodule update --init --recursive
tags:
- osx
artifacts:
expire_in: "2 weeks"
paths:
- build-64-osx-universal-release/bin/

View File

@ -10,7 +10,12 @@ standalone_osx:
extends:
- .base_osx_build
script:
- python3 Tools/build.py --type=release --use-aqt --deploy-version --sign_osx
- python3 Tools/build.py --type=release --use-aqt --installer --deploy-version --sign_osx
- mv build-64-osx-universal-release/ScreenPlay-Installer-ScreenPlayComponent.dmg build-64-osx-universal-release/ScreenPlay-Installer.dmg
artifacts:
expire_in: "2 weeks"
paths:
- build-64-osx-universal-release/ScreenPlay-Installer.dmg
standalone_linux:
stage: build
@ -32,10 +37,14 @@ steam_osx:
- .base_osx_build
script:
- python3 Tools/build.py --type=release -steam --use-aqt --deploy-version --sign_osx
artifacts:
expire_in: "2 weeks"
paths:
- build-64-osx-universal-release/bin/ScreenPlay.app
steam_linux:
stage: build_steam
extends:
- .base_linux_build
script:
- python3 Tools/build.py --type=release -steam --deploy-version --use-aqt --installer
- python3 Tools/build.py --type=release -steam --use-aqt --deploy-version

View File

@ -25,7 +25,7 @@ set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
set(CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE ON)
set(MACOSX_BUNDLE_BUNDLE_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
set(MACOSX_BUNDLE_ICON_FILE "${CMAKE_SOURCE_DIR}/CMake/exampleApp.icns")
set(MACOSX_BUNDLE_ICON_FILE "${CMAKE_SOURCE_DIR}/ScreenPlay/assets/icons/ScreenPlay.icns")
set(CPACK_DMG_DS_STORE_SETUP_SCRIPT "${CMAKE_SOURCE_DIR}/CMake/DS_Store.scpt")
set(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_SOURCE_DIR}/CMake/dmg_background.png")
set(MACOSX_BUNDLE_INFO_PLIST "${CMAKE_SOURCE_DIR}/CMake/MacOSXBundleInfo.plist.in")

View File

@ -83,7 +83,6 @@ else()
message(FATAL_ERROR "Unsupported OS")
endif()
option(SCREENPLAY_OSX_BUNDLE "Enable distribution macOS bundle" OFF)
option(SCREENPLAY_STEAM "For FOSS distribution so we do not bundle proprietary code." ON)
option(SCREENPLAY_DEPLOY "Marks this version as an official deploy version. This version uses different import paths and other settings."
OFF)

View File

@ -329,16 +329,11 @@ if(${SCREENPLAY_TESTS})
if(${SCREENPLAY_STEAM})
target_link_libraries(tst_ScreenPlay PUBLIC ScreenPlayWorkshopplugin ScreenPlayWorkshop)
endif()
endif()
if(APPLE AND NOT SCREENPLAY_OSX_BUNDLE)
set_source_files_properties(
${TS_FILES} PROPERTIES OUTPUT_LOCATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}.app/Contents/Resources/translations")
else()
set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/translations")
if(APPLE)
set_target_properties(tst_ScreenPlay PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/")
endif()
endif()
qt_add_lrelease(${PROJECT_NAME} TS_FILES ${TS_FILES})
target_include_directories(
ScreenPlayApp
@ -382,30 +377,22 @@ if(WIN32)
endif()
if(APPLE AND SCREENPLAY_OSX_BUNDLE)
# Set the installation destination
install(TARGETS "ScreenPlay" DESTINATION /Applications)
if(APPLE)
include(InstallRequiredSystemLibraries)
set(CPACK_GENERATOR "Bundle")
set(CPACK_BINARY_DRAGNDROP ON)
set(CPACK_BUNDLE_NAME "ScreenPlay")
set(CPACK_BUNDLE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/assets/icons/app.ico")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/assets/icons/app.ico")
set(CPACK_BUNDLE_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist")
set(CPACK_BUNDLE_APPLE_ENTITLEMENTS "${CMAKE_CURRENT_SOURCE_DIR}/entitlements.plist")
set(CPACK_PACKAGE_FILE_NAME "ScreenPlay-0.15")
include(CPack)
# Set the path to the icon file
set(APP_ICON_MACOSX ${CMAKE_CURRENT_SOURCE_DIR}/assets/icons/ScreenPlay.icns)
# Install all files from /bin
install(
DIRECTORY "${CMAKE_BINARY_DIR}/bin/"
COMPONENT ScreenPlay
DESTINATION "./")
# Tell CMake where to find the icon
set_source_files_properties(${APP_ICON_MACOSX} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
endif()
set(RESOURCES_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ScreenPlay.app/Contents/Resources")
file(MAKE_DIRECTORY ${RESOURCES_DIR})
# Specify the name of the icon file for the bundle
set(MACOSX_BUNDLE_ICON_FILE ScreenPlay.icns) # Only the file name
# Fore some reason this only works with maually copy
configure_file(${APP_ICON_MACOSX} "${RESOURCES_DIR}/ScreenPlay.icns" COPYONLY)
if(APPLE AND NOT SCREENPLAY_OSX_BUNDLE)
# Creates a ScreenPlay.app
set_target_properties(
${PROJECT_NAME}
@ -413,12 +400,13 @@ if(APPLE AND NOT SCREENPLAY_OSX_BUNDLE)
MACOSX_BUNDLE TRUE
MACOSX_RPATH TRUE
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist
MACOSX_FRAMEWORK_IDENTIFIER screen-play.app
MACOSX_FRAMEWORK_IDENTIFIER app.screenplay
XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@loader_path/Libraries"
RESOURCE "${RESOURCE_FILES}"
RESOURCE "${RESOURCE_FILES};${APP_ICON_MACOSX}" # Include the icon in the resources
XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME TRUE
XCODE_ATTRIBUTE_EXECUTABLE_NAME ${PROJECT_NAME})
add_custom_command(
TARGET ${PROJECT_NAME}
POST_BUILD
@ -431,28 +419,24 @@ if(APPLE AND NOT SCREENPLAY_OSX_BUNDLE)
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/ffmpeg/ffprobe
${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/)
# tst_ScreenPlay needs ffmpeg in the base path
if(${SCREENPLAY_TESTS})
add_custom_command(
TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/ffmpeg/ffmpeg ${CMAKE_BINARY_DIR}/bin/)
add_custom_command(
TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/ffmpeg/ffprobe ${CMAKE_BINARY_DIR}/bin/)
endif()
# fonts
include(CopyRecursive)
set(FONTS_OUT_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ScreenPlay.app/Contents/Resources/fonts/)
set(FONTS_OUT_DIR "${RESOURCES_DIR}/fonts")
file(MAKE_DIRECTORY ${FONTS_OUT_DIR})
copy_recursive(${CMAKE_CURRENT_SOURCE_DIR}/assets/fonts ${FONTS_OUT_DIR} "*.ttf")
copy_recursive(${CMAKE_CURRENT_SOURCE_DIR}/assets/fonts ${FONTS_OUT_DIR} "*.otf")
# .qm translations
set(QM_OUT_DIR "${RESOURCES_DIR}/translations")
file(MAKE_DIRECTORY ${QM_OUT_DIR})
set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION ${QM_OUT_DIR})
endif()
# Must be called here, because we need to change the
# OUTPUT_LOCATION for macos
qt_add_lrelease(${PROJECT_NAME} TS_FILES ${TS_FILES} )
# Note: We need the variables in the lib and exe!
generate_cmake_variable_header(${PROJECT_NAME})
generate_cmake_variable_header(ScreenPlayApp)

View File

@ -7,9 +7,9 @@
<key>CFBundleExecutable</key>
<string>ScreenPlay</string>
<key>CFBundleIconFile</key>
<string></string>
<string>ScreenPlay</string>
<key>CFBundleIdentifier</key>
<string>app.screen-play</string>
<string>app.screenplay</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>

View File

@ -0,0 +1,33 @@
Create icons. Replace `\` with `^` on windows.
```
convert app.png -resize 16x16 ScreenPlay.iconset/icon_16x16.png \
&& convert app.png -resize 32x32 ScreenPlay.iconset/icon_16x16@2x.png \
&& convert app.png -resize 32x32 ScreenPlay.iconset/icon_32x32.png \
&& convert app.png -resize 64x64 ScreenPlay.iconset/icon_32x32@2x.png \
&& convert app.png -resize 128x128 ScreenPlay.iconset/icon_128x128.png \
&& convert app.png -resize 256x256 ScreenPlay.iconset/icon_128x128@2x.png \
&& convert app.png -resize 256x256 ScreenPlay.iconset/icon_256x256.png \
&& convert app.png -resize 512x512 ScreenPlay.iconset/icon_256x256@2x.png \
&& convert app.png -resize 512x512 ScreenPlay.iconset/icon_512x512.png \
&& convert app.png -resize 1024x1024 ScreenPlay.iconset/icon_512x512@2x.png
// Convert to .icns
iconutil -c icns ScreenPlay.iconset
```
Convert for Windows .ico
```
magick convert app.png \
\( -clone 0 -resize 16x16 \) \
\( -clone 0 -resize 32x32 \) \
\( -clone 0 -resize 48x48 \) \
\( -clone 0 -resize 64x64 \) \
\( -clone 0 -resize 128x128 \) \
\( -clone 0 -resize 256x256 \) \
-delete 0 -background transparent app.ico
```
Make the 1k logo smaller
```
convert app.png -resize 512x512 app_icon.png
```

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 271 KiB

After

Width:  |  Height:  |  Size: 128 KiB

BIN
ScreenPlay/assets/icons/app.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

View File

@ -163,18 +163,18 @@ void Settings::setupWidgetAndWindowPaths()
m_globalVariables->setGodotWallpaperExecutablePath(QUrl(workingDir.path() + "/ScreenPlayWallpaperGodot" + ScreenPlayUtil::executableBinEnding()));
const auto godotEditorName = "Godot_" + godotVersion + "_win64.exe";
m_globalVariables->setGodotEditorExecutablePath(QUrl(workingDir.path() + "/" + godotEditorName));
} else if (osType == "macos") {
// ScreenPlayTest is not bundled in an .app so the working directory
// the the same as the executable.
if (QFileInfo(QCoreApplication::applicationFilePath()).fileName() != "tst_ScreenPlay") {
workingDir.cdUp();
workingDir.cdUp();
workingDir.cdUp();
if (!QFileInfo::exists(m_globalVariables->godotWallpaperExecutablePath().toString())) {
qInfo() << "godotWallpaperExecutablePath:" << m_globalVariables->godotWallpaperExecutablePath();
qCritical("Godot Wallpaper not found");
}
const QString basePath = "/ScreenPlay.app/Contents/MacOS/";
m_globalVariables->setWidgetExecutablePath(QUrl::fromUserInput(workingDir.path() + basePath + "ScreenPlayWidget").toLocalFile());
m_globalVariables->setWallpaperExecutablePath(QUrl::fromUserInput(workingDir.path() + basePath + "ScreenPlayWallpaper").toLocalFile());
m_globalVariables->setGodotWallpaperExecutablePath(QUrl(workingDir.path() + basePath + "ScreenPlayWallpaperGodot").toLocalFile());
if (!QFileInfo::exists(m_globalVariables->godotEditorExecutablePath().toString())) {
qInfo() << "godotEditorExecutablePath :" << m_globalVariables->godotEditorExecutablePath();
qCritical("Godot Editor not found");
}
} else if (osType == "macos") {
m_globalVariables->setWidgetExecutablePath(QUrl::fromUserInput(workingDir.path() + "/ScreenPlayWidget").toLocalFile());
m_globalVariables->setWallpaperExecutablePath(QUrl::fromUserInput(workingDir.path() + "/ScreenPlayWallpaper").toLocalFile());
m_globalVariables->setGodotWallpaperExecutablePath(QUrl(workingDir.path() + "/ScreenPlayWallpaperGodot").toLocalFile());
const auto godotEditorName = "Godot_" + godotVersion + "-stable_osx.universal";
m_globalVariables->setGodotEditorExecutablePath(QUrl(workingDir.path() + "/" + godotEditorName));
} else if (osType == "linux" || osType == "ubuntu") {
@ -187,14 +187,6 @@ void Settings::setupWidgetAndWindowPaths()
qFatal("OS not supported.");
}
if (!QFileInfo::exists(m_globalVariables->godotWallpaperExecutablePath().toString())) {
qInfo() << "godotWallpaperExecutablePath:" << m_globalVariables->godotWallpaperExecutablePath();
qCritical("Godot Wallpaper not found");
}
if (!QFileInfo::exists(m_globalVariables->godotEditorExecutablePath().toString())) {
qInfo() << "godotEditorExecutablePath :" << m_globalVariables->godotEditorExecutablePath();
qCritical("Godot Editor not found");
}
if (!QFileInfo::exists(m_globalVariables->widgetExecutablePath().toString())) {
qInfo() << "widgetExecutablePath:" << m_globalVariables->widgetExecutablePath();
qCritical("widget executable not found!");

View File

@ -71,4 +71,7 @@ qt6_add_shaders(
if(${SCREENPLAY_TESTS})
qt_add_executable(tst_ScreenPlayShader src/TestMain.cpp)
target_link_libraries(tst_ScreenPlayShader PRIVATE Qt::Quick ${PROJECT_NAME}plugin)
if(APPLE)
set_target_properties(tst_ScreenPlayShader PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/")
endif()
endif()

View File

@ -112,14 +112,13 @@ endif()
if(APPLE)
target_link_libraries(${PROJECT_NAME} PRIVATE "-framework Cocoa")
if(NOT SCREENPLAY_OSX_BUNDLE)
add_custom_command(
TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/index.html
${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/)
set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/")
endif()
endif()
if(WIN32)

View File

@ -266,4 +266,8 @@ qt_add_qml_module(
if(${SCREENPLAY_TESTS})
qt_add_executable(tst_ScreenPlayWeather src/TestMain.cpp)
target_link_libraries(tst_ScreenPlayWeather PRIVATE Qt6::Quick ${PROJECT_NAME}plugin)
if(APPLE)
set_target_properties(tst_ScreenPlayWeather PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/")
endif()
endif()

View File

@ -76,7 +76,7 @@ if(WIN32)
set_property(TARGET ${PROJECT_NAME} PROPERTY WIN32_EXECUTABLE true)
endif()
if(APPLE AND NOT SCREENPLAY_OSX_BUNDLE)
if(APPLE)
set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/")
endif()

View File

@ -122,14 +122,11 @@ qt_add_qml_module(
${RESOURCES})
if(${SCREENPLAY_STEAM})
if(APPLE AND NOT SCREENPLAY_OSX_BUNDLE)
if(APPLE)
set(MACOS_FRAMEWORKS_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ScreenPlay.app/Contents/MacOS/)
file(MAKE_DIRECTORY ${MACOS_FRAMEWORKS_DIR})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/steam_appid.txt ${MACOS_FRAMEWORKS_DIR} COPYONLY)
configure_file(${STEAM_BIN} ${MACOS_FRAMEWORKS_DIR} COPYONLY)
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()
if(${SCREENPLAY_TESTS})
@ -142,5 +139,9 @@ if(${SCREENPLAY_STEAM})
ScreenPlayUtilplugin
SteamSDK
SteamSDKQtEnums)
if(APPLE)
set_target_properties(tst_ScreenPlayWorkshop PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/ScreenPlay.app/Contents/MacOS/")
endif()
endif()
endif()