【问题标题】:ant target exec fails, while running command on shell is sucsessfulant target exec 失败,而在 shell 上运行命令成功
【发布时间】:2013-09-06 19:55:01
【问题描述】:

我有一个针对不同目标平台和主机平台运行的构建环境,使用 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:\Dev\lib\cpp\libspeex\include -I. -IC:/PROGRA~1/Qualcomm/BrewMPSDK/Platforms/BREW4/sdk/inc -IC:/PROGRA~1/Qualcomm/BrewMPSDK/Platforms/BREW4/sdk/../inc -I../inc -I../../common -IC:\Dev\ignore\BOOST_~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:\Dev\lib\cpp\libspeex\include -I. -IC:/PROGRA~1/Qualcomm/BrewMPSDK/Platforms/BREW4/sdk/inc -IC:/PROGRA~1/Qualcomm/BrewMPSDK/Platforms/BREW4/sdk/../inc -I../inc -I../../common -IC:\Dev\ignore\BOOST_~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\..\res\brew.bar +,,Win32_Debug\..\res\brew.bar>nul) else (echo on>Win32_Debug/../res/brew.bar)
 [exec] "C:/PROGRA~1/Qualcomm/BREWMP~1/TOOLSE~1.246/bin/cifc.exe"  -IC:\Dev\lib\cpp\libspeex\include -I. -IC:/PROGRA~1/Qualcomm/BrewMPSDK/Platforms/BREW4/sdk/inc -IC:/PROGRA~1/Qualcomm/BrewMPSDK/Platforms/BREW4/sdk/../inc -I../inc -I../../common -IC:\Dev\ignore\BOOST_~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:\Dev\lib\cpp\libspeex\include -I. -IC:/PROGRA~1/Qualcomm/BrewMPSDK/Platforms/BREW4/sdk/inc -IC:/PROGRA~1/Qualcomm/BrewMPSDK/Platforms/BREW4/sdk/../inc -I../inc -I../../common -IC:\Dev\ignore\BOOST_~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:\Dev\lib\cpp\libspeex\include -I. -IC:/PROGRA~1/Qualcomm/BrewMPSDK/Platforms/BREW4/sdk/inc -IC:/PROGRA~1/Qualcomm/BrewMPSDK/Platforms/BREW4/sdk/../inc -I../inc -I../../common -IC:\Dev\ignore\BOOST_~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:\Dev\brew.xml:27: The following error occurred while executing this line:
C:\Dev\brew.xml:43: exec returned: 2

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

cs-make -f brew.mak

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

【问题讨论】:

  • 尝试将 -verbose-debug 添加到您的 ant 调用中,看看您是否获得了有关 exec 失败原因的更多有用信息
  • 我做到了,但几乎没有更多可看的了。真的,唯一出现的是 ant 的堆栈跟踪。我还尝试使用 output="somefile.log" 参数作为 exec 目标,但输出与屏幕上的相同。不是ant错误,是cs-make.exe抛出的错误信息,但是我不知道是什么意思。

标签: c ant compilation


【解决方案1】:

这是一个为时已晚的问题。在我第一次遇到这个错误后,我认为它必须是 %PATH% 或其他环境变量。所以我添加了这一行:

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

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

<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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-28
    相关资源
    最近更新 更多