Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HiveHiveEngine/HeuristicLab.ExtLibs/HeuristicLab.ProtobufCS/0.9.1/ProtobufCS/ProtocolBuffers.build @ 9844

Last change on this file since 9844 was 3857, checked in by abeham, 15 years ago

#866

  • Added protobuf-csharp-port project source to ExtLibs
File size: 13.3 KB
Line 
1<?xml version="1.0"?>
2<project name="Protocol Buffers" default="build" basedir=".">
3  <description>Port of Google's Protocol Buffers to C#/.NET</description>
4
5  <!-- NAntContrib configuration. TODO(jonskeet): Improve this? -->
6  <property name="nantcontrib-dir"
7            value="${path::combine(nant::get-base-directory(), '../../NAntContrib')}"
8            overwrite="false" />
9
10  <loadtasks assembly="${path::combine(nantcontrib-dir, 'bin/NAnt.Contrib.Tasks.dll')}" /> 
11 
12  <property name="build-configuration"
13            value="Debug"
14            overwrite="false" />
15 
16  <property name="src"
17            value="${project::get-base-directory()}/src" />
18
19 
20  <property name="tools-protoc"
21            value="${project::get-base-directory()}/lib/protoc.exe"
22            overwrite="false" />
23
24  <!-- Output directory for copying generated binaries -->
25  <property name="output-dir"
26            value="${path::combine(project::get-base-directory(), 'dist')}"
27            overwrite="false" />           
28
29  <!-- Directory to find test data -->
30  <property name="testdata-dir"
31            value="${path::combine(project::get-base-directory(), 'testdata')}"
32            overwrite="false" />
33           
34  <!-- Base directory to find protos (core, C# options, tests) -->
35  <property name="protos-dir"
36            value="${path::combine(project::get-base-directory(), 'protos')}"
37            overwrite="false" />
38 
39  <!-- Scratch directory used when generating code -->
40  <property name="tmp-dir"
41            value="${path::combine(project::get-base-directory(), 'tmp')}"
42            overwrite="false" />
43
44  <!-- Directory to build and run benchmarks in -->
45  <property name="benchmark-run-dir"
46            value="${path::combine(tmp-dir, 'benchmark')}"
47            overwrite="false" />
48   
49  <!-- Directory to find benchmark data in -->
50  <property name="benchmark-data-dir"
51            value="${path::combine(project::get-base-directory(), 'benchmarks')}"
52            overwrite="false" />
53
54  <!-- Which version of protogen to use when regenerating source -->
55  <property name="tools-protogen-config"
56            value="${build-configuration}"
57            overwrite="false" />
58 
59  <property name="tools-protogen"
60            value="${src}/ProtoGen/bin/${tools-protogen-config}/protogen.exe"
61            overwrite="false"/>
62
63  <target name="clean-build"
64          description="Rebuilds all source and binaries, including distribution">
65
66  <!--
67    - Use call instead of dependencies to make it clear what's going on: we
68    - need to call some targets multiple times.
69    -->
70    <call target="clean" />
71    <call target="build" />
72    <call target="generate-source" />
73    <call target="copy-generated-source" />
74    <!-- Now we've got fresh source, build again -->
75    <call target="clean" />
76    <call target="build" />
77    <!--
78      - In particularly insane situations we should possibly do another
79      - round of generating source and building, but it gets silly.
80      -->
81   
82    <call target="test" />
83    <call target="dist" />
84  </target>
85 
86  <target name="clean-build-all"
87          description="Rebuilds all source and binaries in all configurations, including distribution">
88
89  <!--
90    - Use call instead of dependencies to make it clear what's going on: we
91    - need to call some targets multiple times.
92    -->
93    <call target="clean" />
94    <call target="build" />
95    <call target="generate-source" />
96    <call target="copy-generated-source" />
97    <!-- Now we've got fresh source, build again -->
98    <call target="clean" />
99    <call target="build-all-configs" />
100    <!--
101      - In particularly insane situations we should possibly do another
102      - round of generating source and building, but it gets silly.
103      -->
104   
105    <call target="test" />
106    <call target="dist" />
107  </target>
108
109  <target name="clean"
110          description="Removes built binaries (of all configurations) and the source generation directory">
111    <delete>
112      <fileset>
113        <include name="${src}/ProtoGen/bin/**" />
114        <include name="${src}/ProtoGen/obj/**" />
115        <include name="${src}/ProtoGen.Test/bin/**" />
116        <include name="${src}/ProtoGen.Test/obj/**" />
117        <include name="${src}/ProtocolBuffers/bin/**" />
118        <include name="${src}/ProtocolBuffers/obj/**" />
119        <include name="${src}/ProtocolBuffers.Test/bin/**" />
120        <include name="${src}/ProtocolBuffers.Test/obj/**" />
121        <include name="${tmp-dir}" />
122        <include name="${output-dir}" />
123      </fileset>
124    </delete>
125  </target>
126 
127  <target name="generate-source"
128          description="Generate source (unit tests, core messages etc). Does not copy source.">
129    <fail message="protoc and protogen must both exist"
130          unless="${file::exists(tools-protoc) and file::exists(tools-protogen)}" />
131    <delete dir="${tmp-dir}" />
132    <mkdir dir="${tmp-dir}" />
133    <exec program="${tools-protoc}"
134          workingdir="${tmp-dir}">
135      <arg value="--proto_path=${protos-dir}" />
136      <arg value="--descriptor_set_out=compiled.pb" />
137      <arg file="${protos-dir}/google/protobuf/descriptor.proto" />
138      <arg file="${protos-dir}/google/protobuf/csharp_options.proto" />
139      <arg file="${protos-dir}/google/protobuf/unittest.proto" />
140      <arg file="${protos-dir}/google/protobuf/unittest_csharp_options.proto" />
141      <arg file="${protos-dir}/google/protobuf/unittest_custom_options.proto" />
142      <arg file="${protos-dir}/google/protobuf/unittest_embed_optimize_for.proto" />
143      <arg file="${protos-dir}/google/protobuf/unittest_import.proto" />
144      <arg file="${protos-dir}/google/protobuf/unittest_mset.proto" />
145      <arg file="${protos-dir}/google/protobuf/unittest_optimize_for.proto" />
146      <arg file="${protos-dir}/tutorial/addressbook.proto" />
147    </exec>
148   
149    <exec program="${tools-protogen}"
150          workingdir="${tmp-dir}">
151      <arg value="compiled.pb" />
152    </exec>   
153  </target>
154 
155  <target name="copy-generated-source"
156          description="Copies generated source from temporary directory to source tree. Use with care!">
157    <copy todir="${src}/ProtocolBuffers/DescriptorProtos">
158      <fileset basedir="${tmp-dir}">
159        <include name="DescriptorProtoFile.cs" />
160        <include name="CSharpOptions.cs" />
161      </fileset>
162    </copy>
163
164    <copy todir="${src}/ProtocolBuffers.Test/TestProtos">
165      <fileset basedir="${tmp-dir}">
166        <include name="UnitTestProtoFile.cs" />
167        <include name="UnitTestCSharpOptionsProtoFile.cs" />
168        <include name="UnitTestCustomOptionsProtoFile.cs" />
169        <include name="UnitTestEmbedOptimizeForProtoFile.cs" />
170        <include name="UnitTestImportProtoFile.cs" />
171        <include name="UnitTestMessageSetProtoFile.cs" />
172        <include name="UnitTestOptimizeForProtoFile.cs" />
173      </fileset>
174    </copy>
175   
176    <copy todir="${src}/AddressBook">
177      <fileset basedir="${tmp-dir}">
178        <include name="AddressBookProtos.cs" />
179      </fileset>
180    </copy>
181  </target>
182
183  <target name="build"
184          description="Builds all C# code">
185    <msbuild project="${src}/ProtocolBuffers.sln">
186      <property name="Configuration"
187                value="${build-configuration}" />
188      <property name="Platform" value="Any CPU" />
189    </msbuild>
190  </target>
191 
192  <target name="benchmark" description="Builds and runs benchmarks">
193 
194    <delete dir="${benchmark-run-dir}" />
195    <mkdir dir="${benchmark-run-dir}" />
196
197    <!-- Generate benchmark source files -->
198    <exec program="${tools-protoc}"
199          workingdir="${benchmark-run-dir}">
200      <arg value="--proto_path=${benchmark-data-dir};${protos-dir}" />
201      <arg value="--include_imports=compiled.pb" /> 
202      <arg value="--descriptor_set_out=compiled.pb" /> 
203      <arg file="${benchmark-data-dir}/google_size.proto" />
204      <arg file="${benchmark-data-dir}/google_speed.proto" />
205    </exec>
206   
207    <exec program="${tools-protogen}"
208          workingdir="${benchmark-run-dir}">
209      <arg value="compiled.pb" />
210    </exec>   
211
212    <!-- Build them into a library -->
213    <csc target="library"
214         output="${benchmark-run-dir}/BenchmarkTypes.dll"
215         optimize="true">
216       <sources>
217         <include name="${benchmark-run-dir}/GoogleSizeProtoFile.cs" />
218         <include name="${benchmark-run-dir}/GoogleSpeedProtoFile.cs" />
219       </sources>
220       <references>
221         <include name="${src}/ProtocolBuffers/bin/${build-configuration}/Google.ProtocolBuffers.dll" />
222       </references>
223    </csc>
224   
225    <!-- Copy everything we need into the same directory -->
226    <copy todir="${benchmark-run-dir}" flatten="true">
227      <fileset>
228        <include name="${src}/ProtocolBuffers/bin/${build-configuration}/Google.ProtocolBuffers.dll" />
229        <include name="${src}/ProtoBench/bin/${build-configuration}/ProtoBench.exe" />
230        <include name="${benchmark-data-dir}/google_message1.dat" />
231        <include name="${benchmark-data-dir}/google_message2.dat" />
232      </fileset>
233    </copy>
234
235    <!-- Run! -->
236    <exec program="${benchmark-run-dir}/ProtoBench.exe"
237          workingdir="${benchmark-run-dir}"
238          output="${benchmark-run-dir}/results.txt">
239      <arg value="Google.ProtocolBuffers.ProtoBench.SizeMessage1,BenchmarkTypes" />
240      <arg value="google_message1.dat" />
241      <arg value="Google.ProtocolBuffers.ProtoBench.SpeedMessage1,BenchmarkTypes" />
242      <arg value="google_message1.dat" />
243      <arg value="Google.ProtocolBuffers.ProtoBench.SizeMessage2,BenchmarkTypes" />
244      <arg value="google_message2.dat" />
245      <arg value="Google.ProtocolBuffers.ProtoBench.SpeedMessage2,BenchmarkTypes" />
246      <arg value="google_message2.dat" />
247    </exec>   
248  </target>
249 
250  <target name="test"
251          description="Runs all unit tests">
252    <nunit2>
253      <formatter type="Plain" />
254      <test assemblyname="${src}/ProtocolBuffers.Test/bin/${build-configuration}/Google.ProtocolBuffers.Test.dll" />
255      <test assemblyname="${src}/Protogen.Test/bin/${build-configuration}/Google.ProtocolBuffers.ProtoGen.Test.dll" />
256    </nunit2>
257  </target>
258 
259  <target name="build-all-configs"
260          description="Builds all versions of the main library">
261    <msbuild project="${src}/ProtocolBuffers.sln">
262      <property name="Configuration" value="Debug" />
263      <property name="Platform" value="Any CPU" />
264    </msbuild>
265    <msbuild project="${src}/ProtocolBuffers.sln">
266      <property name="Configuration" value="Release" />
267      <property name="Platform" value="Any CPU" />
268    </msbuild>
269    <msbuild project="${src}/ProtocolBuffers.sln">
270      <property name="Configuration" value="Silverlight2" />
271      <property name="Platform" value="Any CPU" />
272    </msbuild>
273    <!-- Note the deliberate lack of space in the platform name -->
274    <msbuild project="${src}/ProtocolBuffers/ProtocolBuffersCF.csproj">
275      <property name="Configuration" value="Release" />
276      <property name="Platform" value="AnyCPU" />
277    </msbuild>
278  </target>
279   
280 
281  <target name="dist"
282          description="Copies all binaries into the output directory">
283    <delete dir="${output-dir}" />
284    <copy todir="${output-dir}">
285      <fileset basedir="${project::get-base-directory()}">
286        <include name="readme.txt" />
287        <include name="license.txt" />
288      </fileset>
289    </copy>
290    <mkdir dir="${output-dir}" />
291    <mkdir dir="${output-dir}/Protoc" />
292    <mkdir dir="${output-dir}/Debug" />
293    <mkdir dir="${output-dir}/Release" />
294    <mkdir dir="${output-dir}/Silverlight2" />
295    <mkdir dir="${output-dir}/CompactFramework35" />
296    <copy todir="${output-dir}/Protoc">
297      <fileset basedir="${project::get-base-directory()}/lib">
298        <include name="protoc.exe" />
299        <include name="protoc-license.txt" />
300      </fileset>
301    </copy>
302    <copy todir="${output-dir}/Debug"
303          flatten="true">
304      <fileset basedir="${src}">
305        <include name="ProtocolBuffers/bin/Debug/Google.ProtocolBuffers.*" />
306        <include name="ProtoGen/bin/Debug/ProtoGen.*" />
307        <include name="ProtoMunge/bin/Debug/ProtoMunge.*" />
308        <include name="ProtoDump/bin/Debug/ProtoDump.*" />
309        <include name="ProtoBench/bin/Debug/ProtoBench.*" />
310        <exclude name="**/*vshost*" />
311      </fileset>
312    </copy>   
313    <copy todir="${output-dir}/Release"
314          flatten="true">
315      <fileset basedir="${src}">
316        <include name="ProtocolBuffers/bin/Release/Google.ProtocolBuffers.*" />
317        <include name="ProtoGen/bin/Release/ProtoGen.*" />
318        <include name="ProtoMunge/bin/Release/ProtoMunge.*" />
319        <include name="ProtoDump/bin/Release/ProtoDump.*" />
320        <include name="ProtoBench/bin/Release/ProtoBench.*" />
321        <exclude name="**/*vshost*" />
322      </fileset>
323    </copy>   
324    <copy todir="${output-dir}/Silverlight2"
325          flatten="true">
326      <fileset basedir="${src}">
327        <include name="ProtocolBuffers/bin/Silverlight2/Google.ProtocolBuffers.dll" />
328      </fileset>
329    </copy>   
330    <copy todir="${output-dir}/CompactFramework35"
331          flatten="true">
332      <fileset basedir="${src}">
333        <include name="ProtocolBuffers/bin/ReleaseCF/Google.ProtocolBuffers.dll" />
334      </fileset>
335    </copy>   
336  </target>
337 
338 
339</project>
Note: See TracBrowser for help on using the repository browser.