1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
|
<?xml version="1.0"?>
<project name="antlr.runtime" default="usage">
<!-- =================================================================== -->
<!-- Initialization target -->
<!-- =================================================================== -->
<target name="init">
<tstamp/>
<property name="debug" value="true"/>
<property name="project.name" value="antlr.runtime"/>
<property name="project.FileName" value="antlr.runtime"/>
<property name="astframe.FileName" value="antlr.astframe"/>
<property name="src.dir" value="antlr.runtime"/>
<property name="build.dir" value="antlr.runtime/bin"/>
<property name="astframe.src.dir" value="antlr.astframe"/>
<property name="astframe.build.dir" value="antlr.astframe/bin"/>
<property name="dist.dir" value="release"/>
<property name="compile.dir" value="${build.dir}"/>
<property name="astframe.compile.dir" value="${astframe.build.dir}"/>
<property name="backup.name" value="${project.name}-backup-${tstamp.date}-${tstamp.time}.zip" />
<property name="project.version" value="x.x"/>
<property name="year" value="2005"/>
<!-- Use script task to get this from AssemblyInfo.cs using a regular expression -->
<script language="C#">
<code><![CDATA[
public static void ScriptMain(Project project) {
string assemblyInfoFileName = Path.Combine(project.BaseDirectory, "antlr.runtime/AssemblyInfo.cs");
StreamReader reader = File.OpenText(assemblyInfoFileName);
try {
// Regular expression built with Regex: http://www.organicbit.com/regex/
Regex expression = new Regex(@"^\[assembly: AssemblyVersion\(\""([0-9]+)\.([0-9]+)\.([0-9]+)");
string line = reader.ReadLine();
while (line != null) {
Match match = expression.Match(line);
if (match.Success) {
project.Properties["project.version"] = match.Result("$1.$2.$3");
break;
}
line = reader.ReadLine();
}
} finally {
// must remember to close the file or the compile may not work
reader.Close();
}
}
]]></code>
</script>
<echo message="------------------- ${project.name} ${project.version} [${year}] ----------------"/>
</target>
<!-- =================================================================== -->
<!-- Help on usage -->
<!-- =================================================================== -->
<target name="usage" depends="init">
<echo message="${project.name} - Nant Build file"/>
<echo message="-------------------------------------------------------------"/>
<echo message=""/>
<echo message=" available targets are:"/>
<echo message=""/>
<echo message=" build --> build a developer/debug version under '${build.dir}'"/>
<echo message=" clean --> cleans up the '${build.dir}' directory"/>
<echo message=" release --> build a release version under '${dist.dir}'"/>
<echo message=" docs --> builds the compiled documentation in '${dist.dir}'"/>
<echo message=" cleanrel --> cleans up the '${dist.dir}' directory"/>
<echo message=" usage --> show this message (default)"/>
<echo message=""/>
<echo message=" See comments in '${project.FileName}.build' file for more details."/>
<echo message="-------------------------------------------------------------"/>
</target>
<target name="build" depends="init" description="makes a debug build, usage: 'nant clean build'">
<property name="debug" value="true"/>
<property name="compile.dir" value="${build.dir}"/>
<property name="astframe.compile.dir" value="${astframe.build.dir}"/>
<property name="dist.name" value="${project.name}-src-${project.version}.zip"/>
<echo message="Building ${project.name}-${project.version} (debug)"/>
<call target="compile"/>
</target>
<target name="release" depends="init" description="makes a release build, usage: 'nant clean release'">
<property name="debug" value="false"/>
<property name="compile.dir" value="${dist.dir}"/>
<property name="astframe.compile.dir" value="${dist.dir}"/>
<property name="dist.name" value="${project.name}-src-${project.version}.zip"/>
<echo message="Building ${project.name}-${project.version} (release)"/>
<call target="compile"/>
</target>
<target name="clean" depends="init" description="cleans up 'build' directory">
<delete dir="${build.dir}" failonerror="false"/>
</target>
<target name="cleanrel" depends="init" description="cleans up 'release' directory">
<delete dir="${dist.dir}" failonerror="false"/>
</target>
<target name="compile" depends="init" description="compiles the source code">
<mkdir dir="${compile.dir}"/>
<mkdir dir="${astframe.compile.dir}"/>
<!-- compile antlr.runtime.dll -->
<csc target="library" output="${compile.dir}/${project.FileName}.dll" debug="${debug}" doc="${build.dir}/${project.FileName}.xml">
<sources basedir="${src.dir}">
<include name="**/*.cs"/>
<exclude name="NAnt.cs"/>
</sources>
<references>
<include name="System.dll" />
</references>
<arg value="/nowarn:1591"/>
</csc>
<!-- copy the antlr.runtime assembly to the astframe build folder -->
<copy file="${compile.dir}\${project.FileName}.dll" tofile="${astframe.compile.dir}\${project.FileName}.dll" />
<!-- compile antlr.astframe.dll -->
<csc target="library" output="${astframe.compile.dir}/${astframe.FileName}.dll" debug="${debug}" doc="${astframe.build.dir}/${astframe.FileName}.xml">
<sources basedir="${astframe.src.dir}">
<include name="**/*.cs"/>
<exclude name="NAnt.cs"/>
</sources>
<references>
<include name="System.dll" />
<include name="System.Drawing.dll" />
<include name="System.Windows.Forms.dll" />
<include name="${astframe.compile.dir}\${project.FileName}.dll" />
</references>
<arg value="/nowarn:1591"/>
</csc>
</target>
<target name="docs" depends="build" description="build documentation">
<echo message="Requires HtmlHelp compiler (hhc.exe) to be in the system path"/>
<ndoc failonerror="false">
<assemblies basedir="${build.dir}">
<include name="${project.FileName}.dll"/>
</assemblies>
<documenters>
<documenter name="MSDN">
<property name="OutputDirectory" value="${build.dir}/docs/MSDN" />
<property name="HtmlHelpName" value="${project.FileName}" />
<property name="HtmlHelpCompilerFilename" value="hhc.exe" />
<property name="IncludeFavorites" value="False" />
<property name="Title" value="ANTLR Runtime for .NET" />
<property name="SplitTOCs" value="False" />
<property name="DefaulTOC" value="" />
<property name="ShowVisualBasic" value="True" />
<property name="ShowMissingSummaries" value="True" />
<property name="ShowMissingRemarks" value="True" />
<property name="ShowMissingParams" value="True" />
<property name="ShowMissingReturns" value="True" />
<property name="ShowMissingValues" value="True" />
<property name="DocumentInternals" value="False" />
<property name="DocumentProtected" value="True" />
<property name="DocumentPrivates" value="False" />
<property name="DocumentEmptyNamespaces" value="False" />
<property name="IncludeAssemblyVersion" value="False" />
<property name="CopyrightText" value="" />
<property name="CopyrightHref" value="" />
</documenter>
</documenters>
</ndoc>
<copy file="${build.dir}/docs/MSDN/${project.FileName}.chm" todir="${dist.dir}"/>
<!-- <delete dir="${build.dir}/docs/MSDN" failonerror="false"/> -->
</target>
<target name="backup" depends="init" description="make local backup">
<echo message="Creating backup ${backup.name}"/>
<zip zipfile="${backup.name}">
<fileset basedir=".">
<include name="**"/>
<exclude name="**/*.suo"/>
<exclude name="**/*.csproj.user"/>
<exclude name="bin/**"/>
<exclude name="obj/**"/>
<exclude name="build/**"/>
</fileset>
</zip>
</target>
</project>
|