Files
spark/src/Directory.Build.targets
T
John Colvin 931c681174 fix build (DataStreamSuite): Change path sep to '\' in Build.targets
Csharp protobuf generation was failing, albeit inconsistently, with a
mysterious error message about normalizing relative/absolute paths.
2023-09-29 13:10:50 -04:00

166 lines
7.1 KiB
XML

<Project>
<!--
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="CompileProtos"
AfterTargets="GetAssemblyVersion"
Condition="'@(Proto)'!=''"
Inputs="$(protoc);
%(Proto.Identity);$(ProtocPluginBase)\plugin.py;
$(ProtocPluginBase)\templates\c#\immutable.pb.cs;"
Outputs="
%(Proto.OutDir)\%(Proto.CSName).cs;
%(Proto.OutDir)\%(Proto.FileName).immutable.pb.cs">
<MakeDir Directories="%(Proto.OutDir)" />
<Message
Importance="High"
Text="Generating Proto %(Proto.FileName)" />
<PropertyGroup>
<GenProtosCmd>$(protoc) %(Proto.FullPath)</GenProtosCmd>
<GenProtosCmd>$(GenProtosCmd) --error_format=msvs</GenProtosCmd>
<GenProtosCmd>$(GenProtosCmd) --proto_path=$(SourceRoot)</GenProtosCmd>
<GenProtosCmd>$(GenProtosCmd) --plugin=&quot;protoc-gen-spark-csharp=$(ProtocPlugin)&quot;</GenProtosCmd>
<GenProtosCmd>$(GenProtosCmd) --spark-csharp_out=lang=c#,templates=immutable.pb.cs,strip_out_path=1:%(Proto.OutDir)</GenProtosCmd>
<GenProtosCmd>$(GenProtosCmd) --csharp_out=%(Proto.OutDir)</GenProtosCmd>
</PropertyGroup>
<Exec Command="$(GenProtosCmd)" WorkingDirectory="%(Proto.RelativeDir)" />
<ItemGroup>
<Compile Include="%(Proto.OutDir)\%(Proto.CSName).cs" />
<Compile Include="%(Proto.OutDir)\%(Proto.FileName).immutable.pb.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="CompileProtoServices"
AfterTargets="GetAssemblyVersion"
Condition="'@(ProtoService)'!=''"
Inputs="$(protoc);
%(ProtoService.Identity);$(ProtocPluginBase)\plugin.py;
$(ProtocPluginBase)\templates\c#\client.pb.cs;
$(ProtocPluginBase)\templates\c#\server.pb.cs;
$(ProtocPluginBase)\templates\c#\immutable.pb.cs;"
Outputs="
%(ProtoService.OutDir)\%(ProtoService.CSName).cs;
%(ProtoService.OutDir)\%(ProtoService.FileName).client.pb.cs;
%(ProtoService.OutDir)\%(ProtoService.FileName).server.pb.cs;
%(ProtoService.OutDir)\%(ProtoService.FileName).immutable.pb.cs">
<MakeDir Directories="%(ProtoService.OutDir)" />
<Message
Importance="High"
Text="Generating ProtoService %(ProtoService.FileName)" />
<PropertyGroup>
<GenProtosCmd>$(protoc) %(ProtoService.FullPath)</GenProtosCmd>
<GenProtosCmd>$(GenProtosCmd) --error_format=msvs</GenProtosCmd>
<GenProtosCmd>$(GenProtosCmd) --proto_path=$(SourceRoot)</GenProtosCmd>
<GenProtosCmd>$(GenProtosCmd) --plugin=&quot;protoc-gen-service=$(ProtocPlugin)&quot;</GenProtosCmd>
<GenProtosCmd>$(GenProtosCmd) --service_out=lang=c#,strip_out_path=1:%(ProtoService.OutDir)</GenProtosCmd>
<GenProtosCmd>$(GenProtosCmd) --csharp_out=%(ProtoService.OutDir)</GenProtosCmd>
</PropertyGroup>
<Exec Command="$(GenProtosCmd)" WorkingDirectory="%(ProtoService.RelativeDir)" />
<ItemGroup>
<Compile Include="%(ProtoService.OutDir)\%(ProtoService.CSName).cs" />
<Compile Include="%(ProtoService.OutDir)\%(ProtoService.FileName).client.pb.cs" />
<Compile Include="%(ProtoService.OutDir)\%(ProtoService.FileName).server.pb.cs" />
<Compile Include="%(ProtoService.OutDir)\%(ProtoService.FileName).immutable.pb.cs" />
</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="GenerateScanners"
BeforeTargets="BeforeBuild"
Condition="'@(Scanner)'!=''"
Outputs="%(Scanner.RelativeOutputDir)\%(Scanner.FileName).Scanner.g.cs">
<Message Text="Generating Scanner %(Scanner.Identity)" Importance="High" />
<ItemGroup>
<LexFile Include="%(Scanner.Identity)">
<OutputFile>$([MSBuild]::MakeRelative(%(Scanner.RootDir)%(Scanner.Directory), $(ScannerOutputPath)))\%(Scanner.FileName).Scanner.g.cs</OutputFile>
</LexFile>
<Compile Include="$([MSBuild]::MakeRelative(%(Scanner.RootDir)%(Scanner.Directory), $(ScannerOutputPath)))\%(Scanner.FileName).Scanner.g.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>%(Scanner.Identity)</DependentUpon>
</Compile>
</ItemGroup>
</Target>
<Target
Name="GenerateParsers"
BeforeTargets="BeforeBuild"
AfterTargets="GenerateScanners"
Condition="'@(Parser)'!=''"
Outputs="%(Parser.RelativeOutputDir)\%(Parser.FileName).Parser.g.cs">
<Message
Text="Generating Parser %(Parser.Identity)"
Importance="High" />
<ItemGroup>
<YaccFile Include="%(Parser.Identity)">
<OutputFile>$([MSBuild]::MakeRelative(%(Parser.RootDir)%(Parser.Directory),
$(ParserOutputPath)))\%(Parser.FileName).Parser.g.cs</OutputFile>
<Arguments>/gplex /nolines</Arguments>
</YaccFile>
<Compile Include="$([MSBuild]::MakeRelative(%(Parser.RootDir)%(Parser.Directory), $(ParserOutputPath)))\%(Parser.FileName).Parser.g.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>%(Parser.Identity)</DependentUpon>
</Compile>
</ItemGroup>
</Target>
<Target
Name="CleanProtos"
AfterTargets="Clean">
<Delete Files="%(Proto.OutDir)\%(Proto.CSName).cs" />
<Delete Files="%(Proto.OutDir)\%(Proto.FileName).client.pb.cs" />
<Delete Files="%(Proto.OutDir)\%(Proto.FileName).server.pb.cs" />
<Delete Files="%(Proto.OutDir)\%(Proto.FileName).immutable.pb.cs" />
<Delete Files="%(ProtoService.OutDir)\%(ProtoService.CSName).cs" />
<Delete Files="%(ProtoService.OutDir)\%(ProtoService.FileName).client.pb.cs" />
<Delete Files="%(ProtoService.OutDir)\%(ProtoService.FileName).server.pb.cs" />
<Delete Files="%(ProtoService.OutDir)\%(ProtoService.FileName).immutable.pb.cs" />
</Target>
<Target
Name="CleanScanners"
AfterTargets="Clean"
Condition="'@(Scanner)'!=''">
<Delete Files="$([MSBuild]::MakeRelative(%(Scanner.RootDir)%(Scanner.Directory), $(ScannerOutputPath)))\%(Scanner.FileName).Scanner.g.cs" />
</Target>
<Target
Name="CleanParsers"
AfterTargets="Clean"
Condition="'@(Parser)'!=''">
<Delete Files="$([MSBuild]::MakeRelative(%(Parser.RootDir)%(Parser.Directory), $(ParserOutputPath)))\%(Parser.FileName).Parser.g.cs" />
</Target>
<Target
Name="Test"
DependsOnTargets="Build"></Target>
</Project>