Skip to content

Commit d7f8efe

Browse files
qiin2333qiin2333
andauthored
fix: build and packaging (#107)
* build(deps): update * update deps * refactor(installer/windows): move nsis code (LizardByte#3915) * Merge branch 'master' into dev --------- Co-authored-by: qiin2333 <[email protected]>
1 parent 6f073c0 commit d7f8efe

File tree

16 files changed

+416
-243
lines changed

16 files changed

+416
-243
lines changed

.codeql-prebuild-cpp-Windows.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -e
44
# update pacman
55
pacman --noconfirm -Syu
66

7-
gcc_version="14.2.0-3"
7+
gcc_version="15.1.0-5"
88

99
broken_deps=(
1010
"mingw-w64-ucrt-x86_64-gcc"
@@ -47,11 +47,13 @@ pacman -Syu --noconfirm --ignore="$(IFS=,; echo "${broken_deps[*]}")" "${depende
4747

4848
# build
4949
mkdir -p build
50-
cd build || exit 1
5150
cmake \
51+
-B build \
52+
-G Ninja \
53+
-S . \
5254
-DBUILD_DOCS=OFF \
53-
-G "MinGW Makefiles" ..
54-
mingw32-make -j"$(nproc)"
55+
-DBUILD_WERROR=ON
56+
ninja -C build
5557

5658
# skip autobuild
57-
echo "skip_autobuild=true" >> "$GITHUB_OUTPUT"
59+
echo "skip_autobuild=true" >> "$GITHUB_OUTPUT"

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ jobs:
117117
shell: msys2 {0}
118118
env:
119119
BRANCH: ${{ github.head_ref || github.ref_name }}
120-
BUILD_VERSION: ${{ needs.setup_release.outputs.release_tag }}.杂鱼
120+
BUILD_VERSION: ${{ needs.setup_release.outputs.release_tag }}
121121
COMMIT: ${{ needs.setup_release.outputs.release_commit }}
122122
run: |
123123
mkdir -p build

cmake/compile_definitions/common.cmake

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,9 @@ list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_ASSETS_DIR="${SUNSHINE_ASSETS_DIR_DEF}
131131

132132
list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_TRAY=${SUNSHINE_TRAY})
133133

134-
# Publisher metadata
135-
list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_PUBLISHER_NAME="${SUNSHINE_PUBLISHER_NAME}")
134+
# Publisher metadata - escape spaces for proper compilation
135+
string(REPLACE " " "_" SUNSHINE_PUBLISHER_NAME_SAFE "${SUNSHINE_PUBLISHER_NAME}")
136+
list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_PUBLISHER_NAME="${SUNSHINE_PUBLISHER_NAME_SAFE}")
136137
list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_PUBLISHER_WEBSITE="${SUNSHINE_PUBLISHER_WEBSITE}")
137138
list(APPEND SUNSHINE_DEFINITIONS SUNSHINE_PUBLISHER_ISSUE_URL="${SUNSHINE_PUBLISHER_ISSUE_URL}")
138139

cmake/compile_definitions/windows.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ list(APPEND SUNSHINE_COMPILE_OPTIONS -Wno-misleading-indentation)
1313
# see gcc bug 98723
1414
add_definitions(-DUSE_BOOST_REGEX)
1515

16+
# Fix for GCC 15 C++20 coroutine compatibility with WinRT
17+
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 15)
18+
# Add compiler flags to handle WinRT coroutine issues with GCC 15
19+
list(APPEND SUNSHINE_COMPILE_OPTIONS -Wno-template-body)
20+
add_definitions(-DWINRT_LEAN_AND_MEAN)
21+
# Force using experimental coroutine ABI for compatibility
22+
add_definitions(-D_ALLOW_COROUTINE_ABI_MISMATCH)
23+
endif()
24+
1625
# curl
1726
add_definitions(-DCURL_STATICLIB)
1827
include_directories(SYSTEM ${CURL_STATIC_INCLUDE_DIRS})

