@@ -1029,6 +1029,8 @@ def add_flags(self, ext):
1029
1029
ext .define_macros .append (('FREETYPE_BUILD_TYPE' , 'system' ))
1030
1030
1031
1031
def do_custom_build (self ):
1032
+ from pathlib import Path
1033
+
1032
1034
# We're using a system freetype
1033
1035
if not options .get ('local_freetype' ):
1034
1036
return
@@ -1122,21 +1124,13 @@ def do_custom_build(self):
1122
1124
[cflags + 'make' ], shell = True , cwd = src_path )
1123
1125
else :
1124
1126
# 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
1127
1130
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}
1140
1134
"""
1141
1135
from setup_external_compile import fixproj , prepare_build_cmd , VS2010 , X64 , tar_extract
1142
1136
# Note: freetype has no build profile for 2014, so we don't bother...
@@ -1148,13 +1142,20 @@ def do_custom_build(self):
1148
1142
fixproj (os .path .join (src_path , 'builds' , 'windows' , vc , 'freetype.sln' ), WinXX )
1149
1143
fixproj (os .path .join (src_path , 'builds' , 'windows' , vc , 'freetype.vcproj' ), WinXX )
1150
1144
1151
- cmdfile = os . path . join ( "build" , ' build_freetype.cmd' )
1152
- with open (cmdfile , 'w' ) as cmd :
1145
+ cmdfile = " build_freetype.cmd"
1146
+ with open (os . path . join ( "build" , cmdfile ) , 'w' ) as cmd :
1153
1147
cmd .write (prepare_build_cmd (FREETYPE_BUILD_CMD , vc20xx = vc , WinXX = WinXX ,
1154
1148
config = 'Release' if VS2010 else 'LIB Release' ))
1155
1149
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 (str (lib_path ),
1158
+ str (Path (src_path , "objs/.libs/libfreetype.lib" )))
1158
1159
1159
1160
1160
1161
class FT2Font (SetupPackage ):
0 commit comments