Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a9445e0

Browse files
fix(packaging): add Sunshine directory to system PATH
1 parent d938596 commit a9445e0

File tree

5 files changed

+88
-12
lines changed

5 files changed

+88
-12
lines changed

cmake/packaging/windows.cmake

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# windows specific packaging
22

33
# see options at: https://cmake.org/cmake/help/latest/cpack_gen/nsis.html
4-
install(TARGETS sunshine RUNTIME DESTINATION "bin" COMPONENT application)
4+
install(TARGETS sunshine RUNTIME DESTINATION "." COMPONENT application)
55

66
# Hardening: include zlib1.dll (loaded via LoadLibrary() in openssl's libcrypto.a)
7-
install(FILES "${ZLIB}" DESTINATION "bin" COMPONENT application)
7+
install(FILES "${ZLIB}" DESTINATION "." COMPONENT application)
88

99
# Adding tools
10-
install(TARGETS dxgi-info RUNTIME DESTINATION "bin" COMPONENT dxgi)
11-
install(TARGETS audio-info RUNTIME DESTINATION "bin" COMPONENT audio)
10+
install(TARGETS dxgi-info RUNTIME DESTINATION "tools" COMPONENT dxgi)
11+
install(TARGETS audio-info RUNTIME DESTINATION "tools" COMPONENT audio)
1212

1313
# Mandatory tools
14-
install(TARGETS sunshinesvc RUNTIME DESTINATION "bin" COMPONENT application)
14+
install(TARGETS sunshinesvc RUNTIME DESTINATION "tools" COMPONENT application)
1515

1616
# Mandatory scripts
1717
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/windows/misc/service/"
@@ -20,6 +20,9 @@ install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/windows/misc/service/"
2020
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/windows/misc/migration/"
2121
DESTINATION "scripts"
2222
COMPONENT assets)
23+
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/windows/misc/path/"
24+
DESTINATION "scripts"
25+
COMPONENT assets)
2326

