zhibo/run_emulator.bat

76 lines
2.2 KiB
Batchfile

@echo off
setlocal
chcp 65001 >nul
set "ROOT=%~dp0"
if "%JAVA_HOME%"=="" (
if exist "%ProgramFiles%\Android\Android Studio\jbr" set "JAVA_HOME=%ProgramFiles%\Android\Android Studio\jbr"
)
if not "%JAVA_HOME%"=="" set "PATH=%JAVA_HOME%\bin;%PATH%"
where java >nul 2>&1
if errorlevel 1 (
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo Please install JDK 17 and set JAVA_HOME, then reopen terminal and rerun.
exit /b 1
)
set "GRADLE_BAT="
for /f "delims=" %%G in ('where gradle.bat 2^>nul') do set "GRADLE_BAT=%%G"
if "%GRADLE_BAT%"=="" (
for /f "delims=" %%G in ('where gradle 2^>nul') do set "GRADLE_BAT=%%G"
)
if "%GRADLE_BAT%"=="" (
set "GRADLE_BAT=D:\soft\gradle-8.1\bin\gradle.bat"
if not exist "%GRADLE_BAT%" set "GRADLE_BAT=D:\soft\gradle-8.1-bin\bin\gradle.bat"
if not exist "%GRADLE_BAT%" set "GRADLE_BAT=D:\soft\gradle-8.1-bin\gradle-8.1\bin\gradle.bat"
)
if "%GRADLE_BAT%"=="" (
echo Gradle not found in PATH.
echo Please install Gradle 8.x and ensure 'gradle' is available in PATH, then rerun.
exit /b 1
)
if not exist "%GRADLE_BAT%" (
echo Gradle not found: %GRADLE_BAT%
echo Please update GRADLE_BAT in run_emulator.bat to point to your gradle.bat, e.g. D:\soft\gradle-8.1\bin\gradle.bat
exit /b 1
)
where npm >nul 2>&1
if errorlevel 1 (
echo npm not found in PATH
exit /b 1
)
echo Starting backend in a new window...
start "live-backend" cmd /k "cd /d ""%ROOT%archive\extras\live-streaming"" ^&^& if not exist node_modules (npm install) ^&^& set PORT=3001 ^&^& set PUBLIC_SRS_HOST=10.0.2.2 ^&^& set PUBLIC_SRS_RTMP_PORT=1935 ^&^& set PUBLIC_SRS_HTTP_PORT=8080 ^&^& npm run dev"
echo Preparing Android project (wrapper/build/install)...
pushd "%ROOT%android-app"
if not exist gradlew.bat (
call "%GRADLE_BAT%" wrapper --gradle-version 8.1
if errorlevel 1 (
popd
exit /b 1
)
if not exist gradlew.bat (
echo Failed to generate gradlew.bat. Please ensure JAVA_HOME points to a valid JDK 17 installation.
popd
exit /b 1
)
)
call "%CD%\gradlew.bat" :app:installDebug
if errorlevel 1 (
popd
exit /b 1
)
popd
echo.
echo Installed. Make sure your Android Emulator is running, then open the app "Live Streaming".
endlocal