Browse Source

Implemented an alternative build script using MSBuild 4.0

ArnoldZokas 15 years ago
parent
commit
eb577e6096
5 changed files with 266 additions and 0 deletions
  1. 81 0
      cfg/Targets/Common.targets
  2. 5 0
      cfg/benchmark.bat
  3. 5 0
      cfg/build.bat
  4. 170 0
      cfg/build.csproj
  5. 5 0
      cfg/buildAll.bat

+ 81 - 0
cfg/Targets/Common.targets

@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+
+	<Target Name="_Clean">
+		<RemoveDir Directories="@(WorkingDirectories)" Condition="Exists(%(WorkingDirectories.Identity))" />
+		<MakeDir Directories="@(WorkingDirectories)" />
+	</Target>
+
+	<Target Name="_Compile">
+		<MSBuild Projects="%(Solution.Identity)" Properties="Configuration=%(Solution.Configuration);Platform=%(Solution.Platform)"
+				 Targets="%(Solution.BuildTarget)" BuildInParallel="true" Condition="%(Solution.CompileGroup) == $(CompileGroup)" />
+	</Target>
+
+	<Target Name="_EnsureEnvironment">
+		<Error Text="Tool &quot;Protoc&quot; could not be found at path $(ProtocExePath)" Condition="!Exists($(ProtocExePath))" />
+		<Error Text="Tool &quot;Protogen&quot; could not be found at path $(ProtogenExePath)" Condition="!Exists($(ProtogenExePath))" />
+	</Target>
+
+	<Target Name="_GenerateSource">
+		<PropertyGroup>
+			<ProtosList>@(Protos)</ProtosList>
+			<Args>$(ProtosList.Replace(`;`,` `))</Args>
+		</PropertyGroup>
+		
+		<Exec Command="$(ProtocExePath) --proto_path=$(ProtosDirectory) --descriptor_set_out=compiled.pb $(Args)" WorkingDirectory="$(BuildTempDirectory)" />
+		<Exec Command="$(ProtogenExePath) compiled.pb" WorkingDirectory="$(BuildTempDirectory)" />
+	</Target>
+
+	<Target Name="_CopyGeneratedSource">
+		<Copy SourceFiles="%(GeneratedSource.Identity)" DestinationFiles="%(GeneratedSource.TargetDirectory)\%(GeneratedSource.Filename)%(GeneratedSource.Extension)" />
+	</Target>
+
+	<Target Name="_Test">
+		<Exec Command="&quot;$(NUnitExePath)&quot; %(NUnitTests.Identity) /xml=%(NUnitTests.Filename)%(NUnitTests.Extension).xml" WorkingDirectory="$(BuildTempDirectory)" />
+	</Target>
+
+	<Target Name="_Package">
+		<Copy SourceFiles="@(PackageContents)" DestinationFolder="$(PackageOutputDirectory)\%(PackageContents.TargetDirectory)\%(PackageContents.RecursiveDir)" />
+	</Target>
+
+	<!--
+		BENCHMARK - this needs optimising but it is 1 AM and I need to be up in 5 hours
+	-->
+	<Target Name="_GenerateBenchmarkSource">
+		<PropertyGroup>
+			<Args>$(BenchmarkProtosDirectory)\google_size.proto $(BenchmarkProtosDirectory)\google_speed.proto</Args>
+		</PropertyGroup>
+
+		<Exec Command="$(ProtocExePath) --proto_path=$(BenchmarkProtosDirectory);$(ProtosDirectory) --include_imports=compiled.pb --descriptor_set_out=compiled.pb $(Args)" WorkingDirectory="$(BenchmarkTempDirectory)" />
+		<Exec Command="$(ProtogenExePath) compiled.pb" WorkingDirectory="$(BenchmarkTempDirectory)" />
+	</Target>
+
+	<Target Name="_CompileBenchmarkAssembly">
+		<ItemGroup>
+			<BenchmarkSources Include="$(BenchmarkTempDirectory)\GoogleSizeProtoFile.cs" />
+			<BenchmarkSources Include="$(BenchmarkTempDirectory)\GoogleSpeedProtoFile.cs" />
+		</ItemGroup>
+		
+		<Csc TargetType="library" OutputAssembly="$(BenchmarkTempDirectory)\BenchmarkTypes.dll" Optimize="true" Sources="@(BenchmarkSources)"
+			 References="$(SourceDirectory)\ProtocolBuffers\bin\$(BuildConfiguration)\Google.ProtocolBuffers.dll" />
+	</Target>
+
+	<Target Name="_PrepareBenchmarkEnvironment">
+		<ItemGroup>
+			<BenchmarkResources Include="$(BenchmarkProtosDirectory)\google_message1.dat" />
+			<BenchmarkResources Include="$(BenchmarkProtosDirectory)\google_message2.dat" />
+			<BenchmarkResources Include="$(SourceDirectory)\ProtoBench\bin\$(BuildConfiguration)\ProtoBench.exe" />
+		</ItemGroup>
+		
+		<Copy SourceFiles="@(BenchmarkResources)" DestinationFolder="$(BenchmarkTempDirectory)" />
+	</Target>
+
+	<Target Name="_RunBenchmark">
+		<PropertyGroup>
+			<Args>Google.ProtocolBuffers.ProtoBench.SizeMessage1,BenchmarkTypes google_message1.dat Google.ProtocolBuffers.ProtoBench.SpeedMessage1,BenchmarkTypes google_message1.dat Google.ProtocolBuffers.ProtoBench.SizeMessage2,BenchmarkTypes google_message2.dat Google.ProtocolBuffers.ProtoBench.SpeedMessage2,BenchmarkTypes google_message2.dat</Args>
+		</PropertyGroup>
+		
+		<Exec Command="ProtoBench.exe $(Args)" WorkingDirectory="$(BenchmarkTempDirectory)" />
+	</Target>
+
+</Project>