cmake/packaging/windows.cmake

Lines changed: 7 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
# windows specific packaging
2-
3-
# see options at: https://cmake.org/cmake/help/latest/cpack_gen/nsis.html
42
install(TARGETS sunshine RUNTIME DESTINATION "." COMPONENT application)
53

64
# Hardening: include zlib1.dll (loaded via LoadLibrary() in openssl's libcrypto.a)
@@ -39,9 +37,8 @@ install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/windows/misc/vdd/"
3937

4038
# Check if cmd directory exists
4139
if(EXISTS "${SUNSHINE_SOURCE_ASSETS_DIR}/windows/misc/cmd")
42-
# Convert path to native format for Windows
43-
file(TO_NATIVE_PATH "${SUNSHINE_SOURCE_ASSETS_DIR}/windows/misc/cmd" cmd_dir_native)
44-
install(DIRECTORY "${cmd_dir_native}/"
40+
# Use original path with forward slashes for CMake install command
41+
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/windows/misc/cmd/"
4542
DESTINATION "tools"
4643
COMPONENT superCmds)
4744
else()
@@ -62,81 +59,11 @@ file(TO_NATIVE_PATH "${SUNSHINE_SOURCE_ASSETS_DIR}/windows/assets/shaders" shade
6259
file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/assets/shaders" shaders_in_build_dest_native)
6360
execute_process(COMMAND cp -rpf "${shaders_in_build_src_native}" "${shaders_in_build_dest_native}")
6461

65-
# set(CPACK_NSIS_MUI_HEADERIMAGE "") # TODO: image should be 150x57 bmp
6662
set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}\\\\sunshine.ico")
67-
set(CPACK_NSIS_INSTALLED_ICON_NAME "${PROJECT__DIR}\\\\${PROJECT_EXE}")
63+
6864
# The name of the directory that will be created in C:/Program files/
6965
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}")
7066

