1313# it should configure and build SSL, then build the ssl Python extension
1414# without intervention.
1515
16+ # Modified by Christian Heimes
17+ # Now this script supports pre-generated makefiles and assembly files.
18+ # Developers don't need an installation of Perl anymore to build Python. A svn
19+ # checkout from our svn repository is enough.
20+
1621import os , sys , re , shutil
1722
1823# Find all "foo.exe" files on the PATH.
@@ -36,7 +41,7 @@ def find_all_on_path(filename, extras = None):
3641# is available.
3742def find_working_perl (perls ):
3843 for perl in perls :
39- fh = os .popen (perl + ' -e "use Win32;"' )
44+ fh = os .popen ('"%s" -e "use Win32;"' % perl )
4045 fh .read ()
4146 rc = fh .close ()
4247 if rc :
@@ -120,6 +125,22 @@ def run_configure(configure, do_script):
120125 print (do_script )
121126 os .system (do_script )
122127
128+ def cmp (f1 , f2 ):
129+ bufsize = 1024 * 8
130+ with open (f1 , 'rb' ) as fp1 , open (f2 , 'rb' ) as fp2 :
131+ while True :
132+ b1 = fp1 .read (bufsize )
133+ b2 = fp2 .read (bufsize )
134+ if b1 != b2 :
135+ return False
136+ if not b1 :
137+ return True
138+
139+ def copy (src , dst ):
140+ if os .path .isfile (dst ) and cmp (src , dst ):
141+ return
142+ shutil .copy (src , dst )
143+
123144def main ():
124145 debug = "-d" in sys .argv
125146 build_all = "-a" in sys .argv
@@ -129,6 +150,7 @@ def main():
129150 do_script = "ms\\ do_nasm"
130151 makefile = "ms\\ nt.mak"
131152 m32 = makefile
153+ dirsuffix = "32"
132154 configure += " no-idea no-rc5 no-mdc2"
133155 make_flags = ""
134156 if build_all :
@@ -137,12 +159,12 @@ def main():
137159 # as "well known" locations
138160 perls = find_all_on_path ("perl.exe" , ["\\ perl\\ bin" , "C:\\ perl\\ bin" ])
139161 perl = find_working_perl (perls )
140- if perl is None :
141- print ("No Perl installation was found. Existing Makefiles are used." )
142- else :
162+ if perl :
143163 print ("Found a working perl at '%s'" % (perl ,))
164+ else :
165+ print ("No Perl installation was found. Existing Makefiles are used." )
144166 sys .stdout .flush ()
145- # Look for SSL 3 levels up from pcbuild - ie, same place zlib etc all live.
167+ # Look for SSL 3 levels up from PC/VC6 - ie, same place zlib etc all live.
146168 ssl_dir = find_best_ssl_dir (("..\\ ..\\ .." ,))
147169 if ssl_dir is None :
148170 sys .exit (1 )
@@ -173,12 +195,21 @@ def main():
173195 # os.system("perl util\mk1mf.pl debug "+configure+" >"+makefile)
174196
175197 fix_makefile (makefile )
176- shutil .copy (r"crypto\buildinf.h" , r"crypto\buildinf_%s.h" % arch )
177- shutil .copy (r"crypto\opensslconf.h" , r"crypto\opensslconf_%s.h" % arch )
198+ copy (r"crypto\buildinf.h" , r"crypto\buildinf_%s.h" % arch )
199+ copy (r"crypto\opensslconf.h" , r"crypto\opensslconf_%s.h" % arch )
200+
201+ # If the assembler files don't exist in tmpXX, copy them there
202+ if perl is None :
203+ if not os .path .exists ("tmp" + dirsuffix ):
204+ os .mkdir ("tmp" + dirsuffix )
205+ for f in os .listdir ("asm" + dirsuffix ):
206+ if not f .endswith (".asm" ): continue
207+ if os .path .isfile (r"tmp%s\%s" % (dirsuffix , f )): continue
208+ shutil .copy (r"asm%s\%s" % (dirsuffix , f ), "tmp" + dirsuffix )
178209
179210 # Now run make.
180- shutil . copy (r"crypto\buildinf_%s.h" % arch , r"crypto\buildinf.h" )
181- shutil . copy (r"crypto\opensslconf_%s.h" % arch , r"crypto\opensslconf.h" )
211+ copy (r"crypto\buildinf_%s.h" % arch , r"crypto\buildinf.h" )
212+ copy (r"crypto\opensslconf_%s.h" % arch , r"crypto\opensslconf.h" )
182213
183214 #makeCommand = "nmake /nologo PERL=\"%s\" -f \"%s\"" %(perl, makefile)
184215 makeCommand = "nmake /nologo -f \" %s\" " % makefile
0 commit comments