|
| 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 | + <property name="tools-protoc" |
| 20 | + value="${project::get-base-directory()}/lib/protoc.exe" |
| 21 | + overwrite="false" /> |
| 22 | + |
| 23 | + <!-- Base directory to find protos (core, C# options, tests) --> |
| 24 | + <property name="protos-dir" |
| 25 | + value="${path::combine(project::get-base-directory(), 'protos')}" |
| 26 | + overwrite="false" /> |
| 27 | + |
| 28 | + <!-- Scratch directory used when generating code --> |
| 29 | + <property name="tmp-dir" |
| 30 | + value="${path::combine(project::get-base-directory(), 'tmp')}" |
| 31 | + overwrite="false" /> |
| 32 | + |
| 33 | + <!-- Which version of protogen to use when regenerating source --> |
| 34 | + <property name="tools-protogen-config" |
| 35 | + value="Debug" |
| 36 | + overwrite="false" /> |
| 37 | + |
| 38 | + <property name="tools-protogen" |
| 39 | + value="${src}/ProtoGen/bin/${tools-protogen-config}/protogen.exe" |
| 40 | + overwrite="false"/> |
| 41 | + |
| 42 | + <target name="clean" |
| 43 | + description="Removes built binaries (of all configurations) and the source generation directory"> |
| 44 | + <delete> |
| 45 | + <fileset> |
| 46 | + <include name="${src}/ProtoGen/bin/**" /> |
| 47 | + <include name="${src}/ProtoGen/obj/**" /> |
| 48 | + <include name="${src}/ProtoGen.Test/bin/**" /> |
| 49 | + <include name="${src}/ProtoGen.Test/obj/**" /> |
| 50 | + <include name="${src}/ProtocolBuffers/bin/**" /> |
| 51 | + <include name="${src}/ProtocolBuffers/obj/**" /> |
| 52 | + <include name="${src}/ProtocolBuffers.Test/bin/**" /> |
| 53 | + <include name="${src}/ProtocolBuffers.Test/obj/**" /> |
| 54 | + <include name="${tmp-dir}" /> |
| 55 | + </fileset> |
| 56 | + </delete> |
| 57 | + </target> |
| 58 | + |
| 59 | + <target name="generate-source" |
| 60 | + description="Generate source (unit tests, core messages etc). Does not copy source."> |
| 61 | + <fail message="protoc and protogen must both exist" |
| 62 | + unless="${file::exists(tools-protoc) and file::exists(tools-protogen)}" /> |
| 63 | + <delete dir="${tmp-dir}" /> |
| 64 | + <mkdir dir="${tmp-dir}" /> |
| 65 | + <exec program="${tools-protoc}" |
| 66 | + workingdir="${tmp-dir}"> |
| 67 | + <arg value="--proto_path=${protos-dir}" /> |
| 68 | + <arg value="--descriptor_set_out=compiled.pb" /> |
| 69 | + <arg file="${protos-dir}/google/protobuf/descriptor.proto" /> |
| 70 | + <arg file="${protos-dir}/google/protobuf/csharp_options.proto" /> |
| 71 | + <arg file="${protos-dir}/google/protobuf/unittest.proto" /> |
| 72 | + <arg file="${protos-dir}/google/protobuf/unittest_custom_options.proto" /> |
| 73 | + <arg file="${protos-dir}/google/protobuf/unittest_embed_optimize_for.proto" /> |
| 74 | + <arg file="${protos-dir}/google/protobuf/unittest_import.proto" /> |
| 75 | + <arg file="${protos-dir}/google/protobuf/unittest_mset.proto" /> |
| 76 | + <arg file="${protos-dir}/google/protobuf/unittest_optimize_for.proto" /> |
| 77 | + </exec> |
| 78 | + |
| 79 | + <exec program="${tools-protogen}" |
| 80 | + workingdir="${tmp-dir}"> |
| 81 | + <arg value="compiled.pb" /> |
| 82 | + </exec> |
| 83 | + </target> |
| 84 | + |
| 85 | + <target name="copy-generated-source" |
| 86 | + description="Copies generated source from temporary directory to source tree. Use with care!"> |
| 87 | + <copy todir="${src}/ProtocolBuffers/DescriptorProtos"> |
| 88 | + <fileset basedir="${tmp-dir}"> |
| 89 | + <include name="DescriptorProtoFile.cs" /> |
| 90 | + <include name="CSharpOptions.cs" /> |
| 91 | + </fileset> |
| 92 | + </copy> |
| 93 | + |
| 94 | + <copy todir="${src}/ProtocolBuffers.Test/TestProtos"> |
| 95 | + <fileset basedir="${tmp-dir}"> |
| 96 | + <include name="UnitTestProtoFile.cs" /> |
| 97 | + <include name="UnitTestCustomOptionsProtoFile.cs" /> |
| 98 | + <include name="UnitTestEmbedOptimizeForProtoFile.cs" /> |
| 99 | + <include name="UnitTestImportProtoFile.cs" /> |
| 100 | + <include name="UnitTestMessageSetProtoFile.cs" /> |
| 101 | + <include name="UnitTestOptimizeForProtoFile.cs" /> |
| 102 | + </fileset> |
| 103 | + </copy> |
| 104 | + </target> |
| 105 | + |
| 106 | + <target name="build" description="Builds all C# code"> |
| 107 | + <msbuild project="${src}/ProtocolBuffers.sln"> |
| 108 | + <property name="Configuration" |
| 109 | + value="${build-configuration}" /> |
| 110 | + </msbuild> |
| 111 | + </target> |
| 112 | + |
| 113 | + <target name="test" description="Runs all unit tests"> |
| 114 | + <nunit2> |
| 115 | + <formatter type="Plain" /> |
| 116 | + <test assemblyname="${src}/ProtocolBuffers.Test/bin/${build-configuration}/Google.ProtocolBuffers.Test.dll" /> |
| 117 | + <test assemblyname="${src}/Protogen.Test/bin/${build-configuration}/Google.ProtocolBuffers.ProtoGen.Test.dll" /> |
| 118 | + </nunit2> |
| 119 | + </target> |
| 120 | + |
| 121 | + <target name="perf-test" description="Runs all performance tests"> |
| 122 | + <fail message="Performance tests not implemented yet" /> |
| 123 | + </target> |
| 124 | + |
| 125 | + |
| 126 | +</project> |
0 commit comments