2011-03-22 16:37:50 +01:00
<project name= "CS2JDist" default= "release" basedir= "." >
<description >
This build file builds a cs2j distribution archive
</description>
2011-03-22 17:34:03 +01:00
<tstamp >
2011-03-23 14:54:47 +01:00
<format property= "timestamp.format" pattern= "yyMMdd" />
2011-03-22 17:34:03 +01:00
</tstamp>
2011-03-22 16:37:50 +01:00
<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>
2011-12-06 15:23:30 +01:00
<target name= "setplatform" >
<condition property= "windows.platform" >
<os family= "windows" />
</condition>
</target>
2011-12-07 12:10:35 +01:00
<target name= "settrial" >
<property name= "cs2j.user.guide" value= "${google.docs.trial.title}" />
</target>
<target name= "setrelease" >
<property name= "cs2j.user.guide" value= "${google.docs.title}" />
</target>
2011-09-02 11:33:26 +02:00
<target name= "release" description= "make a release archive" depends= "clean,init,switch,checkclean,buildcs2j,signtxfiles,tagme,mkcs2jlibprojsrc,mkarchive,mkmailarchive" />
2011-03-22 16:37:50 +01:00
2011-12-07 12:10:35 +01:00
<target name= "releasefromhere" description= "make a release archive off the current branch" depends= "clean,init,checkclean,setrelease,buildcs2j,signtxfiles,mkcs2jlibprojsrc,mkarchive,mkmailarchive" />
2011-12-06 15:23:30 +01:00
2011-12-07 12:10:35 +01:00
<target name= "trialfromhere" description= "make a release archive off the current branch" depends= "clean,init,checkclean,settrial,buildcs2j,obfuscate,signtxfiles,mkcs2jlibprojsrc,mkarchive,mkmailarchive" />
2011-05-26 02:20:27 -05:00
2011-09-02 11:33:26 +02:00
<target name= "dummyrelease" description= "make a release archive (doesn't change git repository)" depends= "clean,init,buildcs2j,signtxfiles,mkcs2jlibprojsrc,mkarchive,mkmailarchive" />
2011-03-22 17:34:03 +01:00
2011-03-23 16:33:09 +01:00
<target name= "dist" description= "Distribute final zip to final resting place" >
2011-03-23 16:31:34 +01:00
<copy todir= "${release.dir}" file= "${release.zip}" />
2011-07-27 12:00:13 +02:00
<copy tofile= "${release.dir}/cs2j-trial-latest.zip" file= "${release.zip}" />
2011-03-23 16:31:34 +01:00
</target>
2011-09-02 11:33:26 +02:00
<target name= "mkmailarchive" description= "builds a zip file containing the release, adds dummy extension to executables" if= "mailsafe.exe.extension" depends= "mkreleasefiles" >
<move todir= "${build.dir}/archive/cs2j-${release.tagname}" includeemptydirs= "false" >
<fileset dir= "${build.dir}/archive/cs2j-${release.tagname}" >
<include name= "**/*.exe" />
</fileset>
<mapper type= "glob" from= "*" to= "*${mailsafe.exe.extension}" />
</move>
<zip destfile= "${release.mailsafe.zip}" basedir= "${build.dir}/archive/" includes= "cs2j-${release.tagname}/**/*" />
</target>
<target name= "mkarchive" description= "builds a zip file containing the release" depends= "mkreleasefiles" >
<zip destfile= "${release.zip}" basedir= "${build.dir}/archive/" includes= "cs2j-${release.tagname}/**/*" />
</target>
2011-12-06 15:33:20 +01:00
<target name= "obfuscate" description= "runs obfuscator on cs2j executable if windows" depends= "buildcs2j,setplatform,do-obfuscate" >
2011-12-06 15:23:30 +01:00
</target>
<target name= "do-obfuscate" description= "runs obfuscator on cs2j executable" if= "windows.platform" >
<exec osfamily= "windows" executable= "${obfuscator.exe}" failonerror= "true" >
<arg value= "-o" />
<arg value= "${cs2j.src.dir}/CS2JTranslator/${exe.sub.dir}/obcs2j.exe" />
<arg value= "${cs2j.src.dir}/CS2JTranslator/${exe.sub.dir}/cs2j.exe" />
</exec>
<move file= "${cs2j.src.dir}/CS2JTranslator/${exe.sub.dir}/obcs2j.exe"
tofile="${cs2j.src.dir}/CS2JTranslator/${exe.sub.dir}/cs2j.exe" />
</target>
2011-09-02 11:33:26 +02:00
<target name= "mkreleasefiles" description= "creates a set of release files" >
2011-03-23 14:54:47 +01:00
<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}" >
2011-05-26 03:44:43 -05:00
<exclude name= "*.vshost.*" />
2011-03-23 14:54:47 +01:00
<include name= "*.exe" />
<include name= "*.dll" />
</fileset>
</copy>
<copy todir= "${build.dir}/archive/cs2j-${release.tagname}" >
<fileset dir= "${project.dir}/docs/external" >
<include name= "README" />
2011-09-07 13:52:59 +02:00
<include name= "CHANGELOG" />
2011-12-07 12:10:35 +01:00
<include name= "${cs2j.user.guide}.pdf" />
2011-03-23 14:54:47 +01:00
</fileset>
</copy>
2011-09-14 15:08:08 +02:00
<copy todir= "${build.dir}/archive/cs2j-${release.tagname}" >
<fileset dir= "${project.dir}/resources" >
<include name= "DefaultSettings.ini" />
</fileset>
</copy>
2011-03-23 14:54:47 +01:00
</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>
2011-03-22 17:34:03 +01:00
<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>
2011-03-22 17:43:48 +01:00
<target name= "tagme" description= "tag current state" >
2011-03-22 17:34:03 +01:00
<git command = "tag" failonerror= "true" >
<args >
<arg value = "-a" />
<arg value = "-m" />
<arg value = "Tagging release" />
<arg value = "${release.tagname}" />
</args>
</git>
2011-03-22 16:37:50 +01:00
</target>
2011-12-07 10:15:42 +01:00
<target name= "refreshdocs" description= "Refreshes the user guides for Google Docs (need to install googlecl)" >
<antcall target= "getuserguide" >
<param name= "google.docs.title" value= "CS2JTrialUsersGuide" />
</antcall>
<antcall target= "getuserguide" >
<param name= "google.docs.title" value= "CS2JUsersGuide" />
</antcall>
</target>
2011-03-23 14:54:47 +01:00
<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>
2011-03-22 17:34:03 +01:00
<target name= "buildcs2j" depends= "buildgrammars" description= "builds all C# source in the solution" >
2011-03-23 14:54:47 +01:00
<exec osfamily= "windows" executable= "${win.msbuild.exe}" failonerror= "true" >
2011-03-22 17:34:03 +01:00
<arg value = "${cs2j.sln}" />
</exec>
2011-03-23 14:54:47 +01:00
<exec osfamily= "mac" executable= "${other.msbuild.exe}" failonerror= "true" >
2011-03-22 17:34:03 +01:00
<arg value = "${cs2j.sln}" />
</exec>
</target>
<target name= "buildgrammars" description= "invokes ANTLR to convert grammar files to C# source" >
2011-03-22 16:37:50 +01:00
<ant-antlr3 xmlns:antlr= "antlib:org/apache/tools/ant/antlr" verbose= "true"
target="${cs2j.parser.dir}/cs.g"
2011-03-26 17:29:28 +01:00
make="true" conversiontimeout="15000" />
2011-03-22 16:37:50 +01:00
<ant-antlr3 xmlns:antlr= "antlib:org/apache/tools/ant/antlr" verbose= "true"
target="${cs2j.transform.dir}/TemplateExtracter.g"
libdirectory="${cs2j.parser.dir}"
2011-03-26 17:29:28 +01:00
make="true" conversiontimeout="15000"/>
2011-03-22 16:37:50 +01:00
<ant-antlr3 xmlns:antlr= "antlib:org/apache/tools/ant/antlr" verbose= "true"
target="${cs2j.transform.dir}/JavaMaker.g"
libdirectory="${cs2j.parser.dir}"
2011-03-26 17:29:28 +01:00
make="true" conversiontimeout="15000"/>
2011-03-22 16:37:50 +01:00
<ant-antlr3 xmlns:antlr= "antlib:org/apache/tools/ant/antlr" verbose= "true"
target="${cs2j.transform.dir}/NetMaker.g"
libdirectory="${cs2j.parser.dir}"
2011-03-26 17:29:28 +01:00
make="true" conversiontimeout="15000"/>
2011-03-22 16:37:50 +01:00
<ant-antlr3 xmlns:antlr= "antlib:org/apache/tools/ant/antlr" verbose= "true"
target="${cs2j.transform.dir}/JavaPrettyPrint.g"
libdirectory="${cs2j.parser.dir}"
2011-03-26 17:29:28 +01:00
make="true" conversiontimeout="15000"/>
2011-03-22 16:37:50 +01:00
</target>
2011-03-22 17:34:03 +01:00
<target name= "switch" description= "switched to release branch" >
2011-03-22 16:37:50 +01:00
<git command = "checkout" failonerror= "true" >
<args >
<arg value = "--quiet" />
<arg value = "${release.branch}" />
</args>
</git>
2011-03-22 17:34:03 +01:00
</target>
2011-12-06 15:23:30 +01:00
<target name= "checkclean" description= "fails if working copy is dirty" unless= "override.clean.check" >
2011-03-22 16:37:50 +01:00
<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}" />
2011-03-23 14:54:47 +01:00
<delete failonerror= "false" dir= "${cs2j.parser.dir}" includes= "cs*.cs *.tokens" />
2011-11-05 14:45:18 +01:00
<delete failonerror= "false" dir= "${cs2j.transform.dir}" includes= "*.cs *.tokens" excludes= "CommonWalker.cs NetFragments.cs SyntaxFragments.cs" />
2011-03-22 17:34:03 +01:00
<exec osfamily= "windows" executable= "${win.msbuild.exe}" >
<arg value = "${cs2j.sln}" />
2011-03-23 14:54:47 +01:00
<arg value = "/verbosity:quiet" />
2011-03-22 17:34:03 +01:00
<arg value = "/t:Clean" />
</exec>
<exec osfamily= "mac" executable= "${other.msbuild.exe}" >
<arg value = "${cs2j.sln}" />
2011-03-23 14:54:47 +01:00
<arg value = "/verbosity:quiet" />
2011-03-22 17:34:03 +01:00
<arg value = "/t:Clean" />
</exec>
2011-03-22 16:37:50 +01:00
</target>
<target name= "dumpProperties" description= "output all set properties, a useful sanity check" >
<echoproperties />
</target>
</project>