<project name="CS2JDist" default="release" basedir="."> <description> This build file builds a cs2j distribution archive </description> <tstamp> <format property="timestamp.format" pattern="yyMMdd" /> </tstamp> <property file="${user.home}/${ant.project.name}.build.properties"/> <property file="${user.home}/build.properties"/> <property file="local.build.properties"/> <property file="build.properties"/> <!-- load the ant-antlr task --> <taskdef resource="org/apache/tools/ant/antlr/antlib.xml" classpath="${builder.ant.lib}/ant-antlr3.jar;${project.dir}/jar/antlr-3.3.jar" /> <!-- git macros, stolen / based on http://tlrobinson.net/blog/2008/11/13/ant-tasks-for-git/ --> <macrodef name = "git"> <attribute name = "command" /> <attribute name = "dir" default = "" /> <attribute name = "failonerror" default = "false" /> <attribute name = "gitresult" default = "gitresult" /> <attribute name = "gitresultsetonfail" default = "@{gitresult}.setonfail" /> <element name = "args" optional = "true" /> <sequential> <echo message = "git @{command}" /> <exec executable = "git" dir = "@{dir}" failonerror="@{failonerror}" resultproperty = "@{gitresult}"> <arg value = "@{command}" /> <args/> </exec> <condition property="@{gitresultsetonfail}"> <equals arg1="${@{gitresult}}" arg2="1"/> </condition> </sequential> </macrodef> <target name="release" description="make a release archive" depends="clean,init,switch,checkclean,buildcs2j,signtxfiles,tagme,mkcs2jlibprojsrc,mkarchive"/> <target name="releasefromhere" description="make a release archive off the current branch" depends="clean,init,checkclean,buildcs2j,signtxfiles,mkcs2jlibprojsrc,mkarchive"/> <target name="dummyrelease" description="make a release archive (doesn't change git repository)" depends="init,buildcs2j,signtxfiles,mkcs2jlibprojsrc,mkarchive"/> <target name="dist" description="Distribute final zip to final resting place"> <copy todir="${release.dir}" file="${release.zip}"/> <copy tofile="${release.dir}/cs2j-latest.zip" file="${release.zip}"/> </target> <target name="mkarchive" description="builds a zip file containing the release"> <mkdir dir="${build.dir}/archive/cs2j-${release.tagname}"/> <copy todir="${build.dir}/archive/cs2j-${release.tagname}"> <fileset dir="${cs2j.library.project}" includes="NetFramework/**/*.xml"/> <fileset dir="${project.dir}" includes="THIRDPARTY-LICENSES/**"/> <fileset dir="${build.dir}/cs2jlibrary" includes="**/*.zip"/> </copy> <copy todir="${build.dir}/archive/cs2j-${release.tagname}/THIRDPARTY-LICENSES" file="${cs2j.parser.dir}/cs.g"/> <copy todir="${build.dir}/archive/cs2j-${release.tagname}/CS2JTranslator/bin"> <fileset dir="${cs2j.src.dir}/CS2JTranslator/${exe.sub.dir}"> <exclude name="*.vshost.*"/> <include name="*.exe"/> </fileset> <globmapper from="*.exe" to="*.exe${exe.extension}"/> </copy> <copy todir="${build.dir}/archive/cs2j-${release.tagname}/CS2JTranslator/bin"> <fileset dir="${cs2j.src.dir}/CS2JTranslator/${exe.sub.dir}"> <exclude name="*.vshost.*"/> <include name="*.dll"/> </fileset> </copy> <copy todir="${build.dir}/archive/cs2j-${release.tagname}"> <fileset dir="${project.dir}/docs/external"> <include name="README"/> <include name="*.pdf"/> </fileset> </copy> <zip destfile="${release.zip}" basedir="${build.dir}/archive/" includes="cs2j-${release.tagname}/**/*"/> </target> <target name="mkcs2jlibprojsrc" description="Build CS2JLibrary Project source for distribution"> <ant dir="${cs2j.library.project}" target="src"> <property name="src.zip" value="${build.dir}/cs2jlibrary/cs2jlib-src-${release.tagname}.zip"/> </ant> </target> <target name="pushme" description="Push changes to remote" > <git command = "push" failonerror="true"> <args> <arg value = "origin"/> <arg value = "HEAD"/> </args> </git> <git command = "push" failonerror="true"> <args> <arg value = "--tags"/> </args> </git> </target> <target name="tagme" description="tag current state"> <git command = "tag" failonerror="true"> <args> <arg value = "-a"/> <arg value = "-m"/> <arg value = "Tagging release"/> <arg value = "${release.tagname}"/> </args> </git> </target> <target name="getuserguide" description="Downloads the user guide for Google Docs (need to install googlecl)"> <exec executable="google" failonerror="false"> <arg value = "docs"/> <arg value = "--user=${google.docs.user}"/> <arg value = "--folder=${google.docs.folder}"/> <arg value = "--dest=${project.dir}/docs/external/${google.docs.title}.pdf"/> <arg value = "get"/> <arg value = "${google.docs.title}.doc"/> </exec> </target> <target name="signtxfiles" description="Add / Update the signatures on the translation files in NetFrameworks"> <exec osfamily="windows" executable="${tx.signer.exe}"> <arg value = "-keyfile"/> <arg value = "${tx.signer.keyfile}"/> <arg value = "${tx.files.root}"/> </exec> <exec osfamily="mac" executable="mono"> <arg value = "${tx.signer.exe}"/> <arg value = "-keyfile"/> <arg value = "${tx.signer.keyfile}"/> <arg value = "${tx.files.root}"/> </exec> </target> <target name="buildcs2j" depends="buildgrammars" description="builds all C# source in the solution"> <exec osfamily="windows" executable="${win.msbuild.exe}" failonerror="true"> <arg value = "${cs2j.sln}"/> </exec> <exec osfamily="mac" executable="${other.msbuild.exe}" failonerror="true"> <arg value = "${cs2j.sln}"/> </exec> </target> <target name="buildgrammars" description="invokes ANTLR to convert grammar files to C# source"> <ant-antlr3 xmlns:antlr="antlib:org/apache/tools/ant/antlr" verbose="true" target="${cs2j.parser.dir}/cs.g" make="true" conversiontimeout="15000" /> <ant-antlr3 xmlns:antlr="antlib:org/apache/tools/ant/antlr" verbose="true" target="${cs2j.transform.dir}/TemplateExtracter.g" libdirectory="${cs2j.parser.dir}" make="true" conversiontimeout="15000"/> <ant-antlr3 xmlns:antlr="antlib:org/apache/tools/ant/antlr" verbose="true" target="${cs2j.transform.dir}/JavaMaker.g" libdirectory="${cs2j.parser.dir}" make="true" conversiontimeout="15000"/> <ant-antlr3 xmlns:antlr="antlib:org/apache/tools/ant/antlr" verbose="true" target="${cs2j.transform.dir}/NetMaker.g" libdirectory="${cs2j.parser.dir}" make="true" conversiontimeout="15000"/> <ant-antlr3 xmlns:antlr="antlib:org/apache/tools/ant/antlr" verbose="true" target="${cs2j.transform.dir}/JavaPrettyPrint.g" libdirectory="${cs2j.parser.dir}" make="true" conversiontimeout="15000"/> </target> <target name="switch" description="switched to release branch"> <git command = "checkout" failonerror="true"> <args> <arg value = "--quiet"/> <arg value = "${release.branch}"/> </args> </git> </target> <target name="checkclean" description="fails if working copy is dirty"> <git command = "diff-index" gitresult = "local.wc.isdirty"> <args> <arg value = "--quiet"/> <arg value = "HEAD"/> </args> </git> <fail message = "Working Copy is dirty. Commit changes and try again." if="local.wc.isdirty.setonfail" /> </target> <target name="init" depends=""> <mkdir dir="${build.dir}" /> </target> <target name="clean" depends="" description="Clean build directory"> <delete failonerror="false" dir="${build.dir}" /> <delete failonerror="false" dir="${cs2j.parser.dir}" includes="cs*.cs *.tokens"/> <delete failonerror="false" dir="${cs2j.transform.dir}" includes="*.cs *.tokens" excludes="CommonWalker.cs"/> <exec osfamily="windows" executable="${win.msbuild.exe}"> <arg value = "${cs2j.sln}"/> <arg value = "/verbosity:quiet"/> <arg value = "/t:Clean"/> </exec> <exec osfamily="mac" executable="${other.msbuild.exe}"> <arg value = "${cs2j.sln}"/> <arg value = "/verbosity:quiet"/> <arg value = "/t:Clean"/> </exec> </target> <target name="dumpProperties" description="output all set properties, a useful sanity check"> <echoproperties/> </target> </project>