2427
# Configurable options for the service
2528
install(DIRECTORY "${SUNSHINE_SOURCE_ASSETS_DIR}/windows/misc/autostart/"
@@ -64,6 +67,7 @@ SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS
6467
IfSilent +2 0
6568
ExecShell 'open' 'https://docs.lizardbyte.dev/projects/sunshine'
6669
nsExec::ExecToLog 'icacls \\\"$INSTDIR\\\" /reset'
70+
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\update-path.bat\\\" add'
6771
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\migrate-config.bat\\\"'
6872
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\add-firewall-rule.bat\\\"'
6973
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\install-gamepad.bat\\\"'
@@ -78,7 +82,7 @@ set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS
7882
"${CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS}
7983
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\delete-firewall-rule.bat\\\"'
8084
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\uninstall-service.bat\\\"'
81-
nsExec::ExecToLog '\\\"$INSTDIR\\\\bin\\\\${CMAKE_PROJECT_NAME}.exe\\\" --restore-nvprefs-undo'
85+
nsExec::ExecToLog '\\\"$INSTDIR\\\\${CMAKE_PROJECT_NAME}.exe\\\" --restore-nvprefs-undo'
8286
MessageBox MB_YESNO|MB_ICONQUESTION \
8387
'Do you want to remove Virtual Gamepad?' \
8488
/SD IDNO IDNO NoGamepad
@@ -88,19 +92,20 @@ set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS
8892
'Do you want to remove $INSTDIR (this includes the configuration, cover images, and settings)?' \
8993
/SD IDNO IDNO NoDelete
9094
RMDir /r \\\"$INSTDIR\\\"; skipped if no
95+
nsExec::ExecToLog '\\\"$INSTDIR\\\\scripts\\\\update-path.bat\\\" remove'
9196
NoDelete:
9297
")
9398

9499
# Adding an option for the start menu
95-
set(CPACK_NSIS_MODIFY_PATH ON)
100+
set(CPACK_NSIS_MODIFY_PATH OFF)
96101
set(CPACK_NSIS_EXECUTABLES_DIRECTORY ".")
97102
# This will be shown on the installed apps Windows settings
98103
set(CPACK_NSIS_INSTALLED_ICON_NAME "${CMAKE_PROJECT_NAME}.exe")
99104
set(CPACK_NSIS_CREATE_ICONS_EXTRA
100105
"${CPACK_NSIS_CREATE_ICONS_EXTRA}
101106
SetOutPath '\$INSTDIR'
102107
CreateShortCut '\$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\${CMAKE_PROJECT_NAME}.lnk' \
103-
'\$INSTDIR\\\\bin\\\\${CMAKE_PROJECT_NAME}.exe' '--shortcut'
108+
'\$INSTDIR\\\\${CMAKE_PROJECT_NAME}.exe' '--shortcut'
104109
")
105110
set(CPACK_NSIS_DELETE_ICONS_EXTRA
106111
"${CPACK_NSIS_DELETE_ICONS_EXTRA}

docs/configuration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ editing the `conf` file in a text editor. Use the examples as reference.
708708
<br>
709709
Enter the following command in command prompt or PowerShell.
710710
@code{}
711-
%ProgramFiles%\Sunshine\bin\audio-info.exe
711+
%ProgramFiles%\Sunshine\tools\audio-info.exe
712712
@endcode
713713
If you have multiple audio devices with identical names, use the Device ID instead.
714714
}
@@ -822,7 +822,7 @@ editing the `conf` file in a text editor. Use the examples as reference.
822822
<br>
823823
Enter the following command in command prompt or PowerShell.
824824
@code{}
825-
%ProgramFiles%\Sunshine\bin\dxgi-info.exe
825+
%ProgramFiles%\Sunshine\tools\dxgi-info.exe
826826
@endcode
827827
For hybrid graphics systems, DXGI reports the outputs are connected to whichever graphics
828828
adapter that the application is configured to use, so it's not a reliable indicator of how the

src/platform/windows/misc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ namespace platf {
118118
std::filesystem::path appdata() {
119119
WCHAR sunshine_path[MAX_PATH];
120120
GetModuleFileNameW(NULL, sunshine_path, _countof(sunshine_path));
121-
return std::filesystem::path {sunshine_path}.remove_filename().parent_path().parent_path() / L"config"sv;
121+
return std::filesystem::path {sunshine_path}.remove_filename() / L"config"sv;
122122
}
123123

124124
std::string from_sockaddr(const sockaddr *const socket_address) {
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
@echo off
2+
setlocal EnableDelayedExpansion
3+
4+
rem Check if parameter is provided
5+
if "%~1"=="" (
6+
echo Usage: %0 [add^|remove]
7+
echo add - Adds Sunshine directory to system PATH
8+
echo remove - Removes Sunshine directory from system PATH
9+
exit /b 1
10+
)
11+
12+
rem Get sunshine root directory
13+
for %%I in ("%~dp0\..") do set "ROOT_DIR=%%~fI"
14+
echo Sunshine root directory: !ROOT_DIR!
15+
16+
rem System path registry location
17+
set "KEY_NAME=HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
18+
set "VALUE_NAME=Path"
19+
20+
rem Get the current path
21+
for /f "tokens=2*" %%A in ('reg query "%KEY_NAME%" /v "%VALUE_NAME%"') do set "CURRENT_PATH=%%B"
22+
echo Current path: !CURRENT_PATH!
23+
24+
rem Check if adding to path
25+
if /i "%~1"=="add" (
26+
rem Check if the path already contains the sunshine bin directory
27+
echo "!CURRENT_PATH!" | findstr /i /c:"!ROOT_DIR!" > nul
28+
if !ERRORLEVEL!==0 (
29+
echo Sunshine directory already in path
30+
exit /b 0
31+
)
32+
33+
set "NEW_PATH=!CURRENT_PATH!;!ROOT_DIR!"
34+
echo Adding to path: !ROOT_DIR!
35+
36+
rem Set the new path in the registry
37+
reg add "%KEY_NAME%" /v "%VALUE_NAME%" /t REG_EXPAND_SZ /d "!NEW_PATH!" /f
38+
if !ERRORLEVEL!==0 (
39+
echo Successfully added Sunshine directory to PATH
40+
) else (
41+
echo Failed to add Sunshine directory to PATH
42+
)
43+
exit /b !ERRORLEVEL!
44+
)
45+
46+
rem Check if removing from path
47+
if /i "%~1"=="remove" (
48+
rem Check if the path contains the sunshine bin directory
49+
echo "!CURRENT_PATH!" | findstr /i /c:"!ROOT_DIR!" > nul
50+
if !ERRORLEVEL!==1 (
51+
echo Sunshine directory not found in path
52+
exit /b 0
53+
)
54+
55+
set "NEW_PATH=!CURRENT_PATH:;%ROOT_DIR%=!"
56+
set "NEW_PATH=!NEW_PATH:%ROOT_DIR%;=!"
57+
echo Removing from path: !ROOT_DIR!
58+
59+
rem Set the new path in the registry
60+
reg add "%KEY_NAME%" /v "%VALUE_NAME%" /t REG_EXPAND_SZ /d "!NEW_PATH!" /f
61+
if !ERRORLEVEL!==0 (
62+
echo Successfully removed Sunshine directory from PATH
63+
) else (
64+
echo Failed to remove Sunshine directory from PATH
65+
)
66+
exit /b !ERRORLEVEL!
67+
)
68+
69+
echo Unknown parameter: %~1
70+
echo Usage: %0 [add^|remove]
71+
exit /b 1

src_assets/windows/misc/service/install-service.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ rem Get sunshine root directory
44
for %%I in ("%~dp0\..") do set "ROOT_DIR=%%~fI"
55

66
set SERVICE_NAME=SunshineService
7-
set SERVICE_BIN="%ROOT_DIR%\bin\sunshinesvc.exe"
7+
set SERVICE_BIN="%ROOT_DIR%\tools\sunshinesvc.exe"
88

99
rem Set service to demand start. It will be changed to auto later if the user selected that option.
1010
set SERVICE_START_TYPE=demand

0 commit comments

Comments
 (0)