From 2aee9f80a0e9f2c9e09d3fe5dc86be35dd44323b Mon Sep 17 00:00:00 2001 From: Nikita Kniazev Date: Mon, 3 Feb 2020 20:34:50 +0300 Subject: [PATCH] BLD: Auto-detect PlatformToolset Instead of using `devenv` (which may be not installed (it is IDE part) or the latest compiler were installed without IDE) modify the project file and change `PlatformToolset` to pick the default version. --- setupext.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/setupext.py b/setupext.py index b472a92871f1..007fae6663fa 100644 --- a/setupext.py +++ b/setupext.py @@ -561,9 +561,22 @@ def do_custom_build(self): """) + # It is not a trivial task to determine PlatformToolset to plug it + # into msbuild command, and Directory.Build.props will not override + # the value in the project file. + # The DefaultPlatformToolset is from Microsoft.Cpp.Default.props + with open(base_path / vc / "freetype.vcxproj", 'r+b') as f: + toolset_repl = b'PlatformToolset>$(DefaultPlatformToolset)<' + vcxproj = f.read().replace(b'PlatformToolset>v100<', + toolset_repl) + assert toolset_repl in vcxproj, ( + 'Upgrading Freetype might break this') + f.seek(0) + f.truncate() + f.write(vcxproj) + cc = ccompiler.new_compiler() - cc.initialize() # Get devenv & msbuild in the %PATH% of cc.spawn. - cc.spawn(["devenv", str(sln_path), "/upgrade"]) + cc.initialize() # Get msbuild in the %PATH% of cc.spawn. cc.spawn(["msbuild", str(sln_path), "/t:Clean;Build", f"/p:Configuration=Release;Platform={msbuild_platform}"])