为项目构建和gtest写的简单批处理,用的命令都是简单的,高级别的技巧还在追求当中,拿来分享,也希望大家共同学习和帮着修改完善。
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: name: Bat to index
:: writer: xulei-nj
:: date: 2011-6-13
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
cls
mode con cols=120 lines=50
:menu
title 本地构建及gtest检查
cls &color 0F
echo.
echo ==============================
echo 请选择要进行的操作,然后按回车
echo ==============================
echo.
echo 1.下载A,编译及gtest
echo.
echo 2.下载B,编译及gtest
echo.
echo 3.下载A和B,编译及gtest
echo.
echo Q.退出
echo.
echo.
set choice=
set /p choice=请选择:
IF NOT "%choice%"=="" SET choice=%choice:~0,1%
if /i "%choice%"=="1" goto A
if /i "%choice%"=="2" goto B
if /i "%choice%"=="3" goto all
if /i "%choice%"=="Q" goto end
echo 选择无效,请重新输入
echo.
goto menu
:A
echo ★★★★★ A ★★★★★
call download.bat A
call :ie
echo.
pause
goto menu
:B
echo ★★★★★ B ★★★★★
call download.bat B
call :ie
echo.
pause
goto menu
:all
echo ★★★★★ A And B ★★★★★
call download.bat A
title 准备下载B代码...
call :progress
echo.
echo 开始下载B代码...
color 0F
call download.bat B
call :ie
echo.
pause
goto menu
:end
echo ★★★★★ 即将退出 ★★★★★ & ping -n 2 127.1 >nul
goto :eof
:ie
start "ie" "C:\Program Files\Internet Explorer\iexplore.exe" http://xxx.xx.xxx.xx
:progress
echo ┌──────────────────────────────────────┐
set/p= ■<nul
for /L %%i in (1 1 38) do set /p a=■<nul&ping /n 1 127.0.0.1>nul
echo 100%%
echo └──────────────────────────────────────┘
上面的内容保存成index.bat
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: name: Bat to download and gtest
:: writer: xulei-nj
:: date: 2011-6-13
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
REM 重构代码配置库路径
set AAddrIn=http://xxx.xx.xxx.xxx/svn/A/trunk
set BAddrIn=http://xxx.xx.xxx.xxx/svn/B/trunk
REM 文件夹路径
set FolderPath=F:\DemoBuild
set AAddrLocal=%FolderPath%\A
set BAddrLocal=%FolderPath%\B
set AAddrOut=%AAddrLocal%\versions\win32_sharedkd\msvc7
set BAddrOut=%BAddrLocal%
set AGTestAddr=%AAddrLocal%\versions\win32_sharedkd\msvc7\st\Debug\
set BGTestAddr=%ComponentAddrLocal%\Test\UT\Auth\platform\win32\msvc7\bin\win32dbg\
REM 创建文件夹
if not exist %FolderPath% (MD %FolderPath%)
REM 编解决方案
if "%~1" == "A" (
RD %AAddrLocal% /s/q
title 正在下载A代码
svn.exe export %AAddrIn% %AAddrLocal%
title 正在构建A...Debug版本
"%vs71comntools%..\ide\devenv" /rebuild "Debug" "%AAddrOut%\A.sln"
if errorlevel 1 echo A.sln & goto BuildError
title 正在构建A...Release版本
"%vs71comntools%..\ide\devenv" /rebuild "Release" "%AAddrOut%\A.sln"
if errorlevel 1 echo A.sln & goto BuildError
title 正在运行A...GTest
%AGTestAddr%\AST.exe
if errorlevel 1 echo AST.exe & goto BuildError
)
if "%~1" == "B" (
RD %BAddrLocal% /s/q
title 正在下载B代码
svn.exe export %BAddrIn% %CBAddrLocal%
title 正在构建B...Debug版本
"%vs71comntools%..\ide\devenv" /rebuild "Debug" "%BAddrOut%\B.sln"
if errorlevel 1 echo B.sln & goto BuildError
title 正在构建B...Release版本
"%vs71comntools%..\ide\devenv" /rebuild "Release" "%BAddrOut%\B.sln"
if errorlevel 1 echo B.sln & goto BuildError
title 正在运行B...GTest
%BGTestAddr%\BUT.exe
if errorlevel 1 echo BUT.exe & goto BuildError
)
:BuildRight
color 2F & echo. & echo OK! No Problem!
exit /B 0
:BuildError
color 4F
echo.
echo There is something wrong with this program!
pause
上面的内容保存成download.bat
当然你最好安装下VisualSVN Server,然后把bin目录下的图示文件拷贝到你的目录里面去。