Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c75a030

Browse filesBrowse 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 126113f commit c75a030
Copy full SHA for c75a030

File tree

Expand file treeCollapse file tree

1 file changed

+19
-16
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+19
-16
lines changed

‎setupext.py

Copy file name to clipboardExpand all lines: setupext.py
+19-16Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,8 @@ def add_flags(self, ext):
10291029
ext.define_macros.append(('FREETYPE_BUILD_TYPE', 'system'))
10301030

10311031
def do_custom_build(self):
1032+
from pathlib import Path
1033+
10321034
# We're using a system freetype
10331035
if not options.get('local_freetype'):
10341036
return
@@ -1122,21 +1124,13 @@ def do_custom_build(self):
11221124
[cflags + 'make'], shell=True, cwd=src_path)
11231125
else:
11241126
# compilation on windows
1125-
FREETYPE_BUILD_CMD = """\
1126-
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
11271130
call "{vcvarsall}" {xXX}
1128-
set MSBUILD=C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\MSBuild.exe
1129-
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-
)
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}
11401134
"""
11411135
from setup_external_compile import fixproj, prepare_build_cmd, VS2010, X64, tar_extract
11421136
# Note: freetype has no build profile for 2014, so we don't bother...
@@ -1153,8 +1147,17 @@ def do_custom_build(self):
11531147
cmd.write(prepare_build_cmd(FREETYPE_BUILD_CMD, vc20xx=vc, WinXX=WinXX,
11541148
config='Release' if VS2010 else 'LIB Release'))
11551149

1156-
os.environ['FREETYPE'] = src_path
1157-
subprocess.check_call([cmdfile], shell=True)
1150+
shutil.rmtree(str(Path(src_path, "objs")), ignore_errors=True)
1151+
subprocess.check_call([cmdfile], 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", vc20xx, xXX)
1156+
.glob("freetype*.lib"))
1157+
shutil.copy2(
1158+
str(lib_path),
1159+
str(Path(src_path, "objs", ".libs", "libfreetype.lib"))
1160+
)
11581161

11591162

11601163
class FT2Font(SetupPackage):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.