Files
MosisUnreal/build-unreal.bat

208 lines
5.0 KiB
Batchfile

@echo off
setlocal enabledelayedexpansion
:: MosisUnreal Build and Deploy Script
:: Usage: build-unreal.bat [build|install|deploy|launch|clean]
:: build - Build Android APK only
:: install - Install APK to device only
:: deploy - Build and install (default)
:: launch - Launch app (starts MosisService first)
:: clean - Clean build artifacts
set ENGINE_PATH=D:\Epic\UE_5.5
set PROJECT_PATH=%~dp0MosisUnreal.uproject
set UAT_PATH=%ENGINE_PATH%\Engine\Build\BatchFiles\RunUAT.bat
set CONFIG=Development
:: Parse command line argument
set ACTION=%1
if "%ACTION%"=="" set ACTION=deploy
:: Validate engine path
if not exist "%UAT_PATH%" (
echo ERROR: Unreal Engine not found at %ENGINE_PATH%
echo Please update ENGINE_PATH in this script.
exit /b 1
)
:: Execute action
if "%ACTION%"=="build" goto :build
if "%ACTION%"=="install" goto :install
if "%ACTION%"=="deploy" goto :deploy
if "%ACTION%"=="launch" goto :launch
if "%ACTION%"=="clean" goto :clean
echo Unknown action: %ACTION%
echo Usage: build-unreal.bat [build^|install^|deploy^|launch^|clean]
exit /b 1
:build
echo.
echo ============================================
echo Building MosisUnreal for Android...
echo ============================================
echo.
call "%UAT_PATH%" BuildCookRun ^
-project="%PROJECT_PATH%" ^
-platform=Android ^
-clientconfig=%CONFIG% ^
-build -cook -stage -pak -package ^
-noP4 ^
-utf8output
if errorlevel 1 (
echo.
echo ERROR: Build failed!
exit /b 1
)
echo.
echo Build completed successfully!
echo APK: %~dp0Binaries\Android\MosisUnreal-arm64.apk
goto :eof
:install
echo.
echo ============================================
echo Installing MosisUnreal to device...
echo ============================================
echo.
:: Check for connected device
adb devices | findstr /r /c:"device$" >nul
if errorlevel 1 (
echo ERROR: No Android device connected!
echo Connect a device and enable USB debugging.
exit /b 1
)
:: Get device ID
for /f "tokens=1" %%d in ('adb devices ^| findstr /r /c:"device$"') do (
set DEVICE=%%d
goto :found_device
)
:found_device
echo Device: %DEVICE%
set APK_PATH=%~dp0Binaries\Android\MosisUnreal-arm64.apk
set OBB_PATH=%~dp0Binaries\Android\main.1.com.omixlab.MosisUnreal.obb
:: Check APK exists
if not exist "%APK_PATH%" (
echo ERROR: APK not found at %APK_PATH%
echo Run 'build-unreal.bat build' first.
exit /b 1
)
:: Install APK
echo Installing APK...
adb -s %DEVICE% install -r "%APK_PATH%"
if errorlevel 1 (
echo ERROR: APK installation failed!
exit /b 1
)
:: Install OBB if exists
if exist "%OBB_PATH%" (
echo.
echo Installing OBB...
:: Create temp directory
adb -s %DEVICE% shell "mkdir -p /data/local/tmp/obb/com.omixlab.MosisUnreal"
:: Push OBB (use forward slashes for adb)
set OBB_UNIX=%OBB_PATH:\=/%
adb -s %DEVICE% push "!OBB_UNIX!" /data/local/tmp/obb/com.omixlab.MosisUnreal/
:: Move to final location
adb -s %DEVICE% shell "rm -rf /sdcard/Android/obb/com.omixlab.MosisUnreal"
adb -s %DEVICE% shell "mv /data/local/tmp/obb/com.omixlab.MosisUnreal /sdcard/Android/obb/"
echo OBB installed.
) else (
echo No OBB file found, skipping.
)
echo.
echo Installation completed!
echo.
echo To launch: adb -s %DEVICE% shell am start -n com.omixlab.MosisUnreal/com.epicgames.unreal.GameActivity
goto :eof
:deploy
call :build
if errorlevel 1 exit /b 1
call :install
if errorlevel 1 exit /b 1
call :launch
goto :eof
:launch
echo.
echo ============================================
echo Launching MosisUnreal...
echo ============================================
echo.
:: Check for connected device
adb devices | findstr /r /c:"device$" >nul
if errorlevel 1 (
echo ERROR: No Android device connected!
exit /b 1
)
:: Get device ID
for /f "tokens=1" %%d in ('adb devices ^| findstr /r /c:"device$"') do (
set DEVICE=%%d
goto :found_device_launch
)
:found_device_launch
echo Device: %DEVICE%
:: Stop any running instances
echo Stopping existing instances...
adb -s %DEVICE% shell am force-stop com.omixlab.MosisUnreal >nul 2>&1
adb -s %DEVICE% shell am force-stop com.omixlab.mosis >nul 2>&1
timeout /t 1 /nobreak >nul
:: Start MosisService first
echo Starting MosisService...
adb -s %DEVICE% shell am start -n com.omixlab.mosis/.MainActivity
timeout /t 2 /nobreak >nul
:: Start MosisUnreal
echo Starting MosisUnreal...
adb -s %DEVICE% shell am start -n com.omixlab.MosisUnreal/com.epicgames.unreal.GameActivity
echo.
echo Launched! Monitoring logs (Ctrl+C to stop)...
echo.
adb -s %DEVICE% logcat -s MosisSDK MosisOS MosisTest UE
goto :eof
:clean
echo.
echo ============================================
echo Cleaning build artifacts...
echo ============================================
echo.
if exist "%~dp0Binaries" (
echo Removing Binaries...
rmdir /s /q "%~dp0Binaries"
)
if exist "%~dp0Intermediate\Build" (
echo Removing Intermediate\Build...
rmdir /s /q "%~dp0Intermediate\Build"
)
if exist "%~dp0Saved\StagedBuilds" (
echo Removing Saved\StagedBuilds...
rmdir /s /q "%~dp0Saved\StagedBuilds"
)
echo Clean completed!
goto :eof