71-
# Extra install commands
72-
# Restores permissions on the install directory
73-
# Migrates config files from the root into the new config folder
74-
# Install service
75-
SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS
76-
"${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}
77-
IfSilent +2 0
78-
CreateShortCut '\\\"$DESKTOP\\\\SunshineGUI.lnk\\\"' '\\\"$INSTDIR\\\\assets\\\\gui\\\\sunshine-gui.exe\\\"'
79-
ExecShell 'startpin' '\\\"$DESKTOP\\\\SunshineGUI.lnk\\\"'
80-
ExecShell 'open' 'https://docs.qq.com/aio/DSGdQc3htbFJjSFdO'
81-
nsExec::ExecToLog 'icacls \\\"$INSTDIR\\\" /reset'
82-
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\migrate-config.bat\\\"'
83-
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\add-firewall-rule.bat\\\"'
84-
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\install-vdd.bat\\\"'
85-
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\install-gamepad.bat\\\"'
86-
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\install-service.bat\\\"'
87-
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\autostart-service.bat\\\"'
88-
NoController:
89-
")
90-
91-
# Extra uninstall commands
92-
# Uninstall service
93-
set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS
94-
"${CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS}
95-
ExecShell 'startunpin' '\\\"$DESKTOP\\\\SunshineGUI.lnk\\\"'
96-
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\delete-firewall-rule.bat\\\"'
97-
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\uninstall-service.bat\\\"'
98-
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\uninstall-vdd.bat\\\"'
99-
nsExec::ExecToLog '\\\"$INSTDIR\\\\sunshine.exe\\\" --restore-nvprefs-undo'
100-
MessageBox MB_YESNO|MB_ICONQUESTION \
101-
'Do you want to remove Virtual Gamepad)?' \
102-
/SD IDNO IDNO NoGamepad
103-
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\uninstall-gamepad.bat\\\"'; skipped if no
104-
NoGamepad:
105-
MessageBox MB_YESNO|MB_ICONQUESTION \
106-
'Do you want to remove $INSTDIR (this includes the configuration, cover images, and settings)?' \
107-
/SD IDNO IDNO NoDelete
108-
RMDir /r \\\"$INSTDIR\\\"; skipped if no
109-
NoDelete:
110-
")
111-
112-
# Adding an option for the start menu
113-
set(CPACK_NSIS_MODIFY_PATH "OFF")
114-
set(CPACK_NSIS_EXECUTABLES_DIRECTORY ".")
115-
# This will be shown on the installed apps Windows settings
116-
set(CPACK_NSIS_INSTALLED_ICON_NAME "${CMAKE_PROJECT_NAME}.exe")
117-
set(CPACK_NSIS_CREATE_ICONS_EXTRA
118-
"${CPACK_NSIS_CREATE_ICONS_EXTRA}
119-
CreateShortCut '\$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\${CMAKE_PROJECT_NAME}.lnk' \
120-
'\$INSTDIR\\\\${CMAKE_PROJECT_NAME}.exe' '--shortcut'
121-
")
122-
set(CPACK_NSIS_DELETE_ICONS_EXTRA
123-
"${CPACK_NSIS_DELETE_ICONS_EXTRA}
124-
Delete '\$SMPROGRAMS\\\\$MUI_TEMP\\\\${CMAKE_PROJECT_NAME}.lnk'
125-
")
126-
127-
# Checking for previous installed versions
128-
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "ON")
129-
130-
set(CPACK_NSIS_HELP_LINK "https://sunshinestream.readthedocs.io/en/latest/about/installation.html")
131-
set(CPACK_NSIS_URL_INFO_ABOUT "${CMAKE_PROJECT_HOMEPAGE_URL}")
132-
set(CPACK_NSIS_CONTACT "${CMAKE_PROJECT_HOMEPAGE_URL}/support")
133-
134-
set(CPACK_NSIS_MENU_LINKS
135-
"https://sunshinestream.readthedocs.io" "Sunshine documentation"
136-
"https://app.lizardbyte.dev" "LizardByte Web Site"
137-
"https://app.lizardbyte.dev/support" "LizardByte Support")
138-
set(CPACK_NSIS_MANIFEST_DPI_AWARE true)
139-
14067
# Setting components groups and dependencies
14168
set(CPACK_COMPONENT_GROUP_CORE_EXPANDED true)
14269
set(CPACK_COMPONENT_GROUP_SCRIPTS_EXPANDED true)
@@ -184,3 +111,7 @@ set(CPACK_COMPONENT_VDD_DISPLAY_NAME "Zako Display Driver")
184111
set(CPACK_COMPONENT_VDD_DESCRIPTION "支持HDR的虚拟显示器驱动安装")
185112
set(CPACK_COMPONENT_VDD_REQUIRED OFF)
186113
set(CPACK_COMPONENT_VDD_GROUP "Scripts")
114+
115+
# include specific packaging
116+
include(${CMAKE_MODULE_PATH}/packaging/windows_nsis.cmake)
117+
include(${CMAKE_MODULE_PATH}/packaging/windows_wix.cmake)

cmake/packaging/windows_nsis.cmake

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# NSIS Packaging
2+
# see options at: https://cmake.org/cmake/help/latest/cpack_gen/nsis.html
3+
4+
set(CPACK_NSIS_INSTALLED_ICON_NAME "${PROJECT__DIR}\\\\${PROJECT_EXE}")
5+
6+
# Extra install commands
7+
# Restores permissions on the install directory
8+
# Migrates config files from the root into the new config folder
9+
# Install service
10+
SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS
11+
"${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}
12+
IfSilent +2 0
13+
CreateShortCut '\\\"$DESKTOP\\\\SunshineGUI.lnk\\\"' '\\\"$INSTDIR\\\\assets\\\\gui\\\\sunshine-gui.exe\\\"'
14+
ExecShell 'startpin' '\\\"$DESKTOP\\\\SunshineGUI.lnk\\\"'
15+
ExecShell 'open' 'https://docs.qq.com/aio/DSGdQc3htbFJjSFdO'
16+
nsExec::ExecToLog 'icacls \\\"$INSTDIR\\\" /reset'
17+
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\update-path.bat\\\" add'
18+
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\migrate-config.bat\\\"'
19+
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\add-firewall-rule.bat\\\"'
20+
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\install-gamepad.bat\\\"'
21+
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\install-service.bat\\\"'
22+
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\autostart-service.bat\\\"'
23+
NoController:
24+
")
25+
26+
# Extra uninstall commands
27+
# Uninstall service
28+
set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS
29+
"${CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS}
30+
ExecShell 'startunpin' '\\\"$DESKTOP\\\\SunshineGUI.lnk\\\"'
31+
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\delete-firewall-rule.bat\\\"'
32+
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\uninstall-service.bat\\\"'
33+
nsExec::ExecToLog '\\\"$INSTDIR\\\\${CMAKE_PROJECT_NAME}.exe\\\" --restore-nvprefs-undo'
34+
MessageBox MB_YESNO|MB_ICONQUESTION \
35+
'Do you want to remove Virtual Gamepad?' \
36+
/SD IDNO IDNO NoGamepad
37+
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\uninstall-gamepad.bat\\\"'; skipped if no
38+
NoGamepad:
39+
MessageBox MB_YESNO|MB_ICONQUESTION \
40+
'Do you want to remove $INSTDIR (this includes the configuration, cover images, and settings)?' \
41+
/SD IDNO IDNO NoDelete
42+
RMDir /r \\\"$INSTDIR\\\"; skipped if no
43+
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\update-path.bat\\\" remove'
44+
NoDelete:
45+
")
46+
47+
# Adding an option for the start menu
48+
set(CPACK_NSIS_MODIFY_PATH OFF)
49+
set(CPACK_NSIS_EXECUTABLES_DIRECTORY ".")
50+
# This will be shown on the installed apps Windows settings
51+
set(CPACK_NSIS_INSTALLED_ICON_NAME "${CMAKE_PROJECT_NAME}.exe")
52+
set(CPACK_NSIS_CREATE_ICONS_EXTRA
53+
"${CPACK_NSIS_CREATE_ICONS_EXTRA}
54+
SetOutPath '\$INSTDIR'
55+
CreateShortCut '\$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\${CMAKE_PROJECT_NAME}.lnk' \
56+
'\$INSTDIR\\\\${CMAKE_PROJECT_NAME}.exe' '--shortcut'
57+
")
58+
set(CPACK_NSIS_DELETE_ICONS_EXTRA
59+
"${CPACK_NSIS_DELETE_ICONS_EXTRA}
60+
Delete '\$SMPROGRAMS\\\\$MUI_TEMP\\\\${CMAKE_PROJECT_NAME}.lnk'
61+
")
62+
63+
# Checking for previous installed versions
64+
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "ON")
65+
66+
set(CPACK_NSIS_HELP_LINK "https://docs.lizardbyte.dev/projects/sunshine/latest/md_docs_2getting__started.html")
67+
set(CPACK_NSIS_URL_INFO_ABOUT "${CMAKE_PROJECT_HOMEPAGE_URL}")
68+
set(CPACK_NSIS_CONTACT "${CMAKE_PROJECT_HOMEPAGE_URL}/support")
69+
70+
set(CPACK_NSIS_MENU_LINKS
71+
"https://docs.lizardbyte.dev/projects/sunshine" "Sunshine documentation"
72+
"https://app.lizardbyte.dev" "LizardByte Web Site"
73+
"https://app.lizardbyte.dev/support" "LizardByte Support")
74+
set(CPACK_NSIS_MANIFEST_DPI_AWARE true)

cmake/packaging/windows_wix.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# WIX Packaging
2+
# see options at: https://cmake.org/cmake/help/latest/cpack_gen/wix.html
3+
4+
# TODO: Replace nsis with wix

0 commit comments

Comments
 (0)