Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/BenchmarkDotNet/BenchmarkDotNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
<ItemGroup>
<EmbeddedResource Include="Templates\*" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
</ItemGroup>
<ItemGroup>
<None Include="BenchmarkDotNet.targets" Pack="true" PackagePath="buildTransitive" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="Gee.External.Capstone" Version="2.3.0" />
Expand Down
31 changes: 31 additions & 0 deletions src/BenchmarkDotNet/BenchmarkDotNet.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Project>
<PropertyGroup>
<!-- If the RuntimeIdentifier is explicitly specified, use the specified target platform. -->
<BenchmarkDotNetTargetPlatform Condition="'$(BenchmarkDotNetTargetPlatform)' == ''">$(RuntimeIdentifier)</BenchmarkDotNetTargetPlatform>

<!-- Otherwise, try to use current build platform -->
<!-- See: List of runtimes supported by Gee.External.Capstone: https://github.com/9ee1/Capstone.NET/tree/master/Gee.External.Capstone/runtimes -->
<!-- linux-x86 is excluded. Because .NET SDK don't support x86. -->
<BenchmarkDotNetTargetPlatform Condition="'$(BenchmarkDotNetTargetPlatform)' == '' AND $([MSBuild]::IsOSPlatform('Linux')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X64'">linux-x64</BenchmarkDotNetTargetPlatform>
<BenchmarkDotNetTargetPlatform Condition="'$(BenchmarkDotNetTargetPlatform)' == '' AND $([MSBuild]::IsOSPlatform('Linux')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm64'">linux-arm64</BenchmarkDotNetTargetPlatform>
<BenchmarkDotNetTargetPlatform Condition="'$(BenchmarkDotNetTargetPlatform)' == '' AND $([MSBuild]::IsOSPlatform('Windows')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X86'">win-x86</BenchmarkDotNetTargetPlatform>
<BenchmarkDotNetTargetPlatform Condition="'$(BenchmarkDotNetTargetPlatform)' == '' AND $([MSBuild]::IsOSPlatform('Windows')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X64'">win-x64</BenchmarkDotNetTargetPlatform>
<BenchmarkDotNetTargetPlatform Condition="'$(BenchmarkDotNetTargetPlatform)' == '' AND $([MSBuild]::IsOSPlatform('Windows')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm64'">win-arm64</BenchmarkDotNetTargetPlatform>
<BenchmarkDotNetTargetPlatform Condition="'$(BenchmarkDotNetTargetPlatform)' == '' AND $([MSBuild]::IsOSPlatform('OSX')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'X64'">osx-x64</BenchmarkDotNetTargetPlatform>
<BenchmarkDotNetTargetPlatform Condition="'$(BenchmarkDotNetTargetPlatform)' == '' AND $([MSBuild]::IsOSPlatform('OSX')) AND '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm64'">osx-arm64</BenchmarkDotNetTargetPlatform>
</PropertyGroup>

<Target Name="FilterBenchmarkDotNetPackageAssets" AfterTargets="ResolvePackageAssets">
<!-- Remove `runtimes/{RuntimeIdentifier}` files that is not matched to target platform. -->
<ItemGroup Condition="'$(BenchmarkDotNetTargetPlatform)' != '' AND $(BenchmarkDotNetTargetPlatform) != 'all'">
<RuntimeTargetsCopyLocalItems Remove="@(RuntimeTargetsCopyLocalItems)"
Condition="'%(RuntimeTargetsCopyLocalItems.NuGetPackageId)' == 'Gee.External.Capstone' AND '%(RuntimeTargetsCopyLocalItems.RuntimeIdentifier)' != '$(BenchmarkDotNetTargetPlatform)'" />
</ItemGroup>

<!-- Remove unnecessary satellite assemblies. -->
<ItemGroup>
<ResourceCopyLocalItems Remove="@(ResourceCopyLocalItems)"
Condition="'%(ResourceCopyLocalItems.NuGetPackageId)' == 'Microsoft.CodeAnalysis.Common' OR '%(ResourceCopyLocalItems.NuGetPackageId)' == 'Microsoft.CodeAnalysis.CSharp'"/>
</ItemGroup>
</Target>
</Project>