+ 5 - 0
cfg/benchmark.bat

@@ -0,0 +1,5 @@
+@echo off
+
+%WINDIR%\Microsoft.NET\Framework\v4.0.30319\msbuild build.csproj /t:Benchmark
+
+pause

+ 5 - 0
cfg/build.bat

@@ -0,0 +1,5 @@
+@echo off
+
+%WINDIR%\Microsoft.NET\Framework\v4.0.30319\msbuild build.csproj
+
+pause

+ 170 - 0
cfg/build.csproj

@@ -0,0 +1,170 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+
+	<PropertyGroup>
+		<ProjectName>Protocol Buffers</ProjectName>
+		<BuildConfiguration>Debug</BuildConfiguration>
+		<CompileGroup>Build</CompileGroup>
+		<VSHostExcludeWildcard>$(SourceDirectory)\**\*.vshost.exe*</VSHostExcludeWildcard>
+
+		<!--Directory Paths-->
+		<ProjectDirectory>$(MSBuildProjectDirectory)\..</ProjectDirectory>
+		<BuildTempDirectory>$(ProjectDirectory)\_tmp</BuildTempDirectory>
+		<BenchmarkTempDirectory>$(ProjectDirectory)\_benchmark</BenchmarkTempDirectory>
+		<PackageOutputDirectory>$(ProjectDirectory)\_dist</PackageOutputDirectory>
+		<SourceDirectory>$(ProjectDirectory)\src</SourceDirectory>
+		<BenchmarkProtosDirectory>$(ProjectDirectory)\benchmarks</BenchmarkProtosDirectory>
+		<ProtosDirectory>$(ProjectDirectory)\protos</ProtosDirectory>
+		<LibDirectory>$(ProjectDirectory)\lib</LibDirectory>
+
+		<!--File Paths-->
+		<SolutionFile>$(ProjectDirectory)\src\ProtocolBuffers.sln</SolutionFile>
+
+		<!--Tools-->
+		<ProtocExePath>$(LibDirectory)\protoc.exe</ProtocExePath>
+		<ProtogenExePath>$(SourceDirectory)\ProtoGen\bin\$(BuildConfiguration)\protogen.exe</ProtogenExePath>
+		<NUnitExePath>$(LibDirectory)\NUnit 2.2.8.0\nunit-console.exe</NUnitExePath>
+	</PropertyGroup>
+
+	<Import Project="Targets\Common.targets"/>
+
+	<ItemGroup>
+		<WorkingDirectories Include="$(BuildTempDirectory)" />
+		<WorkingDirectories Include="$(BenchmarkTempDirectory)" />
+		<WorkingDirectories Include="$(PackageOutputDirectory)" />
+
+		<Solution Include="$(SolutionFile)">
+			<Configuration>$(BuildConfiguration)</Configuration>
+			<Platform>Any CPU</Platform>
+			<BuildTarget>Rebuild</BuildTarget>
+			<CompileGroup>Build</CompileGroup>
+		</Solution>
+		<Solution Include="$(SolutionFile)">
+			<Configuration>Debug</Configuration>
+			<Platform>Any CPU</Platform>
+			<BuildTarget>Rebuild</BuildTarget>
+			<CompileGroup>BuildAll</CompileGroup>
+		</Solution>
+		<Solution Include="$(SolutionFile)">
+			<Configuration>Release</Configuration>
+			<Platform>Any CPU</Platform>
+			<BuildTarget>Rebuild</BuildTarget>
+			<CompileGroup>BuildAll</CompileGroup>
+	</Solution>
+		<Solution Include="$(SolutionFile)">
+			<Configuration>Silverlight2</Configuration>
+			<Platform>Any CPU</Platform>
+			<BuildTarget>Rebuild</BuildTarget>
+			<CompileGroup>BuildAll</CompileGroup>
+		</Solution>
+		<!--<Solution Include="$(ProjectDirectory)\src\ProtocolBuffers/ProtocolBuffersCF.csproj">
+			<Configuration>$(BuildConfiguration)</Configuration>
+			<Platform>AnyCPU</Platform>
+			<BuildTarget>Rebuild</BuildTarget>
+			<CompileGroup>BuildAll</CompileGroup>
+		</Solution>-->
+
+		<Protos Include="$(ProtosDirectory)\google\protobuf\descriptor.proto" />
+		<Protos Include="$(ProtosDirectory)\google\protobuf\csharp_options.proto" />
+		<Protos Include="$(ProtosDirectory)\google\protobuf\unittest.proto" />
+		<Protos Include="$(ProtosDirectory)\google\protobuf\unittest_csharp_options.proto" />
+		<Protos Include="$(ProtosDirectory)\google\protobuf\unittest_custom_options.proto" />
+		<Protos Include="$(ProtosDirectory)\google\protobuf\unittest_embed_optimize_for.proto" />
+		<Protos Include="$(ProtosDirectory)\google\protobuf\unittest_import.proto" />
+		<Protos Include="$(ProtosDirectory)\google\protobuf\unittest_mset.proto" />
+		<Protos Include="$(ProtosDirectory)\google\protobuf\unittest_optimize_for.proto" />
+		<Protos Include="$(ProtosDirectory)\tutorial\addressbook.proto" />
+
+		<GeneratedSource Include="$(BuildTempDirectory)\CSharpOptions.cs">
+			<TargetDirectory>$(SourceDirectory)\ProtocolBuffers\DescriptorProtos</TargetDirectory>
+		</GeneratedSource>
+		<GeneratedSource Include="$(BuildTempDirectory)\DescriptorProtoFile.cs">
+			<TargetDirectory>$(SourceDirectory)\ProtocolBuffers\DescriptorProtos</TargetDirectory>
+		</GeneratedSource>
+		<GeneratedSource Include="$(BuildTempDirectory)\UnitTestMessageSetProtoFile.cs">
+			<TargetDirectory>$(SourceDirectory)\ProtocolBuffers.Test\TestProtos</TargetDirectory>
+		</GeneratedSource>
+		<GeneratedSource Include="$(BuildTempDirectory)\UnitTestOptimizeForProtoFile.cs">
+			<TargetDirectory>$(SourceDirectory)\ProtocolBuffers.Test\TestProtos</TargetDirectory>
+		</GeneratedSource>
+		<GeneratedSource Include="$(BuildTempDirectory)\UnitTestProtoFile.cs">
+			<TargetDirectory>$(SourceDirectory)\ProtocolBuffers.Test\TestProtos</TargetDirectory>
+		</GeneratedSource>
+		<GeneratedSource Include="$(BuildTempDirectory)\AddressBookProtos.cs">
+			<TargetDirectory>$(SourceDirectory)\ProtocolBuffers.Test\TestProtos</TargetDirectory>
+		</GeneratedSource>
+		<GeneratedSource Include="$(BuildTempDirectory)\UnitTestCSharpOptionsProtoFile.cs">
+			<TargetDirectory>$(SourceDirectory)\ProtocolBuffers.Test\TestProtos</TargetDirectory>
+		</GeneratedSource>
+		<GeneratedSource Include="$(BuildTempDirectory)\UnitTestCustomOptionsProtoFile.cs">
+			<TargetDirectory>$(SourceDirectory)\ProtocolBuffers.Test\TestProtos</TargetDirectory>
+		</GeneratedSource>
+		<GeneratedSource Include="$(BuildTempDirectory)\UnitTestEmbedOptimizeForProtoFile.cs">
+			<TargetDirectory>$(SourceDirectory)\ProtocolBuffers.Test\TestProtos</TargetDirectory>
+		</GeneratedSource>
+		<GeneratedSource Include="$(BuildTempDirectory)\UnitTestImportProtoFile.cs">
+			<TargetDirectory>$(SourceDirectory)\ProtocolBuffers.Test\TestProtos</TargetDirectory>
+		</GeneratedSource>
+
+		<NUnitTests Include="$(SourceDirectory)\ProtocolBuffers.Test\bin\$(BuildConfiguration)\Google.ProtocolBuffers.Test.dll" />
+		<NUnitTests Include="$(SourceDirectory)\Protogen.Test\bin\$(BuildConfiguration)\Google.ProtocolBuffers.ProtoGen.Test.dll" />
+
+		<PackageContents Include="$(ProjectDirectory)\readme.txt" />
+		<PackageContents Include="$(ProjectDirectory)\license.txt" />
+		<PackageContents Include="$(ProjectDirectory)\protos\**\*.*">
+			<TargetDirectory>\protos</TargetDirectory>
+		</PackageContents>
+		<PackageContents Include="$(SourceDirectory)\ProtocolBuffers\bin\Debug\Google.ProtocolBuffers.*" Exclude="$(VSHostExcludeWildcard)">
+			<TargetDirectory>\Debug</TargetDirectory>
+		</PackageContents>
+		<PackageContents Include="$(SourceDirectory)\ProtoGen\bin\Debug\ProtoGen.*" Exclude="$(VSHostExcludeWildcard)">
+			<TargetDirectory>\Debug</TargetDirectory>
+		</PackageContents>
+		<PackageContents Include="$(SourceDirectory)\ProtoMunge\bin\Debug\ProtoMunge.*" Exclude="$(VSHostExcludeWildcard)">
+			<TargetDirectory>\Debug</TargetDirectory>
+		</PackageContents>
+		<PackageContents Include="$(SourceDirectory)\ProtoDump\bin\Debug\ProtoDump.*" Exclude="$(VSHostExcludeWildcard)">
+			<TargetDirectory>\Debug</TargetDirectory>
+		</PackageContents>
+		<PackageContents Include="$(SourceDirectory)\ProtoBench\bin\Debug\ProtoBench.*" Exclude="$(VSHostExcludeWildcard)">
+			<TargetDirectory>\Debug</TargetDirectory>
+		</PackageContents>
+		<PackageContents Include="$(SourceDirectory)\ProtocolBuffers\bin\Release\Google.ProtocolBuffers.*" Exclude="$(VSHostExcludeWildcard)">
+			<TargetDirectory>\Release</TargetDirectory>
+		</PackageContents>
+		<PackageContents Include="$(SourceDirectory)\ProtoGen\bin\Release\ProtoGen.*" Exclude="$(VSHostExcludeWildcard)">
+			<TargetDirectory>\Release</TargetDirectory>
+		</PackageContents>
+		<PackageContents Include="$(SourceDirectory)\ProtoMunge\bin\Release\ProtoMunge.*" Exclude="$(VSHostExcludeWildcard)">
+			<TargetDirectory>\Release</TargetDirectory>
+		</PackageContents>
+		<PackageContents Include="$(SourceDirectory)\ProtoDump\bin\Release\ProtoDump.*" Exclude="$(VSHostExcludeWildcard)">
+			<TargetDirectory>\Release</TargetDirectory>
+		</PackageContents>
+		<PackageContents Include="$(SourceDirectory)\ProtoBench\bin\Release\ProtoBench.*" Exclude="$(VSHostExcludeWildcard)">
+			<TargetDirectory>\Release</TargetDirectory>
+		</PackageContents>
+		<PackageContents Include="$(SourceDirectory)\ProtocolBuffers\bin\Silverlight2\Google.ProtocolBuffers.*" Exclude="$(VSHostExcludeWildcard)">
+			<TargetDirectory>\Silverlight2</TargetDirectory>
+		</PackageContents>
+		<!--<PackageContents Include="$(SourceDirectory)\ProtocolBuffers\bin\ReleaseCF\Google.ProtocolBuffers.*" Exclude="$(VSHostExcludeWildcard)">
+				<TargetDirectory>\CompactFramework35</TargetDirectory>
+			</PackageContents>-->
+	</ItemGroup>
+
+	<!--target groups-->
+	<Target Name="Build" DependsOnTargets="_Clean;_Compile;_EnsureEnvironment;_GenerateSource;_CopyGeneratedSource">
+		<Message Text="BEFORE" Importance="high" />
+		<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="_Clean;_Compile" Properties="ForceTargets=true" />
+		<CallTarget Targets="_Test" />
+	</Target>
+
+	<Target Name="BuildAll" DependsOnTargets="_Clean;_Compile;_EnsureEnvironment;_GenerateSource;_CopyGeneratedSource">
+		<Message Text="BEFORE" Importance="high" />
+		<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="_Clean;_Compile" Properties="ForceTargets=true" />
+		<CallTarget Targets="_Test;_Package" />
+	</Target>
+
+	<Target Name="Benchmark" DependsOnTargets="_Clean;_GenerateBenchmarkSource;_CompileBenchmarkAssembly;_PrepareBenchmarkEnvironment;_RunBenchmark" />
+
+</Project>

+ 5 - 0
cfg/buildAll.bat

@@ -0,0 +1,5 @@
+@echo off
+
+%WINDIR%\Microsoft.NET\Framework\v4.0.30319\msbuild build.csproj /t:BuildAll /p:CompileGroup=BuildAll
+
+pause