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

Skip to content

Commit 6993bd8

Browse files
anntzertacaswell
authored andcommitted
CI: Fix FreeType build.
1 parent 21fcf68 commit 6993bd8

File tree

2 files changed

+26
-20
lines changed

2 files changed

+26
-20
lines changed

.flake8

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ exclude =
2828

2929
per-file-ignores =
3030
setup.py: E402
31+
setupext.py: E501
3132

3233
tools/subset.py: E221, E251, E261, E302, E501
3334

setupext.py

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import configparser
2-
from distutils import sysconfig
2+
from distutils import ccompiler, sysconfig
33
from distutils.core import Extension
44
import functools
55
import glob
@@ -569,30 +569,35 @@ def do_custom_build(self):
569569
subprocess.check_call(["make"], env=env, cwd=src_path)
570570
else:
571571
# compilation on windows
572-
shutil.rmtree(pathlib.Path(src_path, "objs"), ignore_errors=True)
573-
import distutils.msvc9compiler as msvc
574-
# FreeType has no build profile for 2014, so we don't bother.
572+
shutil.rmtree(str(pathlib.Path(src_path, "objs")),
573+
ignore_errors=True)
574+
msbuild_platform = (
575+
'x64' if platform.architecture()[0] == '64bit' else 'Win32')
576+
base_path = pathlib.Path("build/freetype-2.6.1/builds/windows")
575577
vc = 'vc2010'
576-
WinXX = 'x64' if platform.architecture()[0] == '64bit' else 'Win32'
577-
xXX = 'x64' if platform.architecture()[0] == '64bit' else 'x86'
578-
vcvarsall = msvc.find_vcvarsall(10.0)
579-
if vcvarsall is None:
580-
raise RuntimeError('Microsoft VS 2010 required')
581-
cmdfile = pathlib.Path("build/build_freetype.cmd")
582-
cmdfile.write_text(fr"""
583-
call "%ProgramFiles%\Microsoft SDKs\Windows\v7.0\Bin\SetEnv.Cmd" ^
584-
/Release /{xXX} /xp
585-
call "{vcvarsall}" {xXX}
586-
set MSBUILD=C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
587-
%MSBUILD% "builds\windows\{vc}\freetype.sln" ^
588-
/t:Clean;Build /p:Configuration="Release";Platform={WinXX}
578+
sln_path = (
579+
base_path / vc / "freetype.sln"
580+
)
581+
# https://developercommunity.visualstudio.com/comments/190992/view.html
582+
(sln_path.parent / "Directory.Build.props").write_text("""
583+
<Project>
584+
<PropertyGroup>
585+
<!-- The following line *cannot* be split over multiple lines. -->
586+
<WindowsTargetPlatformVersion>$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))</WindowsTargetPlatformVersion>
587+
</PropertyGroup>
588+
</Project>
589589
""")
590-
subprocess.check_call([str(cmdfile.resolve())],
591-
shell=True, cwd=src_path)
590+
cc = ccompiler.new_compiler()
591+
cc.initialize() # Get devenv & msbuild in the %PATH% of cc.spawn.
592+
cc.spawn(["devenv", str(sln_path), "/upgrade"])
593+
cc.spawn(["msbuild", str(sln_path),
594+
"/t:Clean;Build",
595+
f"/p:Configuration=Release;Platform={msbuild_platform}"])
592596
# Move to the corresponding Unix build path.
593597
(src_path / "objs" / ".libs").mkdir()
594598
# Be robust against change of FreeType version.
595-
lib_path, = (src_path / "objs" / vc / xXX).glob("freetype*.lib")
599+
lib_path, = (src_path / "objs" / vc / msbuild_platform).glob(
600+
"freetype*.lib")
596601
shutil.copy2(lib_path, src_path / "objs/.libs/libfreetype.lib")
597602

598603

0 commit comments

Comments
 (0)