-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlaunch.bat
More file actions
235 lines (215 loc) · 7.78 KB
/
Copy pathlaunch.bat
File metadata and controls
235 lines (215 loc) · 7.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
@echo off
setlocal enabledelayedexpansion
cd /d "%~dp0"
:: ── CLI Argument Dispatch ───────────────────────────────────────
if /i "%~1"=="dev" goto :run_dev
if /i "%~1"=="release" goto :run_release
if /i "%~1"=="build" goto :run_build
if /i "%~1"=="compile" goto :run_build
if /i "%~1"=="test" goto :run_test
if /i "%~1"=="start" goto :run_normal
:menu
cls
echo ===================================================
echo CloudStream Desktop Launcher
echo ===================================================
echo.
echo [1] Start CloudStream (Default Dev Mode)
echo [2] Start with Dev Studio ^& Live LogCat (--dev)
echo [3] Launch Packaged Release EXE
echo [4] Build / Compile Standalone EXE
echo [5] Run All Tests ^& Health Checks
echo.
echo [Q] Exit
echo.
echo ===================================================
set /p "CHOICE=Select option [1-5] (Default is 1): "
if "%CHOICE%"=="" goto :run_normal
if /i "%CHOICE%"=="1" goto :run_normal
if /i "%CHOICE%"=="2" goto :run_dev
if /i "%CHOICE%"=="3" goto :run_release
if /i "%CHOICE%"=="4" goto :run_build
if /i "%CHOICE%"=="5" goto :run_test
if /i "%CHOICE%"=="q" exit /b 0
echo Invalid selection. Please try again.
timeout /t 2 >nul
goto :menu
:: ── Shared Pre-Flight Verification ─────────────────────────────
:check_prerequisites
call :check_java
if %errorlevel% neq 0 exit /b %errorlevel%
call :check_submodules
if %errorlevel% neq 0 exit /b %errorlevel%
call :check_native_binaries
if %errorlevel% neq 0 exit /b %errorlevel%
exit /b 0
:: ── Java Environment Verification ──────────────────────────────
:check_java
where java >nul 2>&1
if %errorlevel% neq 0 (
if "%JAVA_HOME%"=="" (
echo.
echo ===================================================
echo [FATAL ERROR] Java is not installed or not in PATH
echo ===================================================
echo CloudStream Desktop requires JDK 21 or higher.
echo Please install Eclipse Adoptium Temurin 21:
echo https://adoptium.net/temurin/releases/?version=21
echo and ensure 'java' is in your PATH or JAVA_HOME is set.
echo ===================================================
echo.
pause
exit /b 1
)
)
exit /b 0
:: ── Shared Submodule Verification ─────────────────────────────
:check_submodules
if not exist "android-reference\settings.gradle.kts" (
echo [INFO] android-reference submodule is empty. Attempting to fetch automatically...
git submodule update --init --recursive
if not exist "android-reference\settings.gradle.kts" (
echo.
echo ===================================================
echo [FATAL ERROR] The android-reference folder is empty!
echo ===================================================
echo This usually happens if the repository was downloaded
echo as a ZIP file instead of cloned with git.
echo.
echo Please run this command in your terminal:
echo git clone --recursive https://github.com/errorcode26/CS3-desktop-client-unofficial.git
echo ===================================================
echo.
pause
exit /b 1
)
)
exit /b 0
:: ── Shared Native Binaries Verification ───────────────────────
:check_native_binaries
set "MPV_DLL=desktop-app\appResources\windows\mpv\libmpv-2.dll"
set "BRIDGE_DLL=desktop-app\appResources\windows\jni\player_bridge.dll"
set "WEBVIEW_DLL=desktop-app\appResources\windows\jni\WebView2Loader.dll"
if exist "%MPV_DLL%" goto :check_bridge
echo.
echo ===============================================================================
echo [MISSING DEPENDENCY] libmpv-2.dll Not Found
echo ===============================================================================
echo Because libmpv-2.dll exceeds GitHub's 100MB file size limit,
echo it is not bundled in the Git repository.
echo.
echo Expected Location:
echo %MPV_DLL%
echo.
echo How to fix:
echo 1. Download 'mpv-dev-x86_64-*.7z' from shinchiro's MPV builds:
echo https://github.com/shinchiro/mpv-winbuild-cmake/releases
echo 2. Extract 'libmpv-2.dll' and place it into:
echo desktop-app\appResources\windows\mpv\
echo ===============================================================================
echo.
pause
exit /b 1
:check_bridge
if exist "%BRIDGE_DLL%" goto :check_webview
echo.
echo [ERROR] Missing native bridge library: %BRIDGE_DLL%
echo Please verify your repository clone or run desktop-app\src\main\cpp\build_jni.ps1
echo.
pause
exit /b 1
:check_webview
if exist "%WEBVIEW_DLL%" goto :binaries_ok
echo.
echo [ERROR] Missing native WebView2 loader: %WEBVIEW_DLL%
echo.
pause
exit /b 1
:binaries_ok
exit /b 0
:: ── Option 1: Normal Launch ──────────────────────────────────
:run_normal
call :check_prerequisites
if %errorlevel% neq 0 exit /b %errorlevel%
echo.
echo [INFO] Starting CloudStream Desktop Client...
echo [TIP] Press F12 in-app anytime to open the Dev Studio LogCat.
echo.
call gradlew :desktop-app:run
goto :after_run
:: ── Option 2: Dev Studio Launch ──────────────────────────────
:run_dev
call :check_prerequisites
if %errorlevel% neq 0 exit /b %errorlevel%
echo.
echo [INFO] Starting CloudStream Desktop with Dev Studio ^& Live LogCat...
echo.
call gradlew :desktop-app:run --args="--dev"
goto :after_run
:: ── Option 3: Release EXE Launch ─────────────────────────────
:run_release
call :check_prerequisites
if %errorlevel% neq 0 exit /b %errorlevel%
set "EXE_PATH=desktop-app\build\compose\binaries\main\app\CloudStream-Desktop\CloudStream-Desktop.exe"
if not exist "%EXE_PATH%" (
echo.
echo [WARN] Release executable not found at:
echo %EXE_PATH%
echo.
set /p "BUILD_NOW=Would you like to compile it now? (Y/N): "
if /i "!BUILD_NOW!"=="Y" (
call :run_build
if not exist "%EXE_PATH%" goto :after_run
) else (
goto :after_run
)
)
echo.
echo [INFO] Starting CloudStream-Desktop.exe...
start "" "%EXE_PATH%"
exit /b 0
:: ── Option 4: Build Release EXE ──────────────────────────────
:run_build
call :check_prerequisites
if %errorlevel% neq 0 exit /b %errorlevel%
echo.
echo ===================================================
echo Compiling CloudStream Desktop (Standalone EXE)
echo ===================================================
echo.
call gradlew clean :desktop-app:createDistributable
if %errorlevel% neq 0 (
echo.
echo [ERROR] Compilation failed with error code %errorlevel%
pause
exit /b %errorlevel%
)
echo.
echo [SUCCESS] Standalone EXE compilation complete!
echo Executable located at:
echo desktop-app\build\compose\binaries\main\app\CloudStream-Desktop\CloudStream-Desktop.exe
echo.
pause
exit /b 0
:: ── Option 5: Run Tests ──────────────────────────────────────
:run_test
call :check_prerequisites
if %errorlevel% neq 0 exit /b %errorlevel%
echo.
echo [INFO] Running all unit test suites and verifications...
echo.
call gradlew :common:test :plugin-runtime:test :desktop-app:compileKotlin
if %errorlevel% equ 0 (
echo.
echo [SUCCESS] All test suites and builds passed!
) else (
echo.
echo [ERROR] Test or compilation failures detected.
)
echo.
pause
exit /b 0
:after_run
echo.
echo App exited with code %errorlevel%
pause