Skip to content

Commit

Permalink
Add build suffix to Windows CI
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-drexler committed Nov 18, 2023
1 parent 48f7bb5 commit 6b0f256
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/windows_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ jobs:
run: |
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$msbuild = & "$vswhere" -latest -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe | select-object -first 1
$buildsuffix = & "Windows\VisualStudio\print_build_suffix.bat"
$options = @( `
'-property:Configuration=Release', `
'-property:Platform=${{ matrix.platform }}', `
'-property:ForceImportBeforeCppTargets=Windows\VisualStudio\custom_build.props', `
'-property:VER_SUFFIX=$gitsuffix', `
'-maxcpucount', `
'-verbosity:minimal' `
)
Expand Down
12 changes: 12 additions & 0 deletions Windows/VisualStudio/custom_build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemDefinitionGroup Condition="'$(VER_SUFFIX)' != ''">
<ClCompile>
<AdditionalOptions>/DIRONWAIL_VER_SUFFIX=\&quot;$(VER_SUFFIX)\&quot; %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
</ItemDefinitionGroup>
<PropertyGroup Condition="'$(BUILD_DIR)' != ''">
<OutDir>$(SolutionDir)$(BUILD_DIR)\</OutDir>
<IntDir>$(BUILD_DIR)\Out\</IntDir>
</PropertyGroup>
</Project>
10 changes: 10 additions & 0 deletions Windows/VisualStudio/print_build_suffix.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@echo off
::Print build suffix (either -hash or -branch-hash)

for /f %%f in ('git describe --always') do set gitrev=%%f
for /f %%f in ('git branch --show-current') do set gitbranch=%%f
if /i "%gitbranch%" == "master" (
echo -%gitrev%
) else (
echo -%gitbranch%-%gitrev%
)

0 comments on commit 6b0f256

Please sign in to comment.