Update README.txt
[GitSharp.git] / GitSharp.build
blob5ae3d9fdde5785ed00ac78cd9f6b4e08c10fbd15
1 <?xml version="1.0"?>
2 <project name="GitSharp" default="run-tests">
4   <property name="build.config" value="debug" overwrite="false" />
5   <property name="build.platform" value="${nant.settings.currentframework}" />
6   <property name="build.defines" value="TRACE;LINQ;DEBUG" />
8   <property name="build.runs.on.mono" value="${(framework::get-family(framework::get-runtime-framework()) == 'mono')}" />
9   
10   <property name="path.base" value="${project::get-base-directory()}"/>
11   <property name="path.build" value="${path.base}/build"/>
12   <property name="path.lib" value="${path.base}/lib"/>
13   <property name="path.dist" value="${path.base}/dist"/>
14   <property name="path.tools" value="${path.base}/tools"/>
15   <property name="path.tools.nunit" value="${path.tools}/nunit"/>
17   <!-- Revision version detection. If build.vcs.number hasn't been passed through command line argument, version revision is set to 'local-build' -->
18   <property name="build.vcs.number.1" value="" overwrite="false"/>
19   <property name="version.revision" value="local-build" />
21   <if test="${(string::get-length(build.vcs.number.1) != 0)}">
22     <property name="version.revision" value="${build.vcs.number.1}" />
23   </if>
25   <property name="version.major" value="${version::get-major(version::parse(version))}" dynamic="true"/>
26   <property name="version.minor" value="${version::get-minor(version::parse(version))}" dynamic="true"/>
27   <property name="version.build" value="${version::get-build(version::parse(version))}" dynamic="true"/>
28   <property name="build.version" value="${version.major}.${version.minor}.${version.build}.${version.revision}" dynamic="true"/>
30   <target name="rebuild" depends="clean, run-tests"/>
32   <target name="clean">
33     <delete dir="${path.build}" if="${directory::exists(path.build)}"/>
34     <delete dir="${path.dist}" if="${directory::exists(path.dist)}"/>
35   </target>
37   <target name="dist" depends="run-tests, package"/>
39   <!-- ********************************************** -->
40   <!-- GitSharp.Core.dll -->
41   <!-- ********************************************** -->
42   <target name="compile-core" depends="init">
43     <property name="assembly.name" value="GitSharp.Core" />
44     <property name="assembly.type" value="library" />
45     <property name="project.directory" value="${assembly.name}" />
47     <property name="assembly.namespace" value="${assembly.name}" />
48     
49     <fileset id="project.references" >
50       <include name="System.dll" />
51       <include name="System.Core.dll" />
52       <include name="System.Xml.dll" />
53       <include name="${path.lib}/ICSharpCode.SharpZipLib.dll" />
54       <include name="${path.lib}/Winterdom.IO.FileMap.dll" />
55       <include name="${path.lib}/Tamir.SharpSSH.dll" />
56     </fileset>
58     <call target="compile-dll" />
59   </target>
61   <!-- ********************************************** -->
62   <!-- git.exe -->
63   <!-- ********************************************** -->
64   <target name="compile-cli" depends="compile-gitsharp">
65     <property name="assembly.name" value="GitSharp.Git" />
66     <property name="assembly.type" value="exe" />
67     <property name="project.directory" value="Git" />
69     <property name="assembly.namespace" value="GitSharp.CLI" />
70     
71     <fileset id="project.references" basedir="${path.build.output}" >
72       <include name="GitSharp.dll" />
73       <include name="GitSharp.Core.dll" />
74     </fileset>
76     <copy todir="${path.build.output}">
77       <fileset basedir="${path.base}/Git">
78         <include name="Commands.xml" />
79       </fileset>
80     </copy>
82     <call target="compile-dll" />
83   </target>
85   <!-- ********************************************** -->
86   <!-- GitSharp.dll -->
87   <!-- ********************************************** -->
88   <target name="compile-gitsharp" depends="compile-core">
89     <property name="assembly.name" value="GitSharp" />
90     <property name="assembly.type" value="library" />
91     <property name="project.directory" value="${assembly.name}" />
93     <property name="assembly.namespace" value="${assembly.name}" />
95     <fileset id="project.references" basedir="${path.build.output}" >
96       <include name="System.dll" />
97       <include name="System.Core.dll" />
98       <include name="GitSharp.Core.dll" />
99       <include name="${path.lib}/Tamir.SharpSSH.dll" />
100     </fileset>
102     <call target="compile-dll" />
103   </target>
105   <!-- ********************************************** -->
106   <!-- GitSharp.Tests.dll -->
107   <!-- ********************************************** -->
108   <target name="compile-tests" depends="compile-cli">
109     <property name="assembly.name" value="GitSharp.Tests" />
110     <property name="assembly.type" value="library" />
111     <property name="project.directory" value="${assembly.name}" />
113     <property name="assembly.namespace" value="${assembly.name}" />
115     <fileset id="project.references" >
116       <include name="${path.build.output}/GitSharp.dll" />
117       <include name="${path.build.output}/GitSharp.Core.dll" />
118       <include name="${path.build.output}/GitSharp.Git.exe" />
119       <include name="${path.tools.nunit}/nunit.framework.dll" />
120     </fileset>
122     <call target="compile-dll" />
123   </target>
125   <!-- ********************************************** -->
126   <!-- run tests -->
127   <!-- ********************************************** -->
128   <target name="run-tests"  depends="compile-tests">
129     <property name="path.testresults" value="${path.build}/${build.platform}-${build.config}/test-results" />
131     <mkdir dir="${path.testresults}" if="${not(directory::exists(path.testresults))}"/>
132     <echo message="path.testresults = ${path.testresults}"/>
134     <copy todir="${path.testresults}">
135       <fileset basedir="${path.base}/GitSharp.Tests/Resources">
136         <include name="${path.build.output}/*.dll" />
137         <include name="${path.build.output}/GitSharp.Git.exe" />
138       </fileset>
139     </copy>
141     <copy todir="${path.testresults}/Resources">
142       <fileset basedir="${path.base}/GitSharp.Tests/Resources">
143         <include name="**" />
144       </fileset>
145     </copy>
147     <property name="nunit.consolerunner" value="${path.tools.nunit}/nunit-console.exe" />
148     <property name="nunit.commandline" value="GitSharp.Tests.dll /xml:GitSharp.Tests.dll-results.xml /noshadow " />
149     <if test="${build.runs.on.mono}">
150       <property name="nunit.consolerunner" value="nunit-console2" />
151       <property name="nunit.commandline" value="GitSharp.Tests.dll -xml:GitSharp.Tests.dll-results.xml -noshadow " />
152     </if>
154     <exec verbose="true"
155       program="${nunit.consolerunner}"
156       workingdir="${path.testresults}"
157       commandline="${nunit.commandline}"
158       failonerror="true"
159                         />
162     <property name="debugger.file.path.before" value="${path.build.output}/GitSharp.Git.pdb" />
163     <property name="debugger.file.path.after" value="${path.build.output}/Git.pdb"  />
165     <property name="debugger.file.path.before" value="${path.build.output}/GitSharp.Git.exe.mdb" if="${build.runs.on.mono}" />
166     <property name="debugger.file.path.after" value="${path.build.output}/Git.exe.mdb" if="${build.runs.on.mono}" />
169     <move file="${path.build.output}/GitSharp.Git.exe" tofile="${path.build.output}/Git.exe" />
170     <move file="${debugger.file.path.before}" tofile="${debugger.file.path.after}" />
171     <move file="${path.build.output}/GitSharp.Git.xml" tofile="${path.build.output}/Git.xml" />
172   </target>
174   <target name="init">
175     <loadfile file="version.txt" property="version" />
177     <mkdir dir="${path.build}" if="${not(directory::exists(path.build))}"/>
179     <property name="path.build.output" value="${path.build}/${build.platform}-${build.config}/bin"/>
181     <echo message="build.version = ${build.version}"/>
182     <echo message="path.build.output = ${path.build.output}"/>
184     <mkdir dir="${path.build.output}" if="${not(directory::exists(path.build.output))}"/>
186     <call target="set-${build.config}-project-configuration" />
187   </target>
189   <target name="package">
190     <mkdir dir="${path.dist}" if="${not(directory::exists(path.dist))}"/>
192     <copy todir="${path.build.output}">
193       <fileset>
194         <include name="${path.base}/*.txt" />
195         <exclude name="${path.base}/version.txt" />
196       </fileset>
197     </copy>
198     
199     <zip zipfile="${path.dist}/GitSharp-${build.version}-${build.config}-${build.platform}.zip" ziplevel="9">
200       <fileset basedir="${path.build.output}">
201         <include name="*.*"/>
202       </fileset>
203     </zip>
204   </target>
206   <target name="set-debug-project-configuration" >
207     <property name="build.optimize"     value="false" />
208   </target>
210   <target name="set-release-project-configuration" >
211     <property name="build.optimize"     value="true" />
212     <property name="build.defines" value="LINQ;TRACE" />
213   </target>
215   <target name="compile-dll">
216     <call target="copy-references"/>
218     <property name="project.sources.path" value="${path.base}/${project.directory}"/>
220     <call target="create-assembly-info"/>
222     <fileset id="project.sources" failonempty="true">
223       <include name="${project.sources.path}/**/*.cs" />
224     </fileset>
226     <property name="assembly.extension" value="dll" />
227     <property name="assembly.extension" value="exe" if="${assembly.type == 'exe'}" />
229     <csc target="${assembly.type}"
230          debug="Full"
231          define="${build.defines}"
232          optimize="${build.optimize}"
233          output="${path.build.output}/${assembly.name}.${assembly.extension}"
234          doc="${path.build.output}/${assembly.name}.xml" >
235       <sources refid="project.sources" />
236       <references refid="project.references" />
237       <resources prefix="${assembly.namespace}.Resources.">
238         <include name="${project.sources.path}/Resources/*.*"/>
239       </resources>
240       <nowarn>
241         <!-- No warning when public members lack XML comments -->
242         <warning number="1591" />
243       </nowarn>
244     </csc>
246     <call target="cleanup-assembly-info"/>
247   </target>
249   <target name="cleanup-assembly-info">
250     <delete file="${project.sources.path}/SharedAssemblyInfo.cs" />
251     <delete file="${project.sources.path}/VersionAssemblyInfo.cs" />
252   </target>
254   <target name="create-assembly-info">
255     <copy todir="${project.sources.path}">
256       <fileset>
257         <include name="${path.base}/SharedAssemblyInfo.cs" />
258       </fileset>
259     </copy>
261     <asminfo output="${project.sources.path}/VersionAssemblyInfo.cs" language="CSharp">
262       <imports>
263         <import namespace="System"/>
264         <import namespace="System.Reflection"/>
265         <import namespace="System.Runtime.InteropServices"/>
266       </imports>
267       <attributes>
268         <attribute type="AssemblyVersionAttribute" value="${version}"/>
269         <attribute type="AssemblyProductAttribute" value="GitSharp [${version.revision}]"/>
270       </attributes>
271     </asminfo>
272   </target>
274   <target name="copy-references">
275     <foreach item="File" property="reference">
276       <in>
277         <items refid="project.references" />
278       </in>
279       <do>
280         <echo message="reference = ${reference}"/>
281         <copy file="${reference}" todir="${path.build.output}" />
282       </do>
283     </foreach>
284   </target>
286 </project>