Skip to content

Commit

Permalink
Merge pull request #542 from Sergio0694/dev/swapchain-cli-options
Browse files Browse the repository at this point in the history
Add more MSBuild options to DX12 CLI sample
  • Loading branch information
Sergio0694 authored Jul 12, 2023
2 parents 1d6fdb1 + e4fc9cd commit 1e64927
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
34 changes: 31 additions & 3 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ jobs:
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.1

# Publish the NativeAOT CLI sample
# Publish the NativeAOT CLI sample (optimized for speed)
- name: Publish ComputeSharp.SwapChain.Cli with NativeAOT
run: >
$env:COMPUTESHARP_SWAPCHAIN_CLI_PUBLISH_AOT='true';
Expand All @@ -244,13 +244,41 @@ jobs:
$process.CloseMainWindow() | Out-Null;
$process.WaitForExit();
$process.ExitCode
# Upload the binary (to track binary size trends)
- if: matrix.platform == 'x64'
name: Upload NativeAOT CLI sample
uses: actions/upload-artifact@v3
with:
name: computesharp.cli.exe
name: computesharp.cli.opt-speed.exe
path: samples\ComputeSharp.SwapChain.Cli\bin\Release\net7.0\win-x64\publish\computesharp.cli.exe
if-no-files-found: error

# Publish the NativeAOT CLI sample (optimized for size, and reflection-free)
- name: Publish ComputeSharp.SwapChain.Cli with NativeAOT
run: >
$env:COMPUTESHARP_SWAPCHAIN_CLI_PUBLISH_AOT='true';
$env:COMPUTESHARP_SWAPCHAIN_CLI_SIZE_OPTIMIZED='true';
$env:COMPUTESHARP_SWAPCHAIN_CLI_DISABLE_REFLECTION='true';
git clean -fdx;
dotnet publish samples\ComputeSharp.SwapChain.Cli\ComputeSharp.SwapChain.Cli.csproj -c Release -f net7.0 -r win-${{matrix.platform}} -v n
# Again only on x64, also run the sample and validate it works correctly
- if: matrix.platform == 'x64'
name: Run ComputeSharp.SwapChain.Cli
run: >
$process = (Start-Process samples\ComputeSharp.SwapChain.Cli\bin\Release\net7.0\win-x64\publish\computesharp.cli.exe -PassThru);
sleep -Seconds 2;
$process.CloseMainWindow() | Out-Null;
$process.WaitForExit();
$process.ExitCode
# Upload the binary again (with a different name)
- if: matrix.platform == 'x64'
name: Upload NativeAOT CLI sample
uses: actions/upload-artifact@v3
with:
name: computesharp.cli.opt-size.exe
path: samples\ComputeSharp.SwapChain.Cli\bin\Release\net7.0\win-x64\publish\computesharp.cli.exe
if-no-files-found: error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
<DefineConstants>$(DefineConstants);SAMPLE_APP</DefineConstants>
<NoWarn>$(NoWarn);CA1416</NoWarn>
<AssemblyName>computesharp.cli</AssemblyName>
<ApplicationIcon>..\..\assets\icon.ico</ApplicationIcon>

<!-- When explicitly optimizing for size, strip the icon (which adds about 100 KB of binary size) -->
<ApplicationIcon Condition="'$(COMPUTESHARP_SWAPCHAIN_CLI_SIZE_OPTIMIZED)' != 'true'">..\..\assets\icon.ico</ApplicationIcon>
</PropertyGroup>

<!--
Expand All @@ -30,8 +32,9 @@
<InvariantGlobalization>true</InvariantGlobalization>
<IlcFoldIdenticalMethodBodies>true</IlcFoldIdenticalMethodBodies>
<IlcGenerateStackTraceData>false</IlcGenerateStackTraceData>
<IlcDisableReflection>true</IlcDisableReflection>
<IlcOptimizationPreference>Speed</IlcOptimizationPreference>
<IlcDisableReflection Condition="'$(COMPUTESHARP_SWAPCHAIN_CLI_DISABLE_REFLECTION)' == 'true'">true</IlcDisableReflection>
<IlcOptimizationPreference Condition="'$(COMPUTESHARP_SWAPCHAIN_CLI_SIZE_OPTIMIZED)' == 'true'">Size</IlcOptimizationPreference>
<IlcOptimizationPreference Condition="'$(COMPUTESHARP_SWAPCHAIN_CLI_SIZE_OPTIMIZED)' != 'true'">Speed</IlcOptimizationPreference>
</PropertyGroup>

<!--
Expand Down

0 comments on commit 1e64927

Please sign in to comment.