Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 36a3a3f

Browse files
authored
Merge pull request #16401 from Kojoley/bld-autodetect-platform-toolset-version
BLD: Auto-detect PlatformToolset
2 parents 0358ab8 + 2aee9f8 commit 36a3a3f

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

setupext.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,9 +561,22 @@ def do_custom_build(self):
561561
</PropertyGroup>
562562
</Project>
563563
""")
564+
# It is not a trivial task to determine PlatformToolset to plug it
565+
# into msbuild command, and Directory.Build.props will not override
566+
# the value in the project file.
567+
# The DefaultPlatformToolset is from Microsoft.Cpp.Default.props
568+
with open(base_path / vc / "freetype.vcxproj", 'r+b') as f:
569+
toolset_repl = b'PlatformToolset>$(DefaultPlatformToolset)<'
570+
vcxproj = f.read().replace(b'PlatformToolset>v100<',
571+
toolset_repl)
572+
assert toolset_repl in vcxproj, (
573+
'Upgrading Freetype might break this')
574+
f.seek(0)
575+
f.truncate()
576+
f.write(vcxproj)
577+
564578
cc = ccompiler.new_compiler()
565-
cc.initialize() # Get devenv & msbuild in the %PATH% of cc.spawn.
566-
cc.spawn(["devenv", str(sln_path), "/upgrade"])
579+
cc.initialize() # Get msbuild in the %PATH% of cc.spawn.
567580
cc.spawn(["msbuild", str(sln_path),
568581
"/t:Clean;Build",
569582
f"/p:Configuration=Release;Platform={msbuild_platform}"])

0 commit comments

Comments
 (0)