Common.targets 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  3. <Target Name="_Clean">
  4. <RemoveDir Directories="@(WorkingDirectories)" Condition="Exists(%(WorkingDirectories.Identity))" />
  5. <MakeDir Directories="@(WorkingDirectories)" />
  6. </Target>
  7. <Target Name="_Compile" DependsOnTargets="_Clean">
  8. <MSBuild Projects="$(SolutionFile)" Properties="Configuration=$(BuildConfiguration)" BuildInParallel="true" />
  9. </Target>
  10. <Target Name="_GenerateSource">
  11. <PropertyGroup>
  12. <ProtosList>@(Protos)</ProtosList>
  13. <Args>$(ProtosList.Replace(`;`,` `))</Args>
  14. </PropertyGroup>
  15. <Exec Command="$(ProtocExePath) --proto_path=$(ProtosDirectory) --descriptor_set_out=compiled.pb $(Args)" WorkingDirectory="$(BuildTempDirectory)" />
  16. <Exec Command="$(ProtogenExePath) compiled.pb" WorkingDirectory="$(BuildTempDirectory)" />
  17. </Target>
  18. <Target Name="_CopyGeneratedSource" DependsOnTargets="_GenerateSource">
  19. <Copy SourceFiles="%(GeneratedSource.Identity)" DestinationFiles="%(GeneratedSource.TargetDirectory)\%(GeneratedSource.Filename)%(GeneratedSource.Extension)" />
  20. </Target>
  21. <Target Name="_CompileGeneratedSource" DependsOnTargets="_CopyGeneratedSource">
  22. <MSBuild Projects="$(SolutionFile)" Properties="Configuration=$(BuildConfiguration)" BuildInParallel="true" />
  23. </Target>
  24. <Target Name="_Test" DependsOnTargets="_CompileGeneratedSource">
  25. <Exec Command="&quot;$(NUnitExePath)&quot; %(TestContainer.Identity) /xml:$(BuildTempDirectory)\..\%(TestContainer.Filename).$(BuildConfiguration).xml" />
  26. </Target>
  27. <!--## Package Generation ##-->
  28. <Target Name="_CleanOutputDirectory">
  29. <ItemGroup><DirectoriesToDelete Include="$([System.IO.Directory]::GetDirectories('$(BuildOutputDirectory)'))" /></ItemGroup>
  30. <RemoveDir Directories="@(DirectoriesToDelete)" ContinueOnError="true" />
  31. <ItemGroup><FilesToDelete Include="$(BuildOutputDirectory)\**\*.*" /></ItemGroup>
  32. <Delete Files="@(FilesToDelete)" />
  33. </Target>
  34. <Target Name="_PreparePackageComponent">
  35. <Copy SourceFiles="@(DynamicPackageItem)" DestinationFolder="$(BuildOutputDirectory)\%(DynamicPackageItem.TargetDirectory)\%(DynamicPackageItem.RecursiveDir)" />
  36. </Target>
  37. <Target Name="_GeneratePackage">
  38. <Copy SourceFiles="@(StaticPackageItem)" DestinationFolder="$(BuildOutputDirectory)\%(StaticPackageItem.TargetDirectory)\%(StaticPackageItem.RecursiveDir)" />
  39. <Exec Command="&quot;$(ZipExePath)&quot; a -tzip $(PackageName) * -r" WorkingDirectory="$(BuildOutputDirectory)" />
  40. <ItemGroup><DirectoriesToDelete Include="$([System.IO.Directory]::GetDirectories('$(BuildOutputDirectory)'))" /></ItemGroup>
  41. <ItemGroup><FilesToDelete Include="$(BuildOutputDirectory)\**\*.*" Exclude="$(BuildOutputDirectory)\$(PackageName)" /></ItemGroup>
  42. <Delete Files="@(FilesToDelete)" />
  43. <RemoveDir Directories="@(DirectoriesToDelete)" ContinueOnError="true" />
  44. </Target>
  45. <!--## Benchmark ##-->
  46. <Target Name="_GenerateBenchmarkSource" DependsOnTargets="_Clean">
  47. <PropertyGroup>
  48. <Args>$(BenchmarkProtosDirectory)\google_size.proto $(BenchmarkProtosDirectory)\google_speed.proto</Args>
  49. </PropertyGroup>
  50. <Exec Command="$(ProtocExePath) --proto_path=$(BenchmarkProtosDirectory);$(ProtosDirectory) --include_imports=compiled.pb --descriptor_set_out=compiled.pb $(Args)" WorkingDirectory="$(BuildTempDirectory)" />
  51. <Exec Command="$(ProtogenExePath) compiled.pb" WorkingDirectory="$(BuildTempDirectory)" />
  52. </Target>
  53. <Target Name="_CompileBenchmarkAssembly" DependsOnTargets="_GenerateBenchmarkSource">
  54. <ItemGroup>
  55. <BenchmarkSources Include="$(BuildTempDirectory)\GoogleSizeProtoFile.cs" />
  56. <BenchmarkSources Include="$(BuildTempDirectory)\GoogleSpeedProtoFile.cs" />
  57. </ItemGroup>
  58. <Csc TargetType="library" OutputAssembly="$(BuildTempDirectory)\BenchmarkTypes.dll" Optimize="true" Sources="@(BenchmarkSources)" References="$(SourceDirectory)\ProtocolBuffers\bin\$(BuildConfiguration)\Google.ProtocolBuffers.dll" />
  59. </Target>
  60. <Target Name="_PrepareBenchmarkEnvironment" DependsOnTargets="_CompileBenchmarkAssembly">
  61. <ItemGroup>
  62. <BenchmarkResources Include="$(BenchmarkProtosDirectory)\google_message1.dat" />
  63. <BenchmarkResources Include="$(BenchmarkProtosDirectory)\google_message2.dat" />
  64. <BenchmarkResources Include="$(SourceDirectory)\ProtocolBuffers\bin\$(BuildConfiguration)\Google.ProtocolBuffers.dll" />
  65. <BenchmarkResources Include="$(SourceDirectory)\ProtoBench\bin\$(BuildConfiguration)\ProtoBench.exe" />
  66. </ItemGroup>
  67. <Copy SourceFiles="@(BenchmarkResources)" DestinationFolder="$(BuildTempDirectory)" />
  68. </Target>
  69. <Target Name="_RunBenchmarks" DependsOnTargets="_PrepareBenchmarkEnvironment">
  70. <ItemGroup>
  71. <BenchmarkParameter Include="Google.ProtocolBuffers.ProtoBench.SizeMessage1,BenchmarkTypes" />
  72. <BenchmarkParameter Include="google_message1.dat" />
  73. <BenchmarkParameter Include="Google.ProtocolBuffers.ProtoBench.SpeedMessage1,BenchmarkTypes" />
  74. <BenchmarkParameter Include="google_message1.dat" />
  75. <BenchmarkParameter Include="Google.ProtocolBuffers.ProtoBench.SizeMessage2,BenchmarkTypes" />
  76. <BenchmarkParameter Include="google_message2.dat" />
  77. <BenchmarkParameter Include="Google.ProtocolBuffers.ProtoBench.SpeedMessage2,BenchmarkTypes" />
  78. <BenchmarkParameter Include="google_message2.dat" />
  79. </ItemGroup>
  80. <PropertyGroup>
  81. <BenchmarkParameterList>@(BenchmarkParameter)</BenchmarkParameterList>
  82. <Args>$(BenchmarkParameterList.Replace(`;`,` `))</Args>
  83. </PropertyGroup>
  84. <Exec Command="&quot;$(ProtoBenchExePath)&quot; $(Args) > &quot;$(BuildTempDirectory)\..\BenchmarkResults.txt&quot;" WorkingDirectory="$(BuildTempDirectory)" />
  85. </Target>
  86. </Project>