Skip to content

Commit 2afeec7

Browse files
authored
Merge pull request #11248 from anntzer/freetype-windows
Simplify FreeType Windows build.
2 parents 145f35e + ff2d796 commit 2afeec7

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

setup_external_compile.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def zip_extract(zip_file, target):
5353
X64 = platform.architecture()[0] == '64bit'
5454
PYVER = sys.version_info[:2]
5555
VS2010 = PYVER >= (3, 3)
56+
xXX = 'x64' if X64 else 'x86'
5657
# If not VS2010, then use VS2008
5758

5859
VCVARSALL = None
@@ -68,4 +69,4 @@ def prepare_build_cmd(build_cmd, **kwargs):
6869
VCVARSALL = candidate
6970

7071
return build_cmd.format(
71-
vcvarsall=VCVARSALL, xXX='x64' if X64 else 'x86', **kwargs)
72+
vcvarsall=VCVARSALL, xXX=xXX, **kwargs)

setupext.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,23 +1124,15 @@ def do_custom_build(self):
11241124
subprocess.check_call(["make"], env=env, cwd=src_path)
11251125
else:
11261126
# compilation on windows
1127-
FREETYPE_BUILD_CMD = """\
1128-
call "%ProgramFiles%\\Microsoft SDKs\\Windows\\v7.0\\Bin\\SetEnv.Cmd" /Release /{xXX} /xp
1127+
FREETYPE_BUILD_CMD = r"""
1128+
call "%ProgramFiles%\Microsoft SDKs\Windows\v7.0\Bin\SetEnv.Cmd" ^
1129+
/Release /{xXX} /xp
11291130
call "{vcvarsall}" {xXX}
1130-
set MSBUILD=C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\MSBuild.exe
1131-
rd /S /Q %FREETYPE%\\objs
1132-
%MSBUILD% %FREETYPE%\\builds\\windows\\{vc20xx}\\freetype.sln /t:Clean;Build /p:Configuration="{config}";Platform={WinXX}
1133-
echo Build completed, moving result"
1134-
:: move to the "normal" path for the unix builds...
1135-
mkdir %FREETYPE%\\objs\\.libs
1136-
:: REMINDER: fix when changing the version
1137-
copy %FREETYPE%\\objs\\{vc20xx}\\{xXX}\\freetype261.lib %FREETYPE%\\objs\\.libs\\libfreetype.lib
1138-
if errorlevel 1 (
1139-
rem This is a py27 version, which has a different location for the lib file :-/
1140-
copy %FREETYPE%\\objs\\win32\\{vc20xx}\\freetype261.lib %FREETYPE%\\objs\\.libs\\libfreetype.lib
1141-
)
1131+
set MSBUILD=C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
1132+
%MSBUILD% "builds\windows\{vc20xx}\freetype.sln" ^
1133+
/t:Clean;Build /p:Configuration="{config}";Platform={WinXX}
11421134
"""
1143-
from setup_external_compile import fixproj, prepare_build_cmd, VS2010, X64
1135+
from setup_external_compile import fixproj, prepare_build_cmd, VS2010, X64, xXX
11441136
# Note: freetype has no build profile for 2014, so we don't bother...
11451137
vc = 'vc2010' if VS2010 else 'vc2008'
11461138
WinXX = 'x64' if X64 else 'Win32'
@@ -1149,13 +1141,21 @@ def do_custom_build(self):
11491141
fixproj(os.path.join(src_path, 'builds', 'windows', vc, 'freetype.sln'), WinXX)
11501142
fixproj(os.path.join(src_path, 'builds', 'windows', vc, 'freetype.vcproj'), WinXX)
11511143

1152-
cmdfile = os.path.join("build", 'build_freetype.cmd')
1144+
cmdfile = os.path.join("build", "build_freetype.cmd")
11531145
with open(cmdfile, 'w') as cmd:
11541146
cmd.write(prepare_build_cmd(FREETYPE_BUILD_CMD, vc20xx=vc, WinXX=WinXX,
11551147
config='Release' if VS2010 else 'LIB Release'))
11561148

1157-
os.environ['FREETYPE'] = src_path
1158-
subprocess.check_call([cmdfile], shell=True)
1149+
shutil.rmtree(str(Path(src_path, "objs")), ignore_errors=True)
1150+
subprocess.check_call([os.path.abspath(cmdfile)],
1151+
shell=True, cwd=src_path)
1152+
# Move to the corresponding Unix build path.
1153+
Path(src_path, "objs/.libs").mkdir()
1154+
# Be robust against change of FreeType version.
1155+
lib_path, = (Path(src_path, "objs", vc, xXX)
1156+
.glob("freetype*.lib"))
1157+
shutil.copy2(str(lib_path),
1158+
str(Path(src_path, "objs/.libs/libfreetype.lib")))
11591159

11601160

11611161
class FT2Font(SetupPackage):

0 commit comments

Comments
 (0)