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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
|
<?xml version="1.0"?>
<project name="Protocol Buffers" default="build" basedir=".">
<description>Port of Google's Protocol Buffers to C#/.NET</description>
<!-- NAntContrib configuration. TODO(jonskeet): Improve this? -->
<property name="nantcontrib-dir"
value="${path::combine(nant::get-base-directory(), '../../NAntContrib')}"
overwrite="false" />
<loadtasks assembly="${path::combine(nantcontrib-dir, 'bin/NAnt.Contrib.Tasks.dll')}" />
<property name="build-configuration"
value="Debug"
overwrite="false" />
<property name="src"
value="${project::get-base-directory()}/src" />
<property name="tools-protoc"
value="${project::get-base-directory()}/lib/protoc.exe"
overwrite="false" />
<!-- Output directory for copying generated binaries -->
<property name="output-dir"
value="${path::combine(project::get-base-directory(), 'dist')}"
overwrite="false" />
<!-- Directory to find test data -->
<property name="testdata-dir"
value="${path::combine(project::get-base-directory(), 'testdata')}"
overwrite="false" />
<!-- Base directory to find protos (core, C# options, tests) -->
<property name="protos-dir"
value="${path::combine(project::get-base-directory(), 'protos')}"
overwrite="false" />
<!-- Scratch directory used when generating code -->
<property name="tmp-dir"
value="${path::combine(project::get-base-directory(), 'tmp')}"
overwrite="false" />
<!-- Directory to build and run benchmarks in -->
<property name="benchmark-run-dir"
value="${path::combine(tmp-dir, 'benchmark')}"
overwrite="false" />
<!-- Directory to find benchmark data in -->
<property name="benchmark-data-dir"
value="${path::combine(project::get-base-directory(), 'benchmarks')}"
overwrite="false" />
<!-- Which version of protogen to use when regenerating source -->
<property name="tools-protogen-config"
value="${build-configuration}"
overwrite="false" />
<property name="tools-protogen"
value="${src}/ProtoGen/bin/${tools-protogen-config}/protogen.exe"
overwrite="false"/>
<target name="clean-build"
description="Rebuilds all source and binaries, including distribution">
<!--
- Use call instead of dependencies to make it clear what's going on: we
- need to call some targets multiple times.
-->
<call target="clean" />
<call target="build" />
<call target="generate-source" />
<call target="copy-generated-source" />
<!-- Now we've got fresh source, build again -->
<call target="clean" />
<call target="build" />
<!--
- In particularly insane situations we should possibly do another
- round of generating source and building, but it gets silly.
-->
<call target="test" />
<call target="dist" />
</target>
<target name="clean-build-all"
description="Rebuilds all source and binaries in all configurations, including distribution">
<!--
- Use call instead of dependencies to make it clear what's going on: we
- need to call some targets multiple times.
-->
<call target="clean" />
<call target="build" />
<call target="generate-source" />
<call target="copy-generated-source" />
<!-- Now we've got fresh source, build again -->
<call target="clean" />
<call target="build-all-configs" />
<!--
- In particularly insane situations we should possibly do another
- round of generating source and building, but it gets silly.
-->
<call target="test" />
<call target="dist" />
</target>
<target name="clean"
description="Removes built binaries (of all configurations) and the source generation directory">
<delete>
<fileset>
<include name="${src}/ProtoGen/bin/**" />
<include name="${src}/ProtoGen/obj/**" />
<include name="${src}/ProtoGen.Test/bin/**" />
<include name="${src}/ProtoGen.Test/obj/**" />
<include name="${src}/ProtocolBuffers/bin/**" />
<include name="${src}/ProtocolBuffers/obj/**" />
<include name="${src}/ProtocolBuffers.Test/bin/**" />
<include name="${src}/ProtocolBuffers.Test/obj/**" />
<include name="${tmp-dir}" />
<include name="${output-dir}" />
</fileset>
</delete>
</target>
<target name="generate-source"
description="Generate source (unit tests, core messages etc). Does not copy source.">
<fail message="protoc and protogen must both exist"
unless="${file::exists(tools-protoc) and file::exists(tools-protogen)}" />
<delete dir="${tmp-dir}" />
<mkdir dir="${tmp-dir}" />
<exec program="${tools-protoc}"
workingdir="${tmp-dir}">
<arg value="--proto_path=${protos-dir}" />
<arg value="--descriptor_set_out=compiled.pb" />
<arg file="${protos-dir}/google/protobuf/descriptor.proto" />
<arg file="${protos-dir}/google/protobuf/csharp_options.proto" />
<arg file="${protos-dir}/google/protobuf/unittest.proto" />
<arg file="${protos-dir}/google/protobuf/unittest_csharp_options.proto" />
<arg file="${protos-dir}/google/protobuf/unittest_custom_options.proto" />
<arg file="${protos-dir}/google/protobuf/unittest_embed_optimize_for.proto" />
<arg file="${protos-dir}/google/protobuf/unittest_import.proto" />
<arg file="${protos-dir}/google/protobuf/unittest_mset.proto" />
<arg file="${protos-dir}/google/protobuf/unittest_optimize_for.proto" />
<arg file="${protos-dir}/google/protobuf/unittest_empty.proto" />
<arg file="${protos-dir}/google/protobuf/unittest_enormous_descriptor.proto" />
<arg file="${protos-dir}/google/protobuf/unittest_import_lite.proto" />
<arg file="${protos-dir}/google/protobuf/unittest_lite.proto" />
<arg file="${protos-dir}/google/protobuf/unittest_lite_imports_nonlite.proto" />
<arg file="${protos-dir}/google/protobuf/unittest_no_generic_services.proto" />
<arg file="${protos-dir}/extest/unittest_extras_full.proto" />
<arg file="${protos-dir}/extest/unittest_extras_lite.proto" />
<arg file="${protos-dir}/tutorial/addressbook.proto" />
</exec>
<exec program="${tools-protogen}"
workingdir="${tmp-dir}">
<arg value="compiled.pb" />
</exec>
</target>
<target name="copy-generated-source"
description="Copies generated source from temporary directory to source tree. Use with care!">
<copy todir="${src}/ProtocolBuffers/DescriptorProtos">
<fileset basedir="${tmp-dir}">
<include name="DescriptorProtoFile.cs" />
<include name="CSharpOptions.cs" />
</fileset>
</copy>
<copy todir="${src}/ProtocolBuffers.Test/TestProtos">
<fileset basedir="${tmp-dir}">
<include name="UnitTestCSharpOptionsProtoFile.cs" />
<include name="UnitTestCustomOptionsProtoFile.cs" />
<include name="UnitTestEmbedOptimizeForProtoFile.cs" />
<include name="UnitTestEmptyProtoFile.cs" />
<include name="UnitTestEnormousDescriptorProtoFile.cs" />
<include name="UnitTestImportProtoFile.cs" />
<include name="UnitTestMessageSetProtoFile.cs" />
<include name="UnitTestNoGenericServicesProtoFile.cs" />
<include name="UnitTestOptimizeForProtoFile.cs" />
<include name="UnitTestProtoFile.cs" />
</fileset>
</copy>
<copy todir="${src}/ProtocolBuffersLite.Test/TestProtos">
<fileset basedir="${tmp-dir}">
<include name="UnitTestExtrasFullProtoFile.cs" />
<include name="UnitTestExtrasLiteProtoFile.cs" />
<include name="UnitTestImportLiteProtoFile.cs" />
<include name="UnitTestImportProtoFile.cs" />
<include name="UnitTestLiteImportNonLiteProtoFile.cs" />
<include name="UnitTestLiteProtoFile.cs" />
<include name="UnitTestProtoFile.cs" />
</fileset>
</copy>
<copy todir="${src}/AddressBook">
<fileset basedir="${tmp-dir}">
<include name="AddressBookProtos.cs" />
</fileset>
</copy>
</target>
<target name="build"
description="Builds all C# code">
<msbuild project="${src}/ProtocolBuffers.sln">
<property name="Configuration"
value="${build-configuration}" />
<property name="Platform" value="Any CPU" />
</msbuild>
</target>
<target name="benchmark" description="Builds and runs benchmarks">
<delete dir="${benchmark-run-dir}" />
<mkdir dir="${benchmark-run-dir}" />
<!-- Generate benchmark source files -->
<exec program="${tools-protoc}"
workingdir="${benchmark-run-dir}">
<arg value="--proto_path=${benchmark-data-dir};${protos-dir}" />
<arg value="--include_imports=compiled.pb" />
<arg value="--descriptor_set_out=compiled.pb" />
<arg file="${benchmark-data-dir}/google_size.proto" />
<arg file="${benchmark-data-dir}/google_speed.proto" />
</exec>
<exec program="${tools-protogen}"
workingdir="${benchmark-run-dir}">
<arg value="compiled.pb" />
</exec>
<!-- Build them into a library -->
<csc target="library"
output="${benchmark-run-dir}/BenchmarkTypes.dll"
optimize="true">
<sources>
<include name="${benchmark-run-dir}/GoogleSizeProtoFile.cs" />
<include name="${benchmark-run-dir}/GoogleSpeedProtoFile.cs" />
</sources>
<references>
<include name="${src}/ProtocolBuffers/bin/${build-configuration}/Google.ProtocolBuffers.dll" />
</references>
</csc>
<!-- Copy everything we need into the same directory -->
<copy todir="${benchmark-run-dir}" flatten="true">
<fileset>
<include name="${src}/ProtocolBuffers/bin/${build-configuration}/Google.ProtocolBuffers.dll" />
<include name="${src}/ProtoBench/bin/${build-configuration}/ProtoBench.exe" />
<include name="${benchmark-data-dir}/google_message1.dat" />
<include name="${benchmark-data-dir}/google_message2.dat" />
</fileset>
</copy>
<!-- Run! -->
<exec program="${benchmark-run-dir}/ProtoBench.exe"
workingdir="${benchmark-run-dir}"
output="${benchmark-run-dir}/results.txt">
<arg value="Google.ProtocolBuffers.ProtoBench.SizeMessage1,BenchmarkTypes" />
<arg value="google_message1.dat" />
<arg value="Google.ProtocolBuffers.ProtoBench.SpeedMessage1,BenchmarkTypes" />
<arg value="google_message1.dat" />
<arg value="Google.ProtocolBuffers.ProtoBench.SizeMessage2,BenchmarkTypes" />
<arg value="google_message2.dat" />
<arg value="Google.ProtocolBuffers.ProtoBench.SpeedMessage2,BenchmarkTypes" />
<arg value="google_message2.dat" />
</exec>
</target>
<target name="test"
description="Runs all unit tests">
<nunit2>
<formatter type="Plain" />
<test assemblyname="${src}/ProtocolBuffers.Test/bin/${build-configuration}/Google.ProtocolBuffers.Test.dll" />
<test assemblyname="${src}/ProtocolBuffersLite.Test/bin/${build-configuration}/Google.ProtocolBuffersLite.Test.dll" />
<test assemblyname="${src}/ProtocolBuffersLite.Test/bin/${build-configuration}/Google.ProtocolBuffersMixedLite.Test.dll" />
<test assemblyname="${src}/Protogen.Test/bin/${build-configuration}/Google.ProtocolBuffers.ProtoGen.Test.dll" />
</nunit2>
</target>
<target name="build-all-configs"
description="Builds all versions of the main library">
<msbuild project="${src}/ProtocolBuffers.sln">
<property name="Configuration" value="Debug" />
<property name="Platform" value="Any CPU" />
</msbuild>
<msbuild project="${src}/ProtocolBuffers.sln">
<property name="Configuration" value="Release" />
<property name="Platform" value="Any CPU" />
</msbuild>
<msbuild project="${src}/ProtocolBuffers.sln">
<property name="Configuration" value="Silverlight2" />
<property name="Platform" value="Any CPU" />
</msbuild>
<!-- Note the deliberate lack of space in the platform name -->
<msbuild project="${src}/ProtocolBuffers/ProtocolBuffersCF.csproj">
<property name="Configuration" value="Release" />
<property name="Platform" value="AnyCPU" />
</msbuild>
</target>
<target name="dist"
description="Copies all binaries into the output directory">
<delete dir="${output-dir}" />
<copy todir="${output-dir}">
<fileset basedir="${project::get-base-directory()}">
<include name="readme.txt" />
<include name="license.txt" />
</fileset>
</copy>
<mkdir dir="${output-dir}" />
<mkdir dir="${output-dir}/Protoc" />
<mkdir dir="${output-dir}/Debug" />
<mkdir dir="${output-dir}/Release" />
<mkdir dir="${output-dir}/Silverlight2" />
<mkdir dir="${output-dir}/CompactFramework35" />
<copy todir="${output-dir}/Protoc">
<fileset basedir="${project::get-base-directory()}/lib">
<include name="protoc.exe" />
<include name="protoc-license.txt" />
</fileset>
</copy>
<copy todir="${output-dir}/Debug"
flatten="true">
<fileset basedir="${src}">
<include name="ProtocolBuffers/bin/Debug/Google.ProtocolBuffers.*" />
<include name="ProtoGen/bin/Debug/ProtoGen.*" />
<include name="ProtoMunge/bin/Debug/ProtoMunge.*" />
<include name="ProtoDump/bin/Debug/ProtoDump.*" />
<include name="ProtoBench/bin/Debug/ProtoBench.*" />
<exclude name="**/*vshost*" />
</fileset>
</copy>
<copy todir="${output-dir}/Release"
flatten="true">
<fileset basedir="${src}">
<include name="ProtocolBuffers/bin/Release/Google.ProtocolBuffers.*" />
<include name="ProtoGen/bin/Release/ProtoGen.*" />
<include name="ProtoMunge/bin/Release/ProtoMunge.*" />
<include name="ProtoDump/bin/Release/ProtoDump.*" />
<include name="ProtoBench/bin/Release/ProtoBench.*" />
<exclude name="**/*vshost*" />
</fileset>
</copy>
<copy todir="${output-dir}/Silverlight2"
flatten="true">
<fileset basedir="${src}">
<include name="ProtocolBuffers/bin/Silverlight2/Google.ProtocolBuffers.dll" />
</fileset>
</copy>
<copy todir="${output-dir}/CompactFramework35"
flatten="true">
<fileset basedir="${src}">
<include name="ProtocolBuffers/bin/ReleaseCF/Google.ProtocolBuffers.dll" />
</fileset>
</copy>
<copy todir="${output-dir}">
<fileset basedir="${project::get-base-directory()}">
<include name="protos/**" />
</fileset>
</copy>
</target>
</project>
|