Previously, the virtual environment was activated in the Proto3 build target. Since the proto3 build target is executed once per proto file, and 91 proto files are processed during the client cs build, this added significant time to the build. For example, on [John's]my laptop, activating the venv takes ~0.15s, which amounts to ~9.55 secs per build.
95 lines
3.7 KiB
XML
95 lines
3.7 KiB
XML
<Project>
|
|
|
|
<Target
|
|
Name="CompileProto2"
|
|
Condition="'@(Proto2)'!=''"
|
|
Inputs="$(MSBuildProjectFile);$(protogen);%(Proto2.FullPath)"
|
|
Outputs="$(GenDir)\proto2\%(Proto2.filename).cs"
|
|
AfterTargets="PreBuildEvent">
|
|
<PropertyGroup>
|
|
<SourceRelativeFile>$([System.String]::Copy('%(proto2.fullpath)').Replace($(SourceRoot), ''))</SourceRelativeFile>
|
|
<SourceRelativeDir>$([System.IO.Path]::GetDirectoryName($(SourceRelativeFile)))</SourceRelativeDir>
|
|
<WorkingDirectory>$(GenDir)\proto2</WorkingDirectory>
|
|
</PropertyGroup>
|
|
<MakeDir Directories="$(WorkingDirectory)" />
|
|
<Copy
|
|
SourceFiles="%(Proto2.FullPath)"
|
|
DestinationFolder="$(WorkingDirectory)"
|
|
SkipUnchangedFiles="True"
|
|
UseHardLinksIfPossible="True" />
|
|
<Error
|
|
Text="protogen.exe does not exist. If you forgot to clone with externals try: git submodule update --init --recursive"
|
|
Condition="!Exists($(protogen))" />
|
|
<Exec
|
|
Command="$(Protogen) %(Proto2.filename)%(proto2.extension) --csharp_out=. -I. -I$(SourceRoot) -I$(Externals)\include"
|
|
WorkingDirectory="$(WorkingDirectory)" />
|
|
<ItemGroup>
|
|
<Compile Include="$(WorkingDirectory)\%(Proto2.filename).cs" />
|
|
</ItemGroup>
|
|
</Target>
|
|
|
|
<!--
|
|
Run this after GetAssemblyVersion because it happens after the Xaml compiler
|
|
and exists in both xaml and non-xaml projects. One of the (many) xaml compile
|
|
passes wipes out the additional compile includes that we add.
|
|
-->
|
|
<Target
|
|
Name="CompileProto3"
|
|
AfterTargets="GetAssemblyVersion"
|
|
Condition="'@(Proto3)'!=''"
|
|
Inputs="$(protoc);
|
|
%(Proto3.Identity);$(ProtocPluginBase)\plugin.py;
|
|
$(ProtocPluginBase)\templates\c#\client.pb.cs;
|
|
$(ProtocPluginBase)\templates\c#\server.pb.cs;
|
|
$(ProtocPluginBase)\templates\c#\immutable.pb.cs;"
|
|
Outputs="%(Proto3.OutCS);%(Proto3.OutCSServer);%(Proto3.OutCSClient);%(Proto3.OutCSImmutable)">
|
|
<MakeDir Directories="%(Proto3.OutBase)" />
|
|
|
|
<Message
|
|
Importance="High"
|
|
Text="Generating service %(Proto3.FileName)" />
|
|
<Exec Command="$(SparkRoot)\.venv\Scripts\activate.bat" />
|
|
<Exec Command="set PYTHONPATH=$(SparkRoot)\.venv\Scripts\python" />
|
|
<Exec
|
|
Command="
|
|
$(protoc) %* %(Proto3.FullPath) ^
|
|
--error_format=msvs ^
|
|
--proto_path=$(SourceRoot) ^
|
|
--plugin="protoc-gen-service=$(ProtocPluginBase)\plugin.cmd" ^
|
|
--service_out=lang=c#,strip_out_path=1:%(Proto3.OutBase) ^
|
|
--csharp_out=%(CompileOptions)%(Proto3.OutBase)"
|
|
WorkingDirectory="%(relativedir)" />
|
|
<ItemGroup>
|
|
<Compile Include="%(Proto3.OutCS)" />
|
|
<Compile Include="%(Proto3.OutCSClient)" />
|
|
<Compile Include="%(Proto3.OutCSServer)" />
|
|
<Compile Include="%(Proto3.OutCSImmutable)" />
|
|
</ItemGroup>
|
|
</Target>
|
|
|
|
<Target Name="RemoveSystemRuntimeFromRefPack"
|
|
BeforeTargets="_HandlePackageFileConflicts"
|
|
Condition="'@(Reference -> WithMetadataValue('NugetPackageId', 'System.Runtime.Experimental'))' != ''">
|
|
<ItemGroup>
|
|
<Reference Remove="@(Reference)"
|
|
Condition="$([System.String]::Copy(%(Reference.Identity)).Contains('System.Runtime.dll')) and
|
|
'%(Reference.NuGetPackageId)' == 'Microsoft.NETCore.App.Ref'" />
|
|
</ItemGroup>
|
|
</Target>
|
|
|
|
<Target
|
|
Name="AfterClean"
|
|
AfterTargets="Clean">
|
|
<Delete Files="%(Proto3.OutCS)" />
|
|
<Delete Files="%(Proto3.OutCSClient)" />
|
|
<Delete Files="%(Proto3.OutCSServer)" />
|
|
<Delete Files="%(Proto3.OutCSImmutable)" />
|
|
<Delete Files="$(GenDir)\proto2\*" />
|
|
</Target>
|
|
|
|
<Target
|
|
Name="Test"
|
|
DependsOnTargets="Build"></Target>
|
|
|
|
</Project>
|