Delphi7 Want编译配置文件编写

来源:互联网 发布:淘宝vr购物是什么意思 编辑:程序博客网 时间:2024/05/21 01:28

最近在学习TDD开发,一直用Delphi7开发程序(各位大侠不要笑话我),配合DUNIT开发(推荐用DUNITWizard插件,支持生成test程序在Console和GUI下运行),通过网上查找内容,发现这篇网页和PDF文档介绍的内容比较适用我,下载Want(下载0.3.3,最新2.02支持的脚本xml,是一种Script语言),WANT是像ant的构建工具,基本上语法与ant一致,但是增加了dcc,dunit几个与delphi有关的命令。自己研究下,编写了一个支持我项目中的配置文件build.xml。我的目录结构和上面网页的类似,不过约有调整。

Project

—    |–src(应用程序源码)

        |–test(测试程序源码)

        |–scratch(中间文件)

             |–dcu(生成的编译文件)
        |–deploy(执行代码和构建文件build.xml)
        |–doc(文档)
        |–lib(开发库)
            |–want

 

配置文件如下:

<project name="testcommonprj" basedir="." default="compile" >    <property name="src.dir" value="${basedir}/src" />    <property name="test.dir" value="${basedir}/test" />    <property name="deploy.dir" value="${basedir}/deploy" />    <property name="dcu.dir" value="${basedir}/scratch/dcu" />    <property name="delphi" value="D:/Program Files/Borland/Delphi7" />    <property name="components" value="E:/Source/Delphi/Component"/>    <property name="test.app" value="testcommonprjstructTests" />    <property name="main.app" value="testcommonprjstruct" />    <property name="mainexe.name" value="${deploy}/${main.app}.exe"/>    <property name="maintestexe.name" value="${deploy}/${test.app}.exe"/>        <patternset id="componentsdir">        <include name = "${components}/dunit_v9.2.0/src"  />    </patternset>           <patternset id="main.src">        <include name="${src.dir}/view"  />        <include name="${src.dir}/common"  />    </patternset>               <patternset id="test.src" refid="main.src">        <include name="${test.dir}/**"  />    </patternset>               <target name="clean">        <echo message="delete dcu" />        <delete dir="${dcu.dir}" >            <include name="**" />        </delete>        <echo message="delete exe" />               <delete dir="${deploy.dir}">            <include name="*.exe" />        </delete>               </target>            <target name="prepare">        <mkdir dir="${dcu.dir}"></mkdir>        <mkdir dir="${deploy.dir}"></mkdir>    </target>       <target name="compile" depends="clean,compiletest,compileapp">      </target>        <target name="compileapp">        <echo message="build ${main.app}" />        <dcc basedir="${src.dir}" source="${main.app}.dpr">            <build value="True" />            <exeoutput path="${deploy.dir}" />            <dcuoutput path="${dcu.dir}" />            <warnings value="True" />            <map value="none" />            <console value="False" />            <unitPath refid="main.src" />            <resourcePath refid="main.src"/>        </dcc>      </target>               <target name="compiletest">        <echo message="build ${test.app}" />        <dcc basedir="${test.dir}" source="${test.app}.dpr">            <build value="True" />            <exeoutput path="${deploy.dir}" />            <dcuoutput path="${dcu.dir}" />            <warnings value="True" />            <map value="none" />            <console value="True" />            <unitPath refid="test.src" />            <includepath refid="componentsdir" />            <resourcePath refid="test.src"/>        </dcc>      </target>           <target name="runtest" depends="clean,compiletest">        <echo message="run test ${maintestexe.name}" />        <exec executable="${maintestexe.name}"/>    </target>        <target name="runmain" depends="clean,compileapp">        <echo message="run test ${mainexe.name}" />        <exec executable="${mainexe.name}"/>    </target>   </project>


原创粉丝点击