incredibuild(分布式任务软件)脚本

IncrediBuild 可以在Server段通过修改单个任务的进程上限来实现提升任务执行速度。

IncredBuild本机版也可以用来进行本机实现多线程任务分发,这样可以充分利用多核资源。

提交分布式任务涉及该工具的三个命令:

    xgConsole.exe ,负责编译工程任务的发起;

    xgSubmit.exe ,负责提交各个工程文件的编译任务;

    xgWait.exe ,负责最后的链接。

 示例:

run.bat
@ECHO OFF
xgSubmit.exe /group=UTest # test.exe 0.cpp
xgSubmit.exe /group=UTest # test.exe 1.cpp
xgSubmit.exe /group=UTest # test.exe 2.cpp
xgSubmit.exe /group=UTest # test.exe 3.cpp
xgSubmit.exe /group=UTest # test.exe 4.cpp
xgSubmit.exe /group=UTest # test.exe 5.cpp
xgSubmit.exe /group=UTest # test.exe 6.cpp
xgSubmit.exe /group=UTest # test.exe 7.cpp
xgSubmit.exe /group=UTest # test.exe 8.cpp
xgSubmit.exe /group=UTest # test.exe 9.cpp
xgSubmit.exe /group=UTest # test.exe 10.cpp
xgWait.exe /group=UTest
echo All Task Finished

xgConsole /command="run.bat" /openmonitor 
Rem UTest.bat - Distributed Version
Rem ===============================
xgSubmit.exe /group=UTest /command UTest.exe /in=Input1.dat /out="Results\"
xgSubmit.exe /group=UTest /command UTest.exe /in=Input2.dat /out="Results\"
xgSubmit.exe /group=UTest /command UTest.exe /in=Input3.dat /out="Results\"
xgSubmit.exe /group=UTest /command UTest.exe /in=Input4.dat /out="Results\"
xgSubmit.exe /group=UTest /command UTest.exe /in=Input5.dat /out="Results\"
xgWait.exe /group=UTest
UReport.exe /in="Results\" /ShowReport
:end

xgConsole.exe UTest.bat

 

 自己写的一个分布式批处理脚本: 

@ECHO OFF
setlocal ENABLEDELAYEDEXPANSION
set time1=%time:~0,2%%time:~3,2%%time:~6,2%

set PRJ_DIR=%CD%
set WORK_FILE=lint
set BAT=run.bat
set SOURCE=filelist.txt

::进工作目录
IF NOT EXIST %WORK_FILE% (
    echo No %WORK_FILE%!!!
    EXIT
)

cd %WORK_FILE%

IF NOT EXIST %SOURCE% (
    echo No %SOURCE%!!!
    EXIT
)

set tmpIndex=0
set duplicateCount=0

::遍历文件列表
FOR /F "eol=/delims=" %%i in (%SOURCE%) do (
    set tmp=%%i
    
    set isannotate=false
    IF "!tmp:~0,1!"=="#" (
        set isannotate=true
    )
    IF "!tmp:~0,2!"=="//" (
        set isannotate=true
    )
    
    IF !isannotate!==false (
        set fileorfolder=!tmp:%%PRJ_DIR%%=%PRJ_DIR%!
        set existfile=false
        FOR /F "delims=" %%j in ('dir /s /b /A:-D !fileorfolder!') do (
            IF EXIST "%%j" (
                set existfile=true
                
                ::判重标识
                set duplicate=false
                FOR /L %%k IN (0,1,!tmpIndex!) do (
                    IF /I !tmp[%%k]!=="%%j" (
                        set duplicate=true
                    )
                )
                
                ::判重
                IF !duplicate!==false (
                    set tmp[!tmpIndex!]="%%j"
                    set /a tmpIndex=tmpIndex+1
                ) ELSE (
                    set /a duplicateCount=duplicateCount+1
                )
            )
        )
        
        IF !existfile!==false (
            echo !tmp! error
            echo !fileorfolder!
        )
    )
)

::清空临时环境变量,否则后面执行xgConsole时会尝试解析这些环境变量而出错
set tmp=
set fileorfolder=
set existfile=
set duplicate=

echo TaskInfo FileCount:!tmpIndex!  Duplicate:!duplicateCount!

::重新生成bat
IF EXIST "%BAT%" (
    del "%BAT%"
)

echo @ECHO OFF >>%BAT%

::按实际大小遍历
set /a tmpIndex=tmpIndex-1

FOR /L %%k IN (0,1,!tmpIndex!) do (
    echo xgSubmit.exe /group=UTest # test.exe !tmp[%%k]! >>%BAT%
)

echo xgWait.exe /group=UTest >>%BAT%
echo echo All Task Finished! >>%BAT%

xgConsole /NOLOGO /command="%BAT%"

set time2=%time:~0,2%%time:~3,2%%time:~6,2%
set /a time3=%time2%-%time1%
echo 耗时%time3%秒

EXIT

 

posted @ 2013-07-07 21:11  dzqabc  阅读(560)  评论(0编辑  收藏  举报