最近在弄一个新研发平台的分布式编译,使用mips-gcc交叉编译,在winxp,win2003和win7上使用cygwin。
分布式编译使用的是distcc,版本为distcc-2.18.3 (for cygwin)。
distcc分布式编译简单介绍一下:
该分布式编译使用的方式是client+server的方式,编译时client可以同时向多个server发送编译请求,server在本机编译完成后,将obj文件回传给client。
client运行distcc.exe,server运行distccd.exe(监听3632端口)。client编译前需要指定server的ip,通过设置环境变量DIST_HOSTS告诉distcc。
distcc.exe distccd.exe 都位于cygwin安装目录bin目录下。
我写了一个bat文件,放到“C:\Documents and Settings\All Users\「开始」菜单\程序\启动”目录下,以便研发人员每次开机的时候可以自动运行distccd.exe服务程序。
现在的问题是:
开机后,distccd能正常启动,但是接收到client发送过来的编译请求时,找不到编译器mips-elf-gcc.exe,而该编译器位于cygwin安装目录的crosscompiler\bin目录下;
但是如果在cmd.exe窗口里输入如下两句启动的distccd,却一切正常,
>set PATH=C:\cygwin\crosscompiler\bin;C:\cygwin\bin;%PATH%
>distccd --daemon --allow 192.168.1.0/24
还请各位大侠帮忙看看问题出在哪里?- @echo off
-
- ::+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- :: 检测系统中是否有distccd在运行
- ::+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- set /a DistccdCount=0
- for /f "delims=" %%i in ('tasklist ^| findstr /i "distccd.exe"') do (set /a DistccdCount+=1)
- if not %DistccdCount%==0 (echo distccd is already running && goto eof)
- :: 先终止当前的distccd线程
- ::taskkill /F /IM distccd.exe
-
- ::+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- :: 根据操作系统类型,查询注册表,寻找cygwin安装目录
- ::+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- set TheOs=
- if /i not "%os%."=="Windows_NT." goto UnknownSystemError
- :: 判断系统版本
- for /f "delims=" %%i in ('ver ^| findstr /i "6.1"') do (set TheOs=Win7 && goto Win7)
- for /f "delims=" %%i in ('ver ^| findstr /i "6.1"') do (set TheOs=WinVista && goto WinVista)
- for /f "delims=" %%i in ('ver ^| findstr /i "5.0"') do (set TheOs=Win2000 && goto Win2000)
- for /f "delims=" %%i in ('ver ^| findstr /i "5.1"') do (set TheOs=WinXP && goto WinXP)
- for /f "delims=" %%i in ('ver ^| findstr /i "5.2"') do (set TheOs=Win2003 && goto Win2003)
- :: 默认是XP
- set TheOs=WinXP && goto WinXP
-
- :Win7
- :WinVista
- echo Find Cygwin install path @%TheOs%
- for /f "skip=2 tokens=1-3" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Cygnus Solutions\Cygwin\mounts v2\/" /v native') do (
- set "CYGWIN_HOME=%%c"
- )
- if "%CYGWIN_HOME%"=="" (goto UnknowCygwinInstallPath) else (goto FindDistccd)
-
- :Win2000
- :WinXP
- echo Find Cygwin install path @%TheOs%
- for /f "skip=4 tokens=1-3" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/" /v native') do (
- set "CYGWIN_HOME=%%c"
- )
- if "%CYGWIN_HOME%"=="" (goto UnknowCygwinInstallPath) else (goto FindDistccd)
-
- :Win2003
- echo Find Cygwin install path @%TheOs%
- for /f "skip=1 tokens=1-3" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Cygnus Solutions\Cygwin\mounts v2\/" /v native') do (
- set "CYGWIN_HOME=%%c"
- )
- if "%CYGWIN_HOME%"=="" (goto UnknowCygwinInstallPath) else (goto FindDistccd)
-
- ::+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- :: 启动distccd
- ::+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- :FindDistccd
- echo cygwin install path is: %CYGWIN_HOME%
- :: 默认distccd位于cygwin安装目录bin下
- set DISTCCD_PATH=%CYGWIN_HOME%\bin
- :: 检测distccd是否存在
- if not exist %DISTCCD_PATH%\distccd.exe (goto NoDistccd)
-
- :: 环境变量中加入distccd以及cygwin的bin目录
- set PATH=%CYGWIN_HOME%\usr\bin;%CYGWIN_HOME%\bin;%PATH%
-
- :: 启动distccd
- :: 这里有个没有解决的问题,在cmd窗口中,只要设置正确的PATH,可以直接输入distccd命令启动,但是在bat文件中却有问题
- :: 通过bash虽然能启动distccd,但是distccd必须放到cygwin安装目录的bin下。具体原因未知
- echo start distccd...
- :: 增加mips-elf-gcc.exe的目录,希望distccd执行的时候能找到该编译器
- set PATH=%CYGWIN_HOME%\crosscompiler\bin;%PATH%
- ::%DISTCCD_PATH%\distccd.exe --daemon --allow 192.168.1.0/24 --verbose --log-file 1.txt --pid-file 1.pid
- ::bash --noprofile -c "distccd --daemon --allow 192.168.1.0/24 --verbose --log-file 1.txt --pid-file 1.pid"
- bash --noprofile -c "distccd --daemon --allow 192.168.1.0/24"
- if errorlevel 0 (goto Success) else (goto Error)
-
- ::+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- :: 以下为各种错误处理
- ::+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- :UnknownSystemError
- echo Unknown OS!!!
- goto Error
-
- :UnknowCygwinInstallPath
- echo Cannot find cygwin install path!!!
- goto Error
-
- :NoDistccd
- echo Cannot find distccd @%DISTCCD_PATH%
- goto Error
-
- :Success
- echo distccd start successful...
- :: 显示三秒后,直接退出,sleep是cygwin的bin下的工具
- sleep 3
- goto eof
-
- :Error
- echo distccd start failed...
- pause
- goto eof
-
- :eof
复制代码
|