1
+ # This file is coppied from https://github.com/jbmohler/matplotlib-winbuild
2
+ # Only the needed functions were kept.
1
3
"""
2
4
This file extracts and builds library dependencies libpng, zlib, & freetype2 on
3
5
MS Windows. It also extract tcl/tk for the header files.
@@ -65,164 +67,3 @@ def prepare_build_cmd(build_cmd, **kwargs):
65
67
VCVARSALL = candidate
66
68
67
69
return build_cmd .format (vcvarsall = VCVARSALL , xXX = 'x64' if X64 else 'x86' , ** kwargs )
68
-
69
- def config_dir ():
70
- segment = 'msvcr{}-x{}' .format ('100' if VS2010 else '90' , '64' if X64 else '32' )
71
- return os .path .join (DEPSBUILD , segment )
72
-
73
- def tcl_config_dir ():
74
- return os .path .join (config_dir (), 'tcl85' , 'include' )
75
-
76
- def build_tcl ():
77
- inclib = config_dir ()
78
- tcl_inclib = tcl_config_dir ()
79
- if not os .path .exists (tcl_inclib ):
80
- os .makedirs (tcl_inclib )
81
- tcl_inclib_x11 = os .path .join (tcl_inclib , 'X11' )
82
- if not os .path .exists (tcl_inclib_x11 ):
83
- os .makedirs (tcl_inclib_x11 )
84
-
85
- distfile = os .path .join (DEPSSRC , 'tcl8513-src.zip' )
86
- compfile = os .path .join (tcl_inclib , 'tcl.h' )
87
- if not os .path .exists (compfile ) or os .path .getmtime (distfile ) > os .path .getmtime (compfile ):
88
- zip_extract (distfile , DEPSBUILD )
89
- targetdir = os .path .join (DEPSBUILD , 'tcl8.5.13' )
90
- headers = glob .glob (os .path .join (targetdir , 'generic' , '*.h' ))
91
- for filename in headers :
92
- shutil .copy (filename , tcl_inclib )
93
-
94
- distfile = os .path .join (DEPSSRC , 'tk8513-src.zip' )
95
- compfile = os .path .join (tcl_inclib , 'tk.h' )
96
- if not os .path .exists (compfile ) or os .path .getmtime (distfile ) > os .path .getmtime (compfile ):
97
- zip_extract (distfile , DEPSBUILD )
98
- targetdir = os .path .join (DEPSBUILD , 'tk8.5.13' )
99
- headers = glob .glob (os .path .join (targetdir , 'generic' , '*.h' ))
100
- for filename in headers :
101
- shutil .copy (filename , tcl_inclib )
102
- headers = glob .glob (os .path .join (targetdir , 'xlib' , 'X11' , '*.*' ))
103
- for filename in headers :
104
- shutil .copy (filename , tcl_inclib_x11 )
105
-
106
- ZLIB_BUILD_CMD = """\
107
- @ECHO OFF
108
- REM call "%ProgramFiles%\\ Microsoft SDKs\\ Windows\\ v7.0\\ Bin\\ SetEnv.Cmd" /Release /{xXX} /xp
109
- call "{vcvarsall}" {xXX}
110
-
111
- cd /D %ZLIB%
112
- nmake -f win32\\ Makefile.msc clean
113
- nmake -f win32\\ Makefile.msc
114
- copy /Y /B *.dll %INCLIB%
115
- copy /Y /B *.lib %INCLIB%
116
- copy /Y /B zlib.lib %INCLIB%\\ z.lib
117
- copy /Y /B zlib.h %INCLIB%
118
- copy /Y /B zconf.h %INCLIB%
119
- """
120
-
121
- def build_zlib ():
122
- inclib = config_dir ()
123
- if not os .path .exists (inclib ):
124
- os .makedirs (inclib )
125
-
126
- distfile = os .path .join (DEPSSRC , 'zlib128.zip' )
127
- compfile = os .path .join (inclib , 'z.lib' )
128
- if os .path .exists (compfile ) and os .path .getmtime (distfile ) < os .path .getmtime (compfile ):
129
- # already built
130
- return
131
-
132
- zip_extract (distfile , DEPSBUILD )
133
-
134
- cmdfile = os .path .join (DEPSBUILD , 'build_zlib.cmd' )
135
- with open (cmdfile , 'w' ) as cmd :
136
- cmd .write (prepare_build_cmd (ZLIB_BUILD_CMD ))
137
-
138
- os .environ ['INCLIB' ] = inclib
139
- os .environ ['ZLIB' ] = os .path .join (DEPSBUILD , 'zlib-1.2.8' )
140
- os .system (cmdfile )
141
-
142
- LIBPNG_BUILD_CMD = """\
143
- @ECHO OFF
144
- REM call "%ProgramFiles%\\ Microsoft SDKs\\ Windows\\ v7.0\\ Bin\\ SetEnv.Cmd" /Release /{xXX} /xp
145
- call "{vcvarsall}" {xXX}
146
- set CMAKE="cmake.exe"
147
-
148
- set BUILDDIR=%LIBPNG%-build
149
- rd /S /Q %BUILDDIR%
150
- %CMAKE% -G"NMake Makefiles" -H%LIBPNG% -B%BUILDDIR% ^
151
- -DCMAKE_BUILD_TYPE=Release ^
152
- -DZLIB_INCLUDE_DIR=%INCLIB% ^
153
- -DZLIB_LIBRARY:FILEPATH=%INCLIB%\\ zlib.lib ^
154
- -DPNG_STATIC=ON ^
155
- -DPNG_SHARED=OFF
156
- copy /Y /B %BUILDDIR%\\ pnglibconf.h %INCLIB%
157
- copy /Y /B %LIBPNG%\\ png.h %INCLIB%
158
- copy /Y /B %LIBPNG%\\ pngconf.h %INCLIB%
159
- cd %BUILDDIR%
160
- nmake -f Makefile
161
- REM It's a static lib -- no *.dll in sight!
162
- REM copy /Y /B *.dll %INCLIB%
163
- copy /Y /B *.lib %INCLIB%
164
- copy /Y /B libpng16_static.lib %INCLIB%\\ png.lib
165
- """
166
-
167
- def build_libpng ():
168
- inclib = config_dir ()
169
- if not os .path .exists (inclib ):
170
- os .mkdir (inclib )
171
-
172
- distfile = os .path .join (DEPSSRC , 'libpng-1.6.7.tar.gz' )
173
- compfile = os .path .join (inclib , 'png.lib' )
174
- if os .path .exists (compfile ) and os .path .getmtime (distfile ) < os .path .getmtime (compfile ):
175
- # already built
176
- return
177
-
178
- tar_extract (distfile , DEPSBUILD )
179
-
180
- cmdfile = os .path .join (DEPSBUILD , 'build_libpng.cmd' )
181
- with open (cmdfile , 'w' ) as cmd :
182
- cmd .write (prepare_build_cmd (LIBPNG_BUILD_CMD ))
183
-
184
- os .environ ['INCLIB' ] = inclib
185
- os .environ ['LIBPNG' ] = os .path .join (DEPSBUILD , 'libpng-1.6.7' )
186
- os .system (cmdfile )
187
-
188
- FREETYPE_VERSION = '2.4.11'
189
-
190
- FREETYPE_BUILD_CMD = """\
191
- @ECHO OFF
192
- REM call "%ProgramFiles%\\ Microsoft SDKs\\ Windows\\ v7.0\\ Bin\\ SetEnv.Cmd" /Release /{xXX} /xp
193
- call "{vcvarsall}" {xXX}
194
- set MSBUILD=C:\\ Windows\\ Microsoft.NET\\ Framework\\ v4.0.30319\\ MSBuild.exe
195
-
196
- rd /S /Q %FREETYPE%\\ objs
197
- %MSBUILD% %FREETYPE%\\ builds\\ win32\\ {vc20xx}\\ freetype.sln /t:Clean;Build /p:Configuration="{config}";Platform={WinXX}
198
- xcopy /Y /E /Q %FREETYPE%\\ include %INCLIB%
199
- xcopy /Y /E /Q %FREETYPE%\\ objs\\ win32\\ {vc20xx} %INCLIB%
200
- copy /Y /B %FREETYPE%\\ objs\\ win32\\ {vc20xx}\\ *.lib %INCLIB%\\ freetype.lib
201
- """
202
-
203
- def build_freetype ():
204
- inclib = config_dir ()
205
- if not os .path .exists (inclib ):
206
- os .mkdir (inclib )
207
-
208
- distfile = os .path .join (DEPSSRC , 'ft2411.zip' )
209
- compfile = os .path .join (inclib , 'freetype.lib' )
210
- if os .path .exists (compfile ) and os .path .getmtime (distfile ) < os .path .getmtime (compfile ):
211
- # already built
212
- return
213
-
214
- vc = 'vc2010' if VS2010 else 'vc2008'
215
- WinXX = 'x64' if X64 else 'Win32'
216
-
217
- zip_extract (distfile , DEPSBUILD )
218
- ft_dir = os .path .join (DEPSBUILD , 'freetype-2.4.11' )
219
- fixproj (os .path .join (ft_dir , 'builds' , 'win32' , vc , 'freetype.sln' ), WinXX )
220
- fixproj (os .path .join (ft_dir , 'builds' , 'win32' , vc , 'freetype.{}' .format ('vcxproj' if VS2010 else 'vcproj' )), WinXX )
221
-
222
- cmdfile = os .path .join (DEPSBUILD , 'build_freetype.cmd' )
223
- with open (cmdfile , 'w' ) as cmd :
224
- cmd .write (prepare_build_cmd (FREETYPE_BUILD_CMD , vc20xx = vc , WinXX = WinXX , config = 'Release' if VS2010 else 'LIB Release' ))
225
-
226
- os .environ ['INCLIB' ] = inclib
227
- os .environ ['FREETYPE' ] = ft_dir
228
- os .system (cmdfile )
0 commit comments