8000 Simplify FreeType Windows build. · matplotlib/matplotlib@ff2d796 · GitHub
[go: up one dir, main page]

Skip to content

Commit ff2d796

Browse files
committed
Simplify FreeType Windows build.
- Make FREETYPE_BUILD_CMD a raw string to avoid doubling all backslashes. - Line-wrap two overly long lines in FREETYPE_BUILD_CMD. - Move the `rd /S /Q %FREETYPE%\objs` to python (`shutil.rmtree`). - Move the `copy %FREETYPE\objs\...` to python (`shutil.copy2`). - Get rid of the Py27 part (`if errorlevel 1 ...`). - Run the FREETYPE_BUILD_CMD script with `src_path` as cwd, which avoids the need to define the %FREETYPE% environment variable.
1 parent 84a03e1 commit ff2d796

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
@@ -1122,23 +1122,15 @@ def do_custom_build(self):
11221122
subprocess.check_call(["make"], env=env, cwd=src_path)
11231123
else:
11241124
# compilation on windows
1125-
FREETYPE_BUILD_CMD = """\
1126-
call "%ProgramFiles%\\Microsoft SDKs\\Windows\\v7.0\\Bin\\SetEnv.Cmd" /Release /{xXX} /xp
1125+
FREETYPE_BUILD_CMD = r"""
1126+
call "%ProgramFiles%\Microsoft SDKs\Windows\v7.0\Bin\SetEnv.Cmd" ^
1127+
/Release /{xXX} /xp
11271128
call "{vcvarsall}" {xXX}
1128-
set MSBUILD=C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\MSBuild.exe
1129-
< 10000 span class=pl-s>rd /S /Q %FREETYPE%\\objs
1130-
%MSBUILD% %FREETYPE%\\builds\\windows\\{vc20xx}\\freetype.sln /t:Clean;Build /p:Configuration="{config}";Platform={WinXX}
1131-
echo Build completed, moving result"
1132-
:: move to the "normal" path for the unix builds...
1133-
mkdir %FREETYPE%\\objs\\.libs
1134-
:: REMINDER: fix when changing the version
1135-
copy %FREETYPE%\\objs\\{vc20xx}\\{xXX}\\freetype261.lib %FREETYPE%\\objs\\.libs\\libfreetype.lib
1136-
if errorlevel 1 (
1137-
rem This is a py27 version, which has a different location for the lib file :-/
1138-
copy %FREETYPE%\\objs\\win32\\{vc20xx}\\freetype261.lib %FREETYPE%\\objs\\.libs\\libfreetype.lib
1139-
)
1129+
set MSBUILD=C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
1130+
%MSBUILD% "builds\windows\{vc20xx}\freetype.sln" ^
1131+
/t:Clean;Build /p:Configuration="{config}";Platform={WinXX}
11401132
"""
1141-
from setup_external_compile import fixproj, prepare_build_cmd, VS2010, X64
1133+
from setup_external_compile import fixproj, prepare_build_cmd, VS2010, X64, xXX
11421134
# Note: freetype has no build profile for 2014, so we don't bother...
11431135
vc = 'vc2010' if VS2010 else 'vc2008'
11441136
WinXX = 'x64' if X64 else 'Win32'
@@ -1147,13 +1139,21 @@ def do_custom_build(self):
11471139
fixproj(os.path.join(src_path, 'builds', 'windows', vc, 'freetype.sln'), WinXX)
11481140
fixproj(os.path.join(src_path, 'builds', 'windows', vc, 'freetype.vcproj'), WinXX)
11491141

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

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

11581158

11591159
class FT2Font(SetupPackage):

0 commit comments

Comments
 (0)
0