自动更新管控端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

159 lines
3.5 KiB

REM 输出utf8编码
chcp 65001
@echo off
REM Windows平台构建脚本 - 优化版
setlocal enabledelayedexpansion
REM 配置参数
set BUILD_DIR=build_windows
set CMAKE_GENERATOR="Visual Studio 17 2022"
set INSTALL_PREFIX=install
set BUILD_TYPE=Release
set NUM_JOBS=%NUMBER_OF_PROCESSORS%
set CLEAN_BUILD=0
set ONLY_CONFIG=0
set ONLY_BUILD=0
set SKIP_INSTALL=0
REM 检查命令行参数
:parse_args
if "%~1"=="" goto end_parse_args
if "%~1"=="--clean" (
set CLEAN_BUILD=1
shift
goto parse_args
)
if "%~1"=="--config-only" (
set ONLY_CONFIG=1
shift
goto parse_args
)
if "%~1"=="--build-only" (
set ONLY_BUILD=1
shift
goto parse_args
)
if "%~1"=="--skip-install" (
set SKIP_INSTALL=1
shift
goto parse_args
)
if "%~1"=="--debug" (
set BUILD_TYPE=Debug
shift
goto parse_args
)
if "%~1"=="--jobs" (
if not "%~2"=="" (
set NUM_JOBS=%~2
shift
shift
goto parse_args
)
)
echo 未知参数: %~1
:end_parse_args
REM 显示配置信息
cls
echo ====================================================
echo Windows平台构建脚本 - RPC项目
echo ====================================================
echo 构建目录: %BUILD_DIR%
echo 生成器: %CMAKE_GENERATOR%
echo 安装前缀: %INSTALL_PREFIX%
echo 构建类型: %BUILD_TYPE%
echo 并行任务数: %NUM_JOBS%
echo 清理构建: %CLEAN_BUILD%
echo ====================================================
REM 清理构建目录(如果需要)
if %CLEAN_BUILD% equ 1 (
echo 正在清理构建目录...
if exist %BUILD_DIR% (
rmdir /s /q %BUILD_DIR% >nul 2>&1
if errorlevel 1 (
echo 清理构建目录失败,请确保没有进程正在使用该目录。
exit /b 1
)
)
if exist %INSTALL_PREFIX% (
rmdir /s /q %INSTALL_PREFIX% >nul 2>&1
if errorlevel 1 (
echo 清理安装目录失败,请确保没有进程正在使用该目录。
exit /b 1
)
)
)
REM 创建构建目录
if not exist %BUILD_DIR% (
mkdir %BUILD_DIR% >nul 2>&1
if errorlevel 1 (
echo 创建构建目录失败。
exit /b 1
)
)
REM 运行CMake配置
pushd %BUILD_DIR% >nul 2>&1
if %ONLY_BUILD% equ 0 (
echo 正在运行CMake配置...
cmake .. -G %CMAKE_GENERATOR% -DCMAKE_INSTALL_PREFIX=../%INSTALL_PREFIX%
if errorlevel 1 (
echo CMake配置失败!
popd >nul 2>&1
exit /b 1
)
echo CMake配置成功。
if %ONLY_CONFIG% equ 1 (
echo 已完成配置,跳过构建和安装步骤。
popd >nul 2>&1
exit /b 0
)
)
REM 构建项目
if %SKIP_INSTALL% equ 0 (
echo 正在构建项目... [%BUILD_TYPE%]
cmake --build . --config %BUILD_TYPE% --parallel %NUM_JOBS%
if errorlevel 1 (
echo 构建失败!
popd >nul 2>&1
exit /b 1
)
echo 项目构建成功。
REM 安装项目
echo 正在安装项目...
cmake --build . --config %BUILD_TYPE% --target install
if errorlevel 1 (
echo 安装失败!
popd >nul 2>&1
exit /b 1
)
echo 项目安装成功。
) else (
echo 已跳过安装步骤。
)
popd >nul 2>&1
REM 显示构建结果
echo ====================================================
echo 构建完成!
echo 服务器可执行文件: %INSTALL_PREFIX%\bin\rpc_server.exe
echo 客户端可执行文件: %INSTALL_PREFIX%\bin\rpc_client.exe
echo ====================================================
exit /b 0