如何使用ant构建c++程序?
如何使用ant构建c++程序?
build_cpp.xml
<?xmlversion="1.0"?>
<projectname="antcpp"default="test">
<!--引入外部文件-->
<importfile="build.inc"/>
<taskdefresource="cpptasks.tasks"/>
<typedefresource="cpptasks.types"/>
<taskdefresource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelementlocation="/usr/share/java/ant-contrib.jar"/>
</classpath>
</taskdef>
<propertyname="base.dir"value="."/>
<propertyname="debug"value="true"/>
<propertyname="compiler"value="gcc"/>
<propertyname="src.dir"location="${base.dir}"/>
<propertyname="samples.dir"location="${base.dir}/samples"/>
<propertyname="build.dir"location="build"/>
<propertyname="obj.dir"location="${build.dir}/obj"/>
<propertyname="include.dir"location="${base.dir}/include"/>
<propertyname="config.dir"location="${base.dir}/config"/>
<propertyname="major"value="0"/>
<propertyname="minor"value="9"/>
<propertyname="build"value="8"/>
<!--specifyapi="unix"orapi="win32"overrideplatformdefault-->
<propertyname="api"value="default"/>
<!--compilerflagdefine-->
<propertyname="CXX_DFLAGS"value="${DFLAGS}-DXML_ERRORS-DHAVE_CONFIG_H-DFOR_LT"/>
<propertyname="RIGHT_HOME"value="${CGI_HOME}/right"/>
<targetname="usage">
<echomessage="Usage:"/>
<echomessage="ant-fbuild_cpp.xml"/>
</target>
<targetname="init">
<echomessage="buildinit"/>
<mkdirdir="${build.dir}"/>
<mkdirdir="${obj.dir}"/>
<conditionproperty="is-gcc">
<or>
<equalsarg1="${compiler}"arg2="gcc"/>
<equalsarg1="${compiler}"arg2="g++"/>
</or>
</condition>
<conditionproperty="is-msvc">
<or>
<equalsarg1="${compiler}"arg2="msvc"/>
</or>
</condition>
<conditionproperty="is-windows"><osfamily="windows"/></condition>
<conditionproperty="is-win32">
<or>
<equalsarg1="${api}"arg2="win32"/>
<and>
<equalsarg1="${api}"arg2="default"/>
<issetproperty="is-windows"/>
</and>
</or>
</condition>
<propertyenvironment="env"/>
<!--incasenotsetinenvironment,useaninsignificantvalue-->
<propertyname="env.LD_LIBRARY_PATH"value="."/>
</target>
<targetname="clean">
<echomessage="buildcleanall"/>
<deletedir="${build.dir}"/>
</target>
<targetname="build-cpp">
<basenameproperty="test.name"file="${a123}"suffix="cpp"/>
<echomessage="compile${test.name}.cppwith${compiler}"/>
<!--preprocesses.uiand.hfiles,placesgeneratedfilesonobj.dir-->
<ccsubsystem="console"
objdir="${obj.dir}"
debug="${debug}"
outtype="executable"
name="${compiler}"
exceptions="true"
rtti="true"
optimize="speed"
outfile="${build.dir}/${test.name}.cgi"
>
<filesetdir="${src.dir}"includes="${test.name}.cpp"/>
<syslibsetlibs="z,m,cgicc,ghttp,ltapi${LTXML_VERSION},ltstd${LTXML_VERSION}"/>
<libsetdir="${MYSQL_LIB}"libs="mysqlclient"/>
<libsetdir="../../lib"libs="gspsright,myutil,db,share,webdev,xmlcpp,ini,net"/>
<compilerargvalue="-O2"/>
<compilerargvalue="-Wno-deprecated"/>
<defineset>
<definename="FOR_LT"/>
<definename="HAVE_CONFIG_H"/>
<definename="XML_ERRORS"/>
<definename="SQLLOG"/>
<definename="GSPS_HOME"value=""${PUB_HOME}""/>
</defineset>
<includepathlocation="${MYSQL_INC}"/>
<includepathlocation="/usr/local/include"/>
<includepathlocation="${LTXML_INC}"/>
<includepathlocation="${BOOST_HOME}"/>
</cc>
</target>
<targetname="build-all"depends="init,setProperties">
<echomessage="Thefirstfivelettersofthealphabetare:"/>
<foreachparam="a123"target="build-cpp">
<path>
<filesetdir="${src.dir}"includes="*.cpp"/>
</path>
</foreach>
</target>
<targetname="test"depends="build-all">
<execdir="${build.dir}"
executable="ls"
failonerror="false">
</exec>
</target>
</project>
<projectname="antcpp"default="test">
<!--引入外部文件-->
<importfile="build.inc"/>
<taskdefresource="cpptasks.tasks"/>
<typedefresource="cpptasks.types"/>
<taskdefresource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelementlocation="/usr/share/java/ant-contrib.jar"/>
</classpath>
</taskdef>
<propertyname="base.dir"value="."/>
<propertyname="debug"value="true"/>
<propertyname="compiler"value="gcc"/>
<propertyname="src.dir"location="${base.dir}"/>
<propertyname="samples.dir"location="${base.dir}/samples"/>
<propertyname="build.dir"location="build"/>
<propertyname="obj.dir"location="${build.dir}/obj"/>
<propertyname="include.dir"location="${base.dir}/include"/>
<propertyname="config.dir"location="${base.dir}/config"/>
<propertyname="major"value="0"/>
<propertyname="minor"value="9"/>
<propertyname="build"value="8"/>
<!--specifyapi="unix"orapi="win32"overrideplatformdefault-->
<propertyname="api"value="default"/>
<!--compilerflagdefine-->
<propertyname="CXX_DFLAGS"value="${DFLAGS}-DXML_ERRORS-DHAVE_CONFIG_H-DFOR_LT"/>
<propertyname="RIGHT_HOME"value="${CGI_HOME}/right"/>
<targetname="usage">
<echomessage="Usage:"/>
<echomessage="ant-fbuild_cpp.xml"/>
</target>
<targetname="init">
<echomessage="buildinit"/>
<mkdirdir="${build.dir}"/>
<mkdirdir="${obj.dir}"/>
<conditionproperty="is-gcc">
<or>
<equalsarg1="${compiler}"arg2="gcc"/>
<equalsarg1="${compiler}"arg2="g++"/>
</or>
</condition>
<conditionproperty="is-msvc">
<or>
<equalsarg1="${compiler}"arg2="msvc"/>
</or>
</condition>
<conditionproperty="is-windows"><osfamily="windows"/></condition>
<conditionproperty="is-win32">
<or>
<equalsarg1="${api}"arg2="win32"/>
<and>
<equalsarg1="${api}"arg2="default"/>
<issetproperty="is-windows"/>
</and>
</or>
</condition>
<propertyenvironment="env"/>
<!--incasenotsetinenvironment,useaninsignificantvalue-->
<propertyname="env.LD_LIBRARY_PATH"value="."/>
</target>
<targetname="clean">
<echomessage="buildcleanall"/>
<deletedir="${build.dir}"/>
</target>
<targetname="build-cpp">
<basenameproperty="test.name"file="${a123}"suffix="cpp"/>
<echomessage="compile${test.name}.cppwith${compiler}"/>
<!--preprocesses.uiand.hfiles,placesgeneratedfilesonobj.dir-->
<ccsubsystem="console"
objdir="${obj.dir}"
debug="${debug}"
outtype="executable"
name="${compiler}"
exceptions="true"
rtti="true"
optimize="speed"
outfile="${build.dir}/${test.name}.cgi"
>
<filesetdir="${src.dir}"includes="${test.name}.cpp"/>
<syslibsetlibs="z,m,cgicc,ghttp,ltapi${LTXML_VERSION},ltstd${LTXML_VERSION}"/>
<libsetdir="${MYSQL_LIB}"libs="mysqlclient"/>
<libsetdir="../../lib"libs="gspsright,myutil,db,share,webdev,xmlcpp,ini,net"/>
<compilerargvalue="-O2"/>
<compilerargvalue="-Wno-deprecated"/>
<defineset>
<definename="FOR_LT"/>
<definename="HAVE_CONFIG_H"/>
<definename="XML_ERRORS"/>
<definename="SQLLOG"/>
<definename="GSPS_HOME"value=""${PUB_HOME}""/>
</defineset>
<includepathlocation="${MYSQL_INC}"/>
<includepathlocation="/usr/local/include"/>
<includepathlocation="${LTXML_INC}"/>
<includepathlocation="${BOOST_HOME}"/>
</cc>
</target>
<targetname="build-all"depends="init,setProperties">
<echomessage="Thefirstfivelettersofthealphabetare:"/>
<foreachparam="a123"target="build-cpp">
<path>
<filesetdir="${src.dir}"includes="*.cpp"/>
</path>
</foreach>
</target>
<targetname="test"depends="build-all">
<execdir="${build.dir}"
executable="ls"
failonerror="false">
</exec>
</target>
</project>
build_cpp.inc
<projectname="Const_variant"default="setProperties">
<taskdefresource="cpptasks.tasks"/>
<typedefresource="cpptasks.types"/>
<taskdefresource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelementlocation="/usr/share/java/ant-contrib.jar"/>
</classpath>
</taskdef>
<propertyname="GSPS_HOME"value=""/>
<propertyname="PUB_HOME"value=""/>
<propertyname="APACHE_HOME"value=""/>
<propertyname="CGI_HOME"value="${APACHE_HOME}/cgi-bin/"/>
<propertyname="HTML_HOME"value="${APACHE_HOME}/htdocs/"/>
<propertyname="BIN_HOME"value="${PUB_HOME}/bin"/>
<propertyname="TMPL_HOME"value="${PUB_HOME}/tmpl"/>
<propertyname="DATA_HOME"value="${PUB_HOME}/data"/>
<propertyname="LIB_HOME"value="${PUB_HOME}/lib"/>
<propertyname="RPATH"value="${LIB_HOME}"/>
<propertyname="GDB_FLAGS"value="-O2"/>
<propertyname="DGSPS_HOME"value="-DGSPS_HOME="${PUB_HOME}""/>
<propertyname="DSQLLOG"value="-DSQLLOG"/>
<propertyname="MYSQL_HOME"value="/usr/local/mysql"/>
<propertyname="BOOST_HOME"value="${PUB_HOME}/supports/boost-1.30.2"/>
<propertyname
<taskdefresource="cpptasks.tasks"/>
<typedefresource="cpptasks.types"/>
<taskdefresource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelementlocation="/usr/share/java/ant-contrib.jar"/>
</classpath>
</taskdef>
<propertyname="GSPS_HOME"value=""/>
<propertyname="PUB_HOME"value=""/>
<propertyname="APACHE_HOME"value=""/>
<propertyname="CGI_HOME"value="${APACHE_HOME}/cgi-bin/"/>
<propertyname="HTML_HOME"value="${APACHE_HOME}/htdocs/"/>
<propertyname="BIN_HOME"value="${PUB_HOME}/bin"/>
<propertyname="TMPL_HOME"value="${PUB_HOME}/tmpl"/>
<propertyname="DATA_HOME"value="${PUB_HOME}/data"/>
<propertyname="LIB_HOME"value="${PUB_HOME}/lib"/>
<propertyname="RPATH"value="${LIB_HOME}"/>
<propertyname="GDB_FLAGS"value="-O2"/>
<propertyname="DGSPS_HOME"value="-DGSPS_HOME="${PUB_HOME}""/>
<propertyname="DSQLLOG"value="-DSQLLOG"/>
<propertyname="MYSQL_HOME"value="/usr/local/mysql"/>
<propertyname="BOOST_HOME"value="${PUB_HOME}/supports/boost-1.30.2"/>
<propertyname