aboutsummaryrefslogtreecommitdiff
path: root/ProtocolBuffers.build
blob: a64f26481ac6dc706edddee40b6f42c63cc7637f (plain) (blame)
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
<?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" />
  
  <!-- 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" />
  
  <!-- Which version of protogen to use when regenerating source -->
  <property name="tools-protogen-config"
            value="Debug"
            overwrite="false" />
  
  <property name="tools-protogen" 
            value="${src}/ProtoGen/bin/${tools-protogen-config}/protogen.exe" 
            overwrite="false"/>
  
  <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}" />
      </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_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" />
    </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="UnitTestProtoFile.cs" />
        <include name="UnitTestCustomOptionsProtoFile.cs" />
        <include name="UnitTestEmbedOptimizeForProtoFile.cs" />
        <include name="UnitTestImportProtoFile.cs" />
        <include name="UnitTestMessageSetProtoFile.cs" />
        <include name="UnitTestOptimizeForProtoFile.cs" />
      </fileset>
    </copy>
  </target>
      
  <target name="build" description="Builds all C# code">
    <msbuild project="${src}/ProtocolBuffers.sln">
      <property name="Configuration"
                value="${build-configuration}" />
    </msbuild>
  </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}/Protogen.Test/bin/${build-configuration}/Google.ProtocolBuffers.ProtoGen.Test.dll" />
    </nunit2>
  </target>
  
  <target name="perf-test" description="Runs all performance tests">
    <fail message="Performance tests not implemented yet" />
  </target>
  
  
</project>