| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- <?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"
- 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}/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="UnitTestProtoFile.cs" />
- <include name="UnitTestCSharpOptionsProtoFile.cs" />
- <include name="UnitTestCustomOptionsProtoFile.cs" />
- <include name="UnitTestEmbedOptimizeForProtoFile.cs" />
- <include name="UnitTestImportProtoFile.cs" />
- <include name="UnitTestMessageSetProtoFile.cs" />
- <include name="UnitTestOptimizeForProtoFile.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}" />
- </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}/Protogen.Test/bin/${build-configuration}/Google.ProtocolBuffers.ProtoGen.Test.dll" />
- </nunit2>
- </target>
-
- <target name="dist"
- description="Copies compiled binaries into the output directory">
- <delete dir="${output-dir}" />
- <mkdir dir="${output-dir}" />
- <copy todir="${output-dir}"
- flatten="true">
- <fileset basedir="${src}">
- <include name="ProtocolBuffers/bin/${build-configuration}/Google.ProtocolBuffers.dll" />
- <include name="ProtoGen/bin/${build-configuration}/ProtoGen.exe" />
- <include name="ProtoMunge/bin/${build-configuration}/ProtoMunge.exe" />
- <include name="ProtoDump/bin/${build-configuration}/ProtoDump.exe" />
- <include name="ProtoBench/bin/${build-configuration}/ProtoBench.exe" />
- </fileset>
- </copy>
- </target>
-
-
- </project>
|