diff options
author | csharptest <roger@csharptest.net> | 2012-10-15 21:29:17 -0500 |
---|---|---|
committer | rogerk <devnull@localhost> | 2012-10-15 21:29:17 -0500 |
commit | 3c491937d30cf250e0324038065802889740bc36 (patch) | |
tree | f61eb1b641f782baa148069fc853458018930f01 /build/Common.targets | |
parent | 70cf2511627197ed38393f077c98e0827d588507 (diff) | |
download | protobuf-3c491937d30cf250e0324038065802889740bc36.tar.gz protobuf-3c491937d30cf250e0324038065802889740bc36.tar.bz2 protobuf-3c491937d30cf250e0324038065802889740bc36.zip |
Adding project templates and refactored build
Diffstat (limited to 'build/Common.targets')
-rw-r--r-- | build/Common.targets | 243 |
1 files changed, 54 insertions, 189 deletions
diff --git a/build/Common.targets b/build/Common.targets index 7682b19e..31f8550d 100644 --- a/build/Common.targets +++ b/build/Common.targets @@ -1,78 +1,71 @@ <?xml version="1.0" encoding="utf-8"?> - <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <!-- ********************************************************************************************** -Targets For FullBuild +Targets For Clean *********************************************************************************************** --> - <Target Name="_FullBuild" DependsOnTargets="_CleanOutputDirectory;_BuildProtoGen;_GenerateSource;_CopyGeneratedSource"> - <MSBuild Projects="$(MSBuildProjectFullPath)" Properties="SolutionTarget=Rebuild;TargetVersion=NET20;BuildTools=3.5" Targets="_BuildAllConfigurations" /> - <MSBuild Projects="$(MSBuildProjectFullPath)" Properties="SolutionTarget=Rebuild;TargetVersion=CF35;BuildTools=3.5" Targets="_BuildAllConfigurations" /> - <MSBuild Projects="$(MSBuildProjectFullPath)" Properties="SolutionTarget=Rebuild;TargetVersion=SL40;BuildTools=4.0" Targets="_BuildAllConfigurations" /> - <MSBuild Projects="$(MSBuildProjectFullPath)" Properties="" Targets="_CompletePackages" /> - </Target> + <Target Name="_CleanFolder"> + <Message Importance="normal" Text="Removing temporary directory '$(CleanFolderDirectory)'"/> + <Error Text="Can not remove empty directory name." Condition=" '$(CleanFolderDirectory)' == '' " /> - <Target Name="_BuildAllConfigurations"> - <!-- Release Package --> - <MSBuild Projects="$(MSBuildProjectFullPath)" Properties="SolutionTarget=Rebuild;Platform=$(Platform);TargetVersion=$(TargetVersion);BuildTools=$(BuildTools);BuildConfiguration=Release" Targets="_BuildConfiguration" /> - <MSBuild Projects="$(MSBuildProjectFullPath)" Properties="SolutionTarget=Rebuild;Platform=$(Platform);TargetVersion=$(TargetVersion);PackageName=Release-$(TargetVersion)" Targets="_GeneratePackage" /> - <!-- Full Package --> - <MSBuild Projects="$(MSBuildProjectFullPath)" Properties="SolutionTarget=Rebuild;Platform=$(Platform);TargetVersion=$(TargetVersion);BuildTools=$(BuildTools);BuildConfiguration=Debug" Targets="_BuildConfiguration" /> - <MSBuild Projects="$(MSBuildProjectFullPath)" Properties="SolutionTarget=Rebuild;Platform=$(Platform);TargetVersion=$(TargetVersion);PackageName=Full-$(TargetVersion)" Targets="_GeneratePackage" /> + <Exec WorkingDirectory="$(MSBuildProjectDirectory)" Condition="Exists($(CleanFolderDirectory))" Outputs="@(Ignore)" + Command="MOVE /Y "$(CleanFolderDirectory)" "$(CleanFolderDirectory)-deleted" > NUL" /> + + <RemoveDir Directories="$(CleanFolderDirectory)-deleted" Condition="Exists('$(CleanFolderDirectory)-deleted')" /> </Target> - <Target Name="_BuildConfiguration" DependsOnTargets="_ReportConfig;_Clean;_BuildSolution;_Test;_PreparePackageComponent" /> - - <Target Name="_ReportConfig"> - <Message Importance="high" Text=" - -Building $(BuildConfiguration) configuration for .NET Framework $(TargetVersion) $(Platform)" /> + <Target Name="_CleanTempOutput"> + <MSBuild Projects="$(MSBuildProjectFullPath)" Properties="CleanFolderDirectory=%(TempBuildFolder.Identity);" Targets="_CleanFolder" /> + </Target> + + <Target Name="_CleanAll" DependsOnTargets="_CleanTempOutput"> + <MakeDir Directories="$(BuildTempDirectory)" /> + <MakeDir Directories="$(BuildOutputDirectory)" /> </Target> <!-- ********************************************************************************************** Targets For Build *********************************************************************************************** --> - <Target Name="_BuildSolution"> - <Message Text="Running $(SolutionTarget) $(BuildConfiguration) with $(BuildTools) on $(SolutionFile)" Importance="normal" /> - <MSBuild Targets="$(SolutionTarget)" Projects="$(SolutionFile)" ToolsVersion="$(BuildTools)" - Properties="Configuration=$(BuildConfiguration);Platform=$(Platform);TreatWarningsAsErrors=true;" - /> + <Target Name="_CompileAll"> + <MSBuild Projects="$(MSBuildProjectFullPath)" Properties="SolutionTarget=Rebuild;" Targets="_BuildAllConfigurations" /> </Target> - <Target Name="_Clean"> - <RemoveDir Directories="@(WorkingDirectories)" Condition="Exists(%(WorkingDirectories.Identity))" /> - <MakeDir Directories="@(WorkingDirectories)" /> - - <MSBuild Projects="$(MSBuildProjectFullPath)" Properties="SolutionTarget=Clean;BuildConfiguration=$(BuildConfiguration);Platform=$(Platform);TargetVersion=$(TargetVersion)" Targets="_BuildSolution" ContinueOnError="true" /> + <Target Name="_BuildAllConfigurations"> + <MSBuild Properties="TargetVersion=cf20;Configuration=$(Configuration);Platform=$(Platform);" Targets="$(SolutionTarget)" Projects="$(MSBuildProjectDirectory)\target.csproj" /> + <MSBuild Properties="TargetVersion=cf35;Configuration=$(Configuration);Platform=$(Platform);" Targets="$(SolutionTarget)" Projects="$(MSBuildProjectDirectory)\target.csproj" /> + <MSBuild Properties="TargetVersion=net20;Configuration=$(Configuration);Platform=$(Platform);" Targets="$(SolutionTarget)" Projects="$(MSBuildProjectDirectory)\target.csproj" /> + <MSBuild Properties="TargetVersion=net35;Configuration=$(Configuration);Platform=$(Platform);" Targets="$(SolutionTarget)" Projects="$(MSBuildProjectDirectory)\target.csproj" /> + <MSBuild Properties="TargetVersion=net40;Configuration=$(Configuration);Platform=$(Platform);" Targets="$(SolutionTarget)" Projects="$(MSBuildProjectDirectory)\target.csproj" /> + <MSBuild Properties="TargetVersion=sl20;Configuration=$(Configuration);Platform=$(Platform);" Targets="$(SolutionTarget)" Projects="$(MSBuildProjectDirectory)\target.csproj" /> + <MSBuild Properties="TargetVersion=sl30;Configuration=$(Configuration);Platform=$(Platform);" Targets="$(SolutionTarget)" Projects="$(MSBuildProjectDirectory)\target.csproj" /> + <MSBuild Properties="TargetVersion=sl40;Configuration=$(Configuration);Platform=$(Platform);" Targets="$(SolutionTarget)" Projects="$(MSBuildProjectDirectory)\target.csproj" /> + <MSBuild Properties="TargetVersion=pl40;Configuration=$(Configuration);Platform=$(Platform);" Targets="$(SolutionTarget)" Projects="$(MSBuildProjectDirectory)\target.csproj" /> </Target> - <Target Name="_Compile"> - <MSBuild Projects="$(MSBuildProjectFullPath)" Properties="SolutionTarget=Rebuild;BuildConfiguration=$(BuildConfiguration);Platform=$(Platform);TargetVersion=$(TargetVersion)" Targets="_BuildSolution" /> - </Target> +<!-- ********************************************************************************************** +Targets For Tools +*********************************************************************************************** --> - <Target Name="Requires20"> - <Error Text="Must be run with TargetVersion=NET20" Condition=" '$(TargetVersion)' != 'NET20' " /> - </Target> + <Target Name="_BuildTools"> + + <MSBuild Targets="Build" ToolsVersion="3.5" Projects="$(ProjectDirectory)\src\ProtocolBuffers.sln" Properties="Configuration=Release;Platform=Any CPU;" /> + <Copy SourceFiles="%(ToolsOutputItem.Identity)" DestinationFolder="$(BuildOutputDirectory)\tools" /> - <Target Name="RequiresRelease"> - <Error Text="Must be run with BuildConfiguration=Release" Condition=" '$(BuildConfiguration)' != 'Release' " /> + <Copy SourceFiles="$(LibDirectory)\NUnit-config\nunit-console.v2.0.config" DestinationFiles="$(NUnitExePath).config" /> + <Exec + WorkingDirectory="%(ToolsTestContainer.RootDir)%(ToolsTestContainer.Directory)" + Command=""$(NUnitExePath)" /nologo /noshadow %(ToolsTestContainer.Identity) /xml:$(BuildTempDirectory)\%(ToolsTestContainer.Filename).xml" /> + </Target> - <!-- ********************************************************************************************** +<!-- ********************************************************************************************** Targets For GenerateSource *********************************************************************************************** --> - <Target Name="_BuildProtoGen"> - <MSBuild Targets="Rebuild" ToolsVersion="3.5" - Projects="$(ProjectDirectory)\src\ProtocolBuffers\ProtocolBuffers.csproj;$(ProjectDirectory)\src\ProtoGen\ProtoGen.csproj" - Properties="Step=_BuildProtoGen;Configuration=Release;Platform=AnyCPU;TargetFrameworkVersion=v2.0;DebugType=none;DocumentationFile=;TreatWarningsAsErrors=true;OutputPath=$(BuildOutputDirectory)\ProtoGen;" /> - </Target> - <Target Name="_CleanTempSource"> - <Message Importance="normal" Text="Cleaning source directory $(SourceTempDirectory)"/> - <RemoveDir Directories="$(SourceTempDirectory)" Condition="Exists($(SourceTempDirectory))" /> + <MSBuild Projects="$(MSBuildProjectFullPath)" Properties="CleanFolderDirectory=$(SourceTempDirectory);" Targets="_CleanFolder" /> <MakeDir Directories="$(SourceTempDirectory)" /> </Target> @@ -87,166 +80,38 @@ Targets For GenerateSource </Target> <!-- ********************************************************************************************** -Targets For Test -*********************************************************************************************** --> - - <Target Name="_Test"> - <CallTarget Targets="_RunTests" /> - </Target> - - <Target Name="_RunTests"> - <!-- NUnit --> - <Copy SourceFiles="$(NUnitExeConfig)" DestinationFiles="$(NUnitExePath).config" /> - <Exec Condition="$(BuildConfiguration)=='Debug' or $(BuildConfiguration)=='Release'" - Command=""$(NUnitExePath)" /nologo /noshadow %(TestContainer.Identity) /xml:$(BuildTempDirectory)\%(TestContainer.Filename).xml" /> - <!-- StatLight --> - <Exec Condition="$(BuildConfiguration)=='Debug_Silverlight' or $(BuildConfiguration)=='Release_Silverlight'" - Command=""$(StatLightExePath)" -x %(StatLightTestContainer.Identity) --ReportOutputFileType=NUnit --ReportOutputFile=$(BuildTempDirectory)\%(StatLightTestContainer.Filename).xml" /> - </Target> - -<!-- ********************************************************************************************** Targets For Package *********************************************************************************************** --> - - <Target Name="_CleanOutputDirectory"> - <RemoveDir Directories="$(BuildOutputPackage)" ContinueOnError="true" /> - <RemoveDir Directories="$(BuildOutputDirectory)" ContinueOnError="true" /> - <MakeDir Directories="$(BuildOutputDirectory)" ContinueOnError="true" /> - </Target> - - <Target Name="_PreparePackageComponent"> - <Copy SourceFiles="@(DynamicPackageItem)" DestinationFolder="$(BuildOutputPackage)\$(BuildConfiguration)\$(TargetVersion)\%(DynamicPackageItem.TargetDirectory)\%(DynamicPackageItem.RecursiveDir)" /> + + <Target Name="_PackageAll"> + <MSBuild Projects="$(MSBuildProjectFullPath)" Properties="SolutionTarget=_Publish;" Targets="_BuildAllConfigurations" /> </Target> <Target Name="_GeneratePackage"> <Copy SourceFiles="@(StaticPackageItem)" DestinationFolder="$(BuildOutputPackage)\%(StaticPackageItem.TargetDirectory)\%(StaticPackageItem.RecursiveDir)" /> - <Exec Command=""$(ZipExePath)" a -tzip ..\$(PackageName).zip * -r" WorkingDirectory="$(BuildOutputPackage)" /> + <Exec Command=""$(ZipExePath)" a -tzip ..\$(PackageName)-binaries.zip * -x!*.pdb -r" WorkingDirectory="$(BuildOutputPackage)" /> + <Exec Command=""$(ZipExePath)" a -tzip ..\$(PackageName)-symbols.zip * -r" WorkingDirectory="$(BuildOutputPackage)" /> </Target> - <Target Name="_CompletePackages"> - <ItemGroup> - <ReleasePackageItem Include="$(BuildOutputDirectory)\ProtoGen\*"> - <TargetDirectory>\Protoc</TargetDirectory> - </ReleasePackageItem> - <!-- RELEASE --> - <ReleasePackageItem Include="$(BuildOutputDirectory)\v2.0\Release\*"> - <TargetDirectory>\Release\v2.0</TargetDirectory> - </ReleasePackageItem> - <ReleasePackageItem Include="$(BuildOutputDirectory)\v2.0\Release_Silverlight\*"> - <TargetDirectory>\Release_Silverlight\v2.0</TargetDirectory> - </ReleasePackageItem> - <ReleasePackageItem Include="$(BuildOutputDirectory)\v3.5\Release\*"> - <TargetDirectory>\Release\v3.5</TargetDirectory> - </ReleasePackageItem> - <ReleasePackageItem Include="$(BuildOutputDirectory)\v3.5\Release_Silverlight\*"> - <TargetDirectory>\Release_Silverlight\v3.0</TargetDirectory> - </ReleasePackageItem> - <ReleasePackageItem Include="$(BuildOutputDirectory)\v4.0\Release\*"> - <TargetDirectory>\Release\v4.0</TargetDirectory> - </ReleasePackageItem> - <ReleasePackageItem Include="$(BuildOutputDirectory)\v4.0\Release_Silverlight\*"> - <TargetDirectory>\Release_Silverlight\v4.0</TargetDirectory> - </ReleasePackageItem> - <!-- DEBUG --> - <DebugPackageItem Include="$(BuildOutputDirectory)\v2.0\Debug\*"> - <TargetDirectory>\Debug\v2.0</TargetDirectory> - </DebugPackageItem> - <DebugPackageItem Include="$(BuildOutputDirectory)\v2.0\Debug_Silverlight\*"> - <TargetDirectory>\Debug_Silverlight\v2.0</TargetDirectory> - </DebugPackageItem> - <DebugPackageItem Include="$(BuildOutputDirectory)\v3.5\Debug\*"> - <TargetDirectory>\Debug\v3.5</TargetDirectory> - </DebugPackageItem> - <DebugPackageItem Include="$(BuildOutputDirectory)\v3.5\Debug_Silverlight\*"> - <TargetDirectory>\Debug_Silverlight\v3.0</TargetDirectory> - </DebugPackageItem> - <DebugPackageItem Include="$(BuildOutputDirectory)\v4.0\Debug\*"> - <TargetDirectory>\Debug\v4.0</TargetDirectory> - </DebugPackageItem> - <DebugPackageItem Include="$(BuildOutputDirectory)\v4.0\Debug_Silverlight\*"> - <TargetDirectory>\Debug_Silverlight\v4.0</TargetDirectory> - </DebugPackageItem> - </ItemGroup> - - <RemoveDir Directories="$(BuildOutputDirectory)\Release;$(BuildOutputDirectory)\Full" ContinueOnError="true" /> - <MakeDir Directories="$(BuildOutputDirectory)\Release;$(BuildOutputDirectory)\Full" ContinueOnError="true" /> - - <!-- Copy files for Release --> - <Copy SourceFiles="@(StaticPackageItem)" DestinationFolder="$(BuildOutputDirectory)\Release\%(StaticPackageItem.TargetDirectory)\%(StaticPackageItem.RecursiveDir)" /> - <Copy SourceFiles="@(ReleasePackageItem)" DestinationFolder="$(BuildOutputDirectory)\Release\%(ReleasePackageItem.TargetDirectory)\%(ReleasePackageItem.RecursiveDir)" /> - <Exec Command=""$(ZipExePath)" a -tzip $(BuildOutputDirectory)\release-binaries.zip * -r" WorkingDirectory="$(BuildOutputDirectory)\Release" /> - - <!-- Copy files for Debug --> - <Copy SourceFiles="@(StaticPackageItem)" DestinationFolder="$(BuildOutputDirectory)\Full\%(StaticPackageItem.TargetDirectory)\%(StaticPackageItem.RecursiveDir)" /> - <Copy SourceFiles="@(ReleasePackageItem)" DestinationFolder="$(BuildOutputDirectory)\Full\%(ReleasePackageItem.TargetDirectory)\%(ReleasePackageItem.RecursiveDir)" /> - <Copy SourceFiles="@(DebugPackageItem)" DestinationFolder="$(BuildOutputDirectory)\Full\%(DebugPackageItem.TargetDirectory)\%(DebugPackageItem.RecursiveDir)" /> - <Exec Command=""$(ZipExePath)" a -tzip $(BuildOutputDirectory)\full-binaries.zip * -r" WorkingDirectory="$(BuildOutputDirectory)\Full" /> - - </Target> - <!-- ********************************************************************************************** Targets For Benchmark *********************************************************************************************** --> - <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="$(SourceTempDirectory)" /> - <Exec Command="$(ProtogenExePath) compiled.pb" WorkingDirectory="$(SourceTempDirectory)" /> - </Target> - - <Target Name="_CompileBenchmarkAssemblyInFramework20" Condition=" '$(MSBuildToolsVersion)' != '2.0' "> - <MSBuild Projects="$(MSBuildProjectFullPath)" Properties="SolutionTarget=Rebuild;BuildConfiguration=$(BuildConfiguration);Platform=$(Platform)" - Targets="_CompileBenchmarkAssembly" ToolsVersion="2.0" /> - </Target> - - <Target Name="_CompileBenchmarkAssembly" DependsOnTargets="_GenerateBenchmarkSource"> - <Error Text="Must be run with Framework 2.0" Condition=" '$(MSBuildToolsVersion)' != '2.0' " /> - - <ItemGroup> - <BenchmarkSources Include="$(SourceTempDirectory)\GoogleSizeProtoFile.cs" /> - <BenchmarkSources Include="$(SourceTempDirectory)\GoogleSpeedProtoFile.cs" /> - <BenchmarkSources Include="$(SourceDirectory)\ProtoBench\Properties\AssemblyInfo.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="_CompileBenchmarkAssemblyInFramework20"> - <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)\ProtocolBuffers.Serialization\bin\$(BuildConfiguration)\Google.ProtocolBuffers.Serialization.dll" /> - <BenchmarkResources Include="$(SourceDirectory)\ProtoBench\bin\$(BuildConfiguration)\ProtoBench.exe" /> - </ItemGroup> - - <Copy SourceFiles="@(BenchmarkResources)" DestinationFolder="$(BuildTempDirectory)" /> - </Target> - - <Target Name="_RunBenchmarks" DependsOnTargets="_PrepareBenchmarkEnvironment"> + <Target Name="_RunBenchmarks"> <ItemGroup> - <BenchmarkParameter Include="Google.ProtocolBuffers.ProtoBench.SizeMessage1,BenchmarkTypes" /> + <BenchmarkParameter Include="Google.ProtocolBuffers.ProtoBench.SizeMessage1,ProtoBench" /> <BenchmarkParameter Include="google_message1.dat" /> - <BenchmarkParameter Include="Google.ProtocolBuffers.ProtoBench.SpeedMessage1,BenchmarkTypes" /> + <BenchmarkParameter Include="Google.ProtocolBuffers.ProtoBench.SpeedMessage1,ProtoBench" /> <BenchmarkParameter Include="google_message1.dat" /> - <BenchmarkParameter Include="Google.ProtocolBuffers.ProtoBench.SizeMessage2,BenchmarkTypes" /> + <BenchmarkParameter Include="Google.ProtocolBuffers.ProtoBench.SizeMessage2,ProtoBench" /> <BenchmarkParameter Include="google_message2.dat" /> - <BenchmarkParameter Include="Google.ProtocolBuffers.ProtoBench.SpeedMessage2,BenchmarkTypes" /> + <BenchmarkParameter Include="Google.ProtocolBuffers.ProtoBench.SpeedMessage2,ProtoBench" /> <BenchmarkParameter Include="google_message2.dat" /> </ItemGroup> - <Message Text="Running $(ProtoBenchExePath) from $(BuildTempDirectory)" /> - <Exec Command=""$(ProtoBenchExePath)" $(BenchmarkArgs) @(BenchmarkParameter->'%(Identity)', ' ') "/log:$(BenchmarkOutputFile)"" - WorkingDirectory="$(BuildTempDirectory)" /> + <Message Text="Running ProtoBench.exe" /> + <Exec Command="ProtoBench.exe $(BenchmarkArgs) @(BenchmarkParameter->'%(Identity)', ' ') "/log:$(BenchmarkOutputFile)"" + WorkingDirectory="$(SourceDirectory)\ProtoBench\bin\NET35\Release" /> </Target> |