0
<?xml version="1.0" encoding="UTF-8" ?>
<project name="winplay" default="build">
<target name="build">
<echo message="${bitoption}" />
<mkdir dir="build" />
<mkdir dir="build/obj" />
<cc name="g++" objdir="build/obj" debug="${debug}">
<fileset dir="src" includes="*.cpp" />
<compiler name="g++">
<compilerarg value="-std=c++11" />
<compilerarg value="-m32" />
</compiler>
</cc>
<condition property="debugoption" value="-g -O0" else="-O2">
<isset property="debug" />
</condition>
<fileset dir="build/obj" id="objects">
<include name="*.o" />
</fileset>
<pathconvert pathsep=" " property="objectslinker" refid="objects" />
<!-- Due to a bug in GppLinker.java in cpptasks.jar, we must exec g++ because GppLinker erroneously uses gcc, which breaks exception handling. -->
<exec command="g++ -std=c++11 -m32 -mwindows ${debugoption} -o build/winplay ${objectslinker}" failonerror="true" />
</target>
<target name="build-32" depends="build">
<property name="bitoption" value="-m32" />
</target>
<target name="build-64" depends="build">
<property name="bitoption" value="-m64" />
</target>
<target name="clean">
<delete dir="build" />
</target>
</project>
我試圖讓$ {bitoption}爲-m32或-m64,這取決於我們是調用目標build-32還是build-64。然後,我將$ {bitoption}傳遞給編譯器和鏈接器參數,以便可以生成相應的exe。我做了一個簡單的回聲測試,看看$ {bitoption}是否設置正確,並且看起來不起作用。我得到的是:爲什麼這個ant腳本不能工作?
Buildfile: E:\_dev\windows\MinGW\msys\home\windoze\projects\Winplay\build.xml
build:
[echo] ${bitoption}
[cc] 1 total files to be compiled.
[exec] The command attribute is deprecated.
[exec] Please use the executable attribute and nested arg elements.
build-64:
BUILD SUCCESSFUL
Total time: 1 second