summaryrefslogtreecommitdiff
path: root/qpid/dotnet/default.build
blob: f719d82c80156f6834f3b6ef894d6ccf736910d2 (plain)
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<?xml version="1.0"?>
<project name="Qpid.NET" default="build">

    <!-- Determines the formatter to use to format output of test results. -->
    <property name="nant.formatter" value="Plain" />

    <!-- Determines whether a 'debug' or 'release' build is to be done. Defaults to 'debug' -->
    <property name="build.config" value="debug" />

    <!-- Sets build properties consistently accross all assemblies in the project. -->
    <property name="build.version.major" value="0"/>
    <property name="build.version.minor" value="3"/>
    <property name="build.version.build" value="0"/>
    <property name="build.version.revision" value="0"/>
    <property name="build.company" value="Apache Software Foundation"/>
    <property name="build.copyright" value="Apache Software Foundation"/>
    <property name="build.description" value="Built from svn revision number: "/>

    <!-- Fileset with build files for each 'core' assembly. -->
    <fileset id="src.builds">
        <include name="Qpid.Buffer/default.build" />
        <include name="Qpid.Sasl/default.build" />
        <include name="Qpid.Messaging/default.build" />
        <include name="Qpid.Codec/default.build" />
        <include name="Qpid.Common/default.build" />        
        <include name="Qpid.Client/default.build" />	
    </fileset>
    
    <!-- Fileset with build files for 'pure unit' test assemblies. -->
    <fileset id="tests.pure.builds">
        <include name="Qpid.Buffer.Tests/default.build" />
        <include name="Qpid.Sasl.Tests/default.build" />
        <include name="Qpid.Common.Tests/default.build" />        
        <include name="Qpid.Client.Tests/default.build" />	
    </fileset>

    <!-- Fileset with build files for 'integration' test assemblies. -->
    <fileset id="tests.integration.builds">
        <include name="Qpid.Integration.Tests/default.build" />	
    </fileset>

    <!-- Other test or utility assemblies. -->
    <fileset id='other.builds'>
        <include name="TopicListener/default.build" />	
        <include name="TopicPublisher/default.build" />	
        <include name="TestClient/default.build" />	
    </fileset>

    <!-- Prepare environment for a debug build. -->
    <target name="debug">
        <property name="build.debug" value="true" />
        <property name="build.defines" value="DEBUG;TRACE"/>
    </target>

    <!-- Prepare environment for a release build. -->
    <target name="release">
        <property name="build.debug" value="false" />
        <property name="build.defines" value=""/>
    </target>
    
    <!-- Prepare environment for build. -->
    <target name="init">
        <property name="base.dir" value="${project::get-base-directory()}" />
        <property name="build.dir" value="${base.dir}/bin/${framework::get-target-framework()}/${build.config}" />
        <call target="${build.config}" />	
    </target>   
    
    <!-- Cleans up the build output directory. -->
    <target name="clean" depends="init">
        <delete dir="${build.dir}" failonerror="false" />
    </target>

    <!-- Runs 'svnversion' to get the repository revision into the build property 'build.svnversion'. -->
    <target name="svnversion" description="Runs svnversion to get the current repository version into a build script property.">
        <exec program="svnversion" output="svnversion_tmp.txt">
            <arg value="-n"/>
        </exec>

        <loadfile file="svnversion_tmp.txt" property="build.svnversion"/>
        <delete file="svnversion_tmp.txt"/>       

        <!-- For some competely retarted reason the '-n' parameter to svnversion doesn't really work under windows... 
             Here is some code to strip the unwanted newlines. -->
        <script language="C#">
            <code><![CDATA[
            public static void ScriptMain(Project project)
            {
                project.Properties["build.svnversion"] = project.Properties["build.svnversion"].Trim("\n\r".ToCharArray());
            }
            ]]>
            </code>
        </script>

    </target>

    <!-- Performs a regex find-and-replace on assembly info files, substituting fields defined as build properties. -->
    <target name="setversion" description="Stamp the version info onto assemblyinfo.cs files" depends="svnversion">

        <echo>build.svnversion = ${build.svnversion}</echo>

        <foreach item="File" property="filename">
            <in>
                <items basedir=".">
                    <include name="**\AssemblyInfo.cs"></include>
                </items>
            </in>
            <do>
                <script language="C#">
                    <code><![CDATA[
                    public static void ScriptMain(Project project)
                    {
                        // Read in the entire file to perform the substitution in.
                        StreamReader reader = new StreamReader(project.Properties["filename"]);
                        string contents = reader.ReadToEnd();
                        reader.Close();

                        // Substitute the version numbers.
                        string replacement = string.Format("[assembly: AssemblyVersion(\"{0}.{1}.{2}.{3}\")]",
                                                           project.Properties["build.version.major"],
                                                           project.Properties["build.version.minor"],
                                                           project.Properties["build.version.build"],
                                                           project.Properties["build.version.revision"]);
                        contents = Regex.Replace(contents, @"\[assembly: AssemblyVersion\("".*""\)\]", replacement);

                        // Substitute the company name and copyright.
                        replacement = string.Format("[assembly: AssemblyCompany(\"{0}\")]",
                                                    project.Properties["build.company"]);
                        contents = Regex.Replace(contents, @"\[assembly: AssemblyCompany\("".*""\)\]", replacement);

                        replacement = string.Format("[assembly: AssemblyCopyright(\"{0}\")]",
                                                    project.Properties["build.copyright"]);
                        contents = Regex.Replace(contents, @"\[assembly: AssemblyCopyright\("".*""\)\]", replacement);

                        // Update the description.
                        //replacement = string.Format("[assembly: AssemblyDescription(\"{0} {1}\")]",
                        //                            project.Properties["build.description"],
                        //                            project.Properties["build.svnversion"]);
                        replacement = string.Format("[assembly: AssemblyDescription(\"{0}\")]",
                                                    project.Properties["build.description"]);
                        contents = Regex.Replace(contents, @"\[assembly: AssemblyDescription\("".*""\)\]", replacement);

                        // Write out the file with the substituted version.
                        StreamWriter writer = new StreamWriter(project.Properties["filename"], false);
                        writer.Write(contents);
                        writer.Close();
                    }
                    ]]>
                    </code>
                </script>
            </do>
        </foreach>
    </target>

    <!-- Do the build. -->
    <target name="build" depends="init, setversion">
        <echo message="Building all modules including tests."/>

        <!-- Make sure output folder exists. -->
        <mkdir dir="${build.dir}" />

        <!-- copy reference assemblies over to the output dir -->
        <copy todir="${build.dir}" file="Qpid.Common/lib/seclib-1.0.0/Org.Mentalis.Security.dll"/>
        <copy todir="${build.dir}" file="Qpid.Common/lib/log4net/log4net.dll"/>
        <copy todir="${build.dir}" file="Qpid.Client.Tests/lib/nunit/nunit.framework.dll"/>

        <!-- Compile assemblies. -->
        <nant target="build">
            <buildfiles refid="src.builds" />
        </nant>

        <!-- Compile test assemblies. -->
        <nant target="build">
            <buildfiles refid="tests.pure.builds" />
        </nant>
        <nant target="build">
            <buildfiles refid="tests.integration.builds" />
        </nant>

        <!-- Compile test assemblies. -->
        <nant target="build">
            <buildfiles refid="other.builds" />
        </nant>
    </target>
    
    <!-- Runs all 'pure unit' tests. -->
    <target name="test" depends="build">
        <echo message="Running all pure unit tests."/>
        <nant target="test">
            <buildfiles refid="tests.pure.builds" />
        </nant>
    </target>

    <!-- Runs all 'integration' tests. -->
    <target name="integrationtest" depends="build">
        <echo message="Running all integration tests."/>
        <nant target="test">
            <buildfiles refid="tests.integration.builds" />
        </nant>
    </target>

    <!-- Creates a release package. -->
    <target name="release-pkg">
        <echo message="Building and packaging a release."/>

        <call target="clean"/>
        <call target="build"/>

        <property name="build.date" value="${datetime::now()}"/>

        <zip zipfile="${build.dir}/Qpid.NET-${framework::get-target-framework()}-${datetime::get-year(build.date)}${datetime::get-month(build.date)}${datetime::get-day(build.date)}.zip">
            <fileset basedir="${build.dir}">
                <include name="**/*.*"/>
                <exclude name="**/*.Tests.*"/>
                <exclude name="**/nunit.framework.dll"/>
                <exclude name="**/*.exe"/>            
            </fileset>
            
            <fileset basedir="${base.dir}">
                <include name="LICENSE.txt"/>
                <include name="NOTICE.txt"/>
                <include name="README.txt"/>
                <include name="RELEASE_NOTES.txt"/>
                <include name="DISCLAIMER"/>                    
            </fileset>
        </zip>
    </target>
    
</project>