Common.targets 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  3. <Target Name="_BuildSolution">
  4. <Message Text="Running $(SolutionTarget) $(BuildConfiguration) with $(BuildTools) on $(SolutionFile)" Importance="normal" />
  5. <MSBuild Targets="$(SolutionTarget)" Projects="$(SolutionFile)" ToolsVersion="$(BuildTools)"
  6. Properties="Configuration=$(BuildConfiguration);$(ForcedFrameworkVersion)TreatWarningsAsErrors=true;"
  7. />
  8. </Target>
  9. <Target Name="_Clean">
  10. <RemoveDir Directories="@(WorkingDirectories)" Condition="Exists(%(WorkingDirectories.Identity))" />
  11. <MakeDir Directories="@(WorkingDirectories)" />
  12. <MSBuild Projects="$(MSBuildProjectFullPath)" Properties="SolutionTarget=Clean;BuildConfiguration=$(BuildConfiguration)" Targets="_BuildSolution" ContinueOnError="true" />
  13. </Target>
  14. <Target Name="_Compile">
  15. <MSBuild Projects="$(MSBuildProjectFullPath)" Properties="SolutionTarget=Rebuild;BuildConfiguration=$(BuildConfiguration)" Targets="_BuildSolution" />
  16. </Target>
  17. <Target Name="_CompileGeneratedSource" DependsOnTargets="_CopyGeneratedSource">
  18. <MSBuild Projects="$(MSBuildProjectFullPath)" Properties="Step=Two;SolutionTarget=Build;BuildConfiguration=$(BuildConfiguration)" Targets="_BuildSolution" />
  19. </Target>
  20. <Target Name="_GenerateSource">
  21. <Exec Command="$(ProtocExePath) --proto_path=$(ProtosDirectory) --descriptor_set_out=compiled.pb @(Protos->'%(RelativeDir)%(Filename)%(Extension)', ' ')" WorkingDirectory="$(BuildTempDirectory)" />
  22. <Exec Command="$(ProtogenExePath) compiled.pb" WorkingDirectory="$(BuildTempDirectory)" />
  23. <!-- Generate the AddressBookProtos.cs directly -->
  24. <Exec Command="$(ProtogenExePath) --protoc_dir=$(LibDirectory) --proto_path=$(ProtosDirectory) $(ProtosDirectory)\tutorial\addressbook.proto -namespace=Google.ProtocolBuffers.Examples.AddressBook -umbrella_classname=AddressBookProtos" WorkingDirectory="$(BuildTempDirectory)" />
  25. </Target>
  26. <Target Name="_CopyGeneratedSource" DependsOnTargets="_GenerateSource">
  27. <Copy SourceFiles="%(GeneratedSource.Identity)" DestinationFiles="%(GeneratedSource.TargetDirectory)\%(GeneratedSource.Filename)%(GeneratedSource.Extension)" />
  28. </Target>
  29. <Target Name="_Test" DependsOnTargets="_CompileGeneratedSource" Condition="$(BuildConfiguration)=='Debug' or $(BuildConfiguration)=='Release'">
  30. <CallTarget Targets="_RunTests" />
  31. </Target>
  32. <Target Name="_RunTests">
  33. <Exec Command="&quot;$(NUnitExePath)&quot; /noshadow %(TestContainer.Identity) /xml:$(BuildTempDirectory)\..\%(TestContainer.Filename).$(BuildConfiguration).xml" />
  34. </Target>
  35. <!--## Package Generation ##-->
  36. <Target Name="_CleanOutputDirectory">
  37. <RemoveDir Directories="$(ProjectDirectory)\build_output\Package" ContinueOnError="true" />
  38. <RemoveDir Directories="$(ProjectDirectory)\build_output" ContinueOnError="true" />
  39. <MakeDir Directories="$(ProjectDirectory)\build_output" ContinueOnError="true" />
  40. </Target>
  41. <Target Name="_PreparePackageComponent">
  42. <Copy SourceFiles="@(DynamicPackageItem)" DestinationFolder="$(ProjectDirectory)\build_output\Package\$(BuildConfiguration)\%(DynamicPackageItem.TargetDirectory)\%(DynamicPackageItem.RecursiveDir)" />
  43. </Target>
  44. <Target Name="_GeneratePackage">
  45. <Copy SourceFiles="@(StaticPackageItem)" DestinationFolder="$(ProjectDirectory)\build_output\Package\%(StaticPackageItem.TargetDirectory)\%(StaticPackageItem.RecursiveDir)" />
  46. <Exec Command="&quot;$(ZipExePath)&quot; a -tzip ..\$(PackageName) * -r" WorkingDirectory="$(ProjectDirectory)\build_output\Package" />
  47. </Target>
  48. <!--## Benchmark ##-->
  49. <Target Name="_GenerateBenchmarkSource" DependsOnTargets="_Clean;_Compile">
  50. <PropertyGroup>
  51. <Args>$(BenchmarkProtosDirectory)\google_size.proto $(BenchmarkProtosDirectory)\google_speed.proto</Args>
  52. </PropertyGroup>
  53. <Exec Command="$(ProtocExePath) --proto_path=$(BenchmarkProtosDirectory);$(ProtosDirectory) --include_imports=compiled.pb --descriptor_set_out=compiled.pb $(Args)" WorkingDirectory="$(BuildTempDirectory)" />
  54. <Exec Command="$(ProtogenExePath) compiled.pb" WorkingDirectory="$(BuildTempDirectory)" />
  55. </Target>
  56. <Target Name="_CompileBenchmarkAssembly" DependsOnTargets="_GenerateBenchmarkSource">
  57. <ItemGroup>
  58. <BenchmarkSources Include="$(BuildTempDirectory)\GoogleSizeProtoFile.cs" />
  59. <BenchmarkSources Include="$(BuildTempDirectory)\GoogleSpeedProtoFile.cs" />
  60. <BenchmarkSources Include="$(SourceDirectory)\ProtoBench\Properties\AssemblyInfo.cs" />
  61. </ItemGroup>
  62. <Csc TargetType="library" OutputAssembly="$(BuildTempDirectory)\BenchmarkTypes.dll" Optimize="true" Sources="@(BenchmarkSources)" References="$(SourceDirectory)\ProtocolBuffers\bin\$(BuildConfiguration)\Google.ProtocolBuffers.dll" />
  63. </Target>
  64. <Target Name="_PrepareBenchmarkEnvironment" DependsOnTargets="_CompileBenchmarkAssembly">
  65. <ItemGroup>
  66. <BenchmarkResources Include="$(BenchmarkProtosDirectory)\google_message1.dat" />
  67. <BenchmarkResources Include="$(BenchmarkProtosDirectory)\google_message2.dat" />
  68. <BenchmarkResources Include="$(SourceDirectory)\ProtocolBuffers\bin\$(BuildConfiguration)\Google.ProtocolBuffers.dll" />
  69. <BenchmarkResources Include="$(SourceDirectory)\ProtocolBuffers.Serialization\bin\$(BuildConfiguration)\Google.ProtocolBuffers.Serialization.dll" />
  70. <BenchmarkResources Include="$(SourceDirectory)\ProtoBench\bin\$(BuildConfiguration)\ProtoBench.exe" />
  71. </ItemGroup>
  72. <Copy SourceFiles="@(BenchmarkResources)" DestinationFolder="$(BuildTempDirectory)" />
  73. </Target>
  74. <Target Name="_RunBenchmarks" DependsOnTargets="_PrepareBenchmarkEnvironment">
  75. <ItemGroup>
  76. <BenchmarkParameter Include="/v2" />
  77. <BenchmarkParameter Include="Google.ProtocolBuffers.ProtoBench.SizeMessage1,BenchmarkTypes" />
  78. <BenchmarkParameter Include="google_message1.dat" />
  79. <BenchmarkParameter Include="Google.ProtocolBuffers.ProtoBench.SpeedMessage1,BenchmarkTypes" />
  80. <BenchmarkParameter Include="google_message1.dat" />
  81. <BenchmarkParameter Include="Google.ProtocolBuffers.ProtoBench.SizeMessage2,BenchmarkTypes" />
  82. <BenchmarkParameter Include="google_message2.dat" />
  83. <BenchmarkParameter Include="Google.ProtocolBuffers.ProtoBench.SpeedMessage2,BenchmarkTypes" />
  84. <BenchmarkParameter Include="google_message2.dat" />
  85. </ItemGroup>
  86. <PropertyGroup>
  87. <BenchmarkParameterList>@(BenchmarkParameter)</BenchmarkParameterList>
  88. <Args>$(BenchmarkParameterList.Replace(`;`,` `))</Args>
  89. </PropertyGroup>
  90. <Exec Command="&quot;$(ProtoBenchExePath)&quot; @(BenchmarkParameter->'%(Identity)', ' ') > &quot;$(BuildTempDirectory)\..\BenchmarkResults.txt&quot;" WorkingDirectory="$(BuildTempDirectory)" />
  91. </Target>
  92. </Project>