aboutsummaryrefslogtreecommitdiff
path: root/build/Common.targets
blob: 8b4238731cb203f8a24747da6730f8bbed15268d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?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" DependsOnTargets="_Clean">
		<MSBuild Projects="$(SolutionFile)" Properties="Configuration=$(BuildConfiguration)" BuildInParallel="true" />
	</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" DependsOnTargets="_GenerateSource">
		<Copy SourceFiles="%(GeneratedSource.Identity)" DestinationFiles="%(GeneratedSource.TargetDirectory)\%(GeneratedSource.Filename)%(GeneratedSource.Extension)" />
	</Target>

	<Target Name="_CompileGeneratedSource" DependsOnTargets="_CopyGeneratedSource">
		<MSBuild Projects="$(SolutionFile)" Properties="Configuration=$(BuildConfiguration)" BuildInParallel="true" />
	</Target>

	<Target Name="_Test" DependsOnTargets="_CompileGeneratedSource">
		<Exec Command="&quot;$(NUnitExePath)&quot; %(TestContainer.Identity) /xml:$(BuildTempDirectory)\..\%(TestContainer.Filename).$(BuildConfiguration).xml" />
	</Target>
	
	<!--## Package Generation ##-->
	<Target Name="_CleanOutputDirectory">
		<ItemGroup><DirectoriesToDelete Include="$([System.IO.Directory]::GetDirectories('$(BuildOutputDirectory)'))" /></ItemGroup>
		<RemoveDir Directories="@(DirectoriesToDelete)" ContinueOnError="true" />
		
		<ItemGroup><FilesToDelete Include="$(BuildOutputDirectory)\**\*.*" /></ItemGroup>
		<Delete Files="@(FilesToDelete)" />
	</Target>
	
	<Target Name="_PreparePackageComponent">
		<Copy SourceFiles="@(DynamicPackageItem)" DestinationFolder="$(BuildOutputDirectory)\%(DynamicPackageItem.TargetDirectory)\%(DynamicPackageItem.RecursiveDir)" />
	</Target>

	<Target Name="_GeneratePackage">
		<Copy SourceFiles="@(StaticPackageItem)" DestinationFolder="$(BuildOutputDirectory)\%(StaticPackageItem.TargetDirectory)\%(StaticPackageItem.RecursiveDir)" />
		<Exec Command="&quot;$(ZipExePath)&quot; a -tzip $(PackageName) * -r" WorkingDirectory="$(BuildOutputDirectory)" />

		<ItemGroup><DirectoriesToDelete Include="$([System.IO.Directory]::GetDirectories('$(BuildOutputDirectory)'))" /></ItemGroup>
		<ItemGroup><FilesToDelete Include="$(BuildOutputDirectory)\**\*.*" Exclude="$(BuildOutputDirectory)\$(PackageName)" /></ItemGroup>
		
		<Delete Files="@(FilesToDelete)" />
		<RemoveDir Directories="@(DirectoriesToDelete)" ContinueOnError="true" />
	</Target>

	<!--## Benchmark ##-->
	<Target Name="_GenerateBenchmarkSource" DependsOnTargets="_Clean">
		<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="$(BuildTempDirectory)" />
		<Exec Command="$(ProtogenExePath) compiled.pb" WorkingDirectory="$(BuildTempDirectory)" />
	</Target>

	<Target Name="_CompileBenchmarkAssembly" DependsOnTargets="_GenerateBenchmarkSource">
		<ItemGroup>
			<BenchmarkSources Include="$(BuildTempDirectory)\GoogleSizeProtoFile.cs" />
			<BenchmarkSources Include="$(BuildTempDirectory)\GoogleSpeedProtoFile.cs" />
		</ItemGroup>

		<Csc TargetType="library" OutputAssembly="$(BuildTempDirectory)\BenchmarkTypes.dll" Optimize="true" Sources="@(BenchmarkSources)" References="$(SourceDirectory)\ProtocolBuffers\bin\$(BuildConfiguration)\Google.ProtocolBuffers.dll" />
	</Target>

	<Target Name="_PrepareBenchmarkEnvironment" DependsOnTargets="_CompileBenchmarkAssembly">
		<ItemGroup>
			<BenchmarkResources Include="$(BenchmarkProtosDirectory)\google_message1.dat" />
			<BenchmarkResources Include="$(BenchmarkProtosDirectory)\google_message2.dat" />
			<BenchmarkResources Include="$(SourceDirectory)\ProtocolBuffers\bin\$(BuildConfiguration)\Google.ProtocolBuffers.dll" />
			<BenchmarkResources Include="$(SourceDirectory)\ProtoBench\bin\$(BuildConfiguration)\ProtoBench.exe" />
		</ItemGroup>

		<Copy SourceFiles="@(BenchmarkResources)" DestinationFolder="$(BuildTempDirectory)" />
	</Target>

	<Target Name="_RunBenchmarks" DependsOnTargets="_PrepareBenchmarkEnvironment">
		<ItemGroup>
			<BenchmarkParameter Include="Google.ProtocolBuffers.ProtoBench.SizeMessage1,BenchmarkTypes" />
			<BenchmarkParameter Include="google_message1.dat" />
			<BenchmarkParameter Include="Google.ProtocolBuffers.ProtoBench.SpeedMessage1,BenchmarkTypes" />
			<BenchmarkParameter Include="google_message1.dat" />
			<BenchmarkParameter Include="Google.ProtocolBuffers.ProtoBench.SizeMessage2,BenchmarkTypes" />
			<BenchmarkParameter Include="google_message2.dat" />
			<BenchmarkParameter Include="Google.ProtocolBuffers.ProtoBench.SpeedMessage2,BenchmarkTypes" />
			<BenchmarkParameter Include="google_message2.dat" />
		</ItemGroup>

		<PropertyGroup>
			<BenchmarkParameterList>@(BenchmarkParameter)</BenchmarkParameterList>
			<Args>$(BenchmarkParameterList.Replace(`;`,` `))</Args>
		</PropertyGroup>
		
		<Exec Command="&quot;$(ProtoBenchExePath)&quot; $(Args) > &quot;$(BuildTempDirectory)\..\BenchmarkResults.txt&quot;" WorkingDirectory="$(BuildTempDirectory)" />
	</Target>

</Project>