C - Ant Target exec 失败,而在 shell 上运行命令成功



我得到了一个针对不同目标平台和主机平台运行的构建环境,使用 ant 来完成主要工作。对于一个目标平台(高通的 BREW MP,本机 C/C++),我需要使用此 ant 目标执行编译:

<target name="build.brew.target" if="${cfg.build.brew}" depends="brew.clean">
  <exec dir="${src.cpp.brew}/brew" executable="cs-make" failonerror="true" newenvironment="false">
    <env key="PATH" value="${env.PATH}" />
    <arg line="-f brew.mak" />
  </exec>
...
</target>

cs-make 是来自 BREW SDK 的 make 实用程序,用于运行在 makefile (brew.mak) 中定义的构建。
ant 从 cmd 提示符 (Win7/64) 执行时返回错误,例如

ant build.brew.target

ant打印出cl.exe(Visual Studio 2010 Express的一部分)报告的错误:

 [exec] "C:/PROGRA~1/Qualcomm/BREWMP~1/TOOLSE~1.246/bin/cifc.exe"  -bar Win32_Debug/../res/brew.bar -IC:Devlibcpplibspeexinclude -I. -IC:/PROGRA~1/Qualcomm/BrewMPSDK/Platforms/BREW4/sdk/inc -IC:/PROGRA~1/Qualcomm/BrewMPSDK/Platforms/BREW4/sdk/../inc -I../inc -I../../common -IC:DevignoreBOOST_~1 -IWin32_Debug ../res/brew.car
 [exec] "C:/PROGRA~1/Qualcomm/BREWMP~1/TOOLSE~1.246/bin/cifc.exe"  -bar Win32_Debug/../res/brew.bar -IC:Devlibcpplibspeexinclude -I. -IC:/PROGRA~1/Qualcomm/BrewMPSDK/Platforms/BREW4/sdk/inc -IC:/PROGRA~1/Qualcomm/BrewMPSDK/Platforms/BREW4/sdk/../inc -I../inc -I../../common -IC:DevignoreBOOST_~1 -IWin32_Debug -M ../res/brew.car > Win32_Debug/../res/brew.bar.dep
 [exec] if exist Win32_Debug/../res/brew.bar (copy /b /v Win32_Debug..resbrew.bar +,,Win32_Debug..resbrew.bar>nul) else (echo on>Win32_Debug/../res/brew.bar)
 [exec] "C:/PROGRA~1/Qualcomm/BREWMP~1/TOOLSE~1.246/bin/cifc.exe"  -IC:Devlibcpplibspeexinclude -I. -IC:/PROGRA~1/Qualcomm/BrewMPSDK/Platforms/BREW4/sdk/inc -IC:/PROGRA~1/Qualcomm/BrewMPSDK/Platforms/BREW4/sdk/../inc -I../inc -I../../common -IC:DevignoreBOOST_~1 -IWin32_Debug ../res/brew.cif -pre Win32_Debug/brew.clif -M > Win32_Debug/brew.clif.dep
 [exec] "C:/PROGRA~1/Qualcomm/BREWMP~1/TOOLSE~1.246/bin/cifc.exe"  -IC:Devlibcpplibspeexinclude -I. -IC:/PROGRA~1/Qualcomm/BrewMPSDK/Platforms/BREW4/sdk/inc -IC:/PROGRA~1/Qualcomm/BrewMPSDK/Platforms/BREW4/sdk/../inc -I../inc -I../../common -IC:DevignoreBOOST_~1 -IWin32_Debug ../res/brew.cif -pre Win32_Debug/brew.clif
 [exec] "C:/PROGRA~1/Qualcomm/BREWMP~1/TOOLSE~1.246/bin/cifc.exe"   -mod brew -mif Win32_Debug/brew.mif Win32_Debug/brew.clif

 [exec] cs-make: *** [Win32_Debug/AEEAppGen.o] Error -1073741515

 [exec] "c:/Program Files (x86)/Microsoft Visual Studio 10.0/VC//bin/cl.exe" -nologo -D_WIN32_WINNT=0x0400 -MTd -Z7 -EHsc -GS -Zl -RTC1 -Od -Ob1 -W3 -WX -wd4244 -wd4146 -wd4005 -wd4355 -c     -DAEE_SIMULATOR -D_DEBUG -D_DEBUG -DAEE_SIMULATOR  -IC:Devlibcpplibspeexinclude -I. -IC:/PROGRA~1/Qualcomm/BrewMPSDK/Platforms/BREW4/sdk/inc -IC:/PROGRA~1/Qualcomm/BrewMPSDK/Platforms/BREW4/sdk/../inc -I../inc -I../../common -IC:DevignoreBOOST_~1 -IWin32_Debug -I"c:/Program Files (x86)/Microsoft Visual Studio 10.0/VC//Include" -I"c:/Program Files (x86)/Microsoft Visual Studio 10.0/VC//PlatformSDK/Include" -FoWin32_Debug/AEEAppGen.o C:/PROGRA~1/Qualcomm/BrewMPSDK/Platforms/BREW4/sdk/src/AEEAppGen.c
BUILD FAILED
C:Devbrew.xml:27: The following error occurred while executing this line:
C:Devbrew.xml:43: exec returned: 2

我找不到有关错误 -1073741515 的任何信息,所以我不知道有什么麻烦。但是:如果我运行相同的命令(在与之前的 ant 调用相同的 cmd 窗口中),一切正常。

cs-make -f brew.mak

我的第一个想法是 - 并且仍然是我最好的赌注 - 它一定与我的环境有关。为此,我将newenvironment="false"添加到我的执行行中。没有成功。
欢迎任何提示...

这是一个

工作太晚的问题。第一次遇到此错误后,我认为它一定是 %PATH% 或其他环境变量。所以我添加了这一行:

<env key="PATH" value="${env.PATH}" />

我从项目中的其他地方复制了这个,但没有交叉检查它是否为我的环境保存正确的 %PATH%。
由于它不起作用,我用谷歌搜索并找到了 exec 目标的参数 newenvironment="false" 并添加了它 - 但由于目标中的上述行没有保存正确的 env。路径值,它出错了。

这对我有用:

<target name="build.brew.target" if="${cfg.build.brew}" depends="brew.clean">
  <exec dir="${src.cpp.brew}/brew" executable="cs-make" failonerror="true" newenvironment="false">
    <arg line="-f brew.mak" />
  </exec>
  ...
</target>

相关内容

  • 没有找到相关文章

最新更新