Skip to content

Commit

Permalink
Fix building with MSVC 14.4
Browse files Browse the repository at this point in the history
  • Loading branch information
jimporter committed Jul 2, 2024
1 parent f0ad994 commit 2618b05
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
include:
- {os: ubuntu-latest, extra-tests: [mingw-cross],
backends: [ninja, make], flags: -Wall -Werror}
- {os: windows-latest, msvc-version: '14.3', win-sdk: '10.0.20348.0',
- {os: windows-latest, msvc-version: '14.4', win-sdk: '10.0.20348.0',
boost-version: '1.80.0', qt-version: '5.15.2',
skipped-tests: [fortran, objc, scala],
backends: [ninja, make, msbuild], flags: /WX}
Expand Down Expand Up @@ -66,21 +66,21 @@ jobs:

# VS 2022 x86 builds
- {os: windows-latest, python-version: '3.11', compiler: default-x86,
msvc-version: '14.3', msvc-arch: 'x86', win-sdk: '10.0.20348.0',
msvc-version: '14.4', msvc-arch: 'x86', win-sdk: '10.0.20348.0',
boost-version: '1.80.0', skipped-tests: [fortran, objc, qt, scala],
backends: [ninja, make, msbuild], flags: /WX}

# VS 2022 clang-cl builds
- {os: windows-latest, python-version: '3.11', compiler: clang-cl,
msvc-version: '14.3', win-sdk: '10.0.20348.0',
msvc-version: '14.4', win-sdk: '10.0.20348.0',
boost-version: '1.80.0', qt-version: '5.15.2',
skipped-tests: [boost, fortran, objc, scala],
backends: [ninja, make], flags: /WX -Wno-microsoft-include
-Wno-unused-command-line-argument -D_CRT_SECURE_NO_WARNINGS}

# MinGW builds
- {os: windows-latest, python-version: '3.11', compiler: mingw,
msvc-version: '14.3', win-sdk: '10.0.20348.0',
msvc-version: '14.4', win-sdk: '10.0.20348.0',
qt-version: '5.15.2', qt-arch: 'win64_mingw81',
skipped-tests: [boost, fortran, objc, pch, scala],
backends: [ninja, make], flags: -Wall -Werror}
Expand Down Expand Up @@ -133,7 +133,7 @@ jobs:
if: startsWith(matrix.os, 'windows-') && matrix.boost-version
run: |
${boostroot} = "C:\boost-${{ matrix.boost-version }}"
${msvcver} = "${{ matrix.msvc-version }}" -replace '(\d+\.\d).*','$1'
${msvcver} = "${{ matrix.msvc-version }}" -replace '14.4','14.3'
${arch} = if ("${{ matrix.msvc-arch }}" -eq "x86") {"32"} else {"64"}
if ("${{ steps.cache-boost.outputs.cache-hit }}" -ne "true" ) {
${boost_ver} = "${{ matrix.boost-version }}" -replace '\.','_'
Expand Down Expand Up @@ -190,7 +190,7 @@ jobs:
7z x -y libogg-1.3.5.zip
${arch} = "${{ matrix.msvc-arch || 'x64' }}"
if(${arch} -eq 'x86') { ${arch} = "Win32" }
${toolset} = "${{ matrix.msvc-version }}" -replace '(\d+)\.(\d).*','$1$2'
${toolset} = "${{ matrix.msvc-version }}" -replace '14.4','14.3' -replace '(\d+)\.(\d+).*','$1$2'
msbuild libogg-1.3.5\win32\VS2015\libogg.sln /p:Configuration=ReleaseDLL /p:Platform=${arch} /p:PlatformToolset=v${toolset} /p:WindowsTargetPlatformVersion=${{ matrix.win-sdk }}
mkdir lib
${liboggbase} = "libogg-1.3.5\win32\VS2015\${arch}\ReleaseDLL"
Expand Down
21 changes: 17 additions & 4 deletions bfg9000/backends/msbuild/syntax.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import ntpath
import os
import re
from collections import defaultdict
from enum import Enum
from itertools import chain
Expand Down Expand Up @@ -170,6 +171,12 @@ class VcxProject(Project):
'dynamic-debug': 'MultiThreadedDebugDLL',
}

# By default, toolsets map the compiler version from MM.N to vMMN, but 14.4
# breaks that convention.
_toolsets = {
'14.4': 'v143',
}

def __init__(self, env, name, mode='Application', configuration=None,
output_file=None, files=None, objs=None, compile_options=None,
link_options=None, dependencies=None):
Expand All @@ -181,11 +188,17 @@ def __init__(self, env, name, mode='Application', configuration=None,
self.compile_options = compile_options or {}
self.link_options = link_options or {}

version = env.getvar(
'VSCMD_ARG_VCVARS_VER',
env.getvar('VCTOOLSVERSION', self.version)
version = env.getvar('VSCMD_ARG_VCVARS_VER')
if version is None:
m = re.match('(\d+\.\d)', env.getvar('VCTOOLSVERSION',
self.version))
if not m:
raise ValueError('unable to guess toolset version; ' +
'run from a Visual Studio prompt?')
version = m.group(1)
self.toolset = self._toolsets.get(
version, 'v' + version.replace('.', '')
)
self.toolset = 'v' + version.replace('.', '')[0:3]

self.windows_sdk = (env.getvar('WINDOWSSDKVERSION', '')
.replace('\\', '') or None)
Expand Down

0 comments on commit 2618b05

Please sign in to comment.