Commit 4a57b004 authored by Martin v. Löwis's avatar Martin v. Löwis

Build _hashlib on Windows. Build OpenSSL with masm assembler code.

Fixes #1535502.
parent 63c640f2
...@@ -127,6 +127,9 @@ Documentation ...@@ -127,6 +127,9 @@ Documentation
Build Build
----- -----
- Bug #1535502, build _hashlib on Windows, and use masm assembler
code in OpenSSL.
- Bug #1534738, win32 debug version of _msi should be _msi_d.pyd. - Bug #1534738, win32 debug version of _msi should be _msi_d.pyd.
- Bug #1530448, ctypes buld failure on Solaris 10 was fixed. - Bug #1530448, ctypes buld failure on Solaris 10 was fixed.
......
!IFDEF DEBUG !IFDEF DEBUG
MODULE=_ssl_d.pyd SUFFIX=_d.pyd
TEMP_DIR=x86-temp-debug/_ssl TEMP=x86-temp-debug/
CFLAGS=/Od /Zi /MDd /LDd /DDEBUG /D_DEBUG /DWIN32 CFLAGS=/Od /Zi /MDd /LDd /DDEBUG /D_DEBUG /DWIN32
SSL_LIB_DIR=$(SSL_DIR)/out32.dbg SSL_LIB_DIR=$(SSL_DIR)/out32.dbg
!ELSE !ELSE
MODULE=_ssl.pyd SUFFIX=.pyd
TEMP_DIR=x86-temp-release/_ssl TEMP=x86-temp-release/
CFLAGS=/Ox /MD /LD /DWIN32 CFLAGS=/Ox /MD /LD /DWIN32
SSL_LIB_DIR=$(SSL_DIR)/out32 SSL_LIB_DIR=$(SSL_DIR)/out32
!ENDIF !ENDIF
INCLUDES=-I ../Include -I ../PC -I $(SSL_DIR)/inc32 INCLUDES=-I ../Include -I ../PC -I $(SSL_DIR)/inc32
LIBS=gdi32.lib wsock32.lib user32.lib advapi32.lib /libpath:$(SSL_LIB_DIR) libeay32.lib ssleay32.lib
SOURCE=../Modules/_ssl.c $(SSL_LIB_DIR)/libeay32.lib $(SSL_LIB_DIR)/ssleay32.lib SSL_LIBS=gdi32.lib wsock32.lib user32.lib advapi32.lib /LIBPATH:$(SSL_LIB_DIR) libeay32.lib ssleay32.lib
SSL_SOURCE=../Modules/_ssl.c $(SSL_LIB_DIR)/libeay32.lib $(SSL_LIB_DIR)/ssleay32.lib
$(MODULE): $(SOURCE) ../PC/*.h ../Include/*.h HASH_LIBS=gdi32.lib user32.lib advapi32.lib /libpath:$(SSL_LIB_DIR) libeay32.lib
@if not exist "$(TEMP_DIR)/." mkdir "$(TEMP_DIR)" HASH_SOURCE=../Modules/_hashopenssl.c $(SSL_LIB_DIR)/libeay32.lib
cl /nologo $(SOURCE) $(CFLAGS) /Fo$(TEMP_DIR)\$*.obj $(INCLUDES) /link /out:$(MODULE) $(LIBS)
all: _ssl$(SUFFIX) _hashlib$(SUFFIX)
# Split compile/link into two steps to better support VSExtComp
_ssl$(SUFFIX): $(SSL_SOURCE) ../PC/*.h ../Include/*.h
@if not exist "$(TEMP)/_ssl/." mkdir "$(TEMP)/_ssl"
cl /nologo $(SSL_SOURCE) $(CFLAGS) /Fo$(TEMP)\_ssl\$*.obj $(INCLUDES)
link /nologo @<<
/dll /out:_ssl$(SUFFIX) $(TEMP)\_ssl\$*.obj $(SSL_LIBS)
<<
_hashlib$(SUFFIX): $(HASH_SOURCE) ../PC/*.h ../Include/*.h
@if not exist "$(TEMP)/_hashlib/." mkdir "$(TEMP)/_hashlib"
cl /nologo /c $(HASH_SOURCE) $(CFLAGS) /Fo$(TEMP)\_hashlib\$*.obj $(INCLUDES)
link /nologo @<<
/dll /out:_hashlib$(SUFFIX) $(HASH_LIBS) $(TEMP)\_hashlib\$*.obj
<<
...@@ -75,6 +75,9 @@ ...@@ -75,6 +75,9 @@
<File <File
RelativePath="..\Modules\_ssl.c"> RelativePath="..\Modules\_ssl.c">
</File> </File>
<File
RelativePath="..\Modules\_hashopenssl.c">
</File>
</Files> </Files>
<Globals> <Globals>
</Globals> </Globals>
......
# Script for building the _ssl module for Windows. # Script for building the _ssl and _hashlib modules for Windows.
# Uses Perl to setup the OpenSSL environment correctly # Uses Perl to setup the OpenSSL environment correctly
# and build OpenSSL, then invokes a simple nmake session # and build OpenSSL, then invokes a simple nmake session
# for _ssl.pyd itself. # for the actual _ssl.pyd and _hashlib.pyd DLLs.
# THEORETICALLY, you can: # THEORETICALLY, you can:
# * Unpack the latest SSL release one level above your main Python source # * Unpack the latest SSL release one level above your main Python source
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
# * Install ActivePerl and ensure it is somewhere on your path. # * Install ActivePerl and ensure it is somewhere on your path.
# * Run this script from the PCBuild directory. # * Run this script from the PCBuild directory.
# #
# it should configure and build SSL, then build the ssl Python extension # it should configure and build SSL, then build the _ssl and _hashlib
# without intervention. # Python extensions without intervention.
import os, sys, re import os, sys, re
...@@ -59,7 +59,8 @@ def find_best_ssl_dir(sources): ...@@ -59,7 +59,8 @@ def find_best_ssl_dir(sources):
candidates = [] candidates = []
for s in sources: for s in sources:
try: try:
s = os.path.abspath(s) # note: do not abspath s; the build will fail if any
# higher up directory name has spaces in it.
fnames = os.listdir(s) fnames = os.listdir(s)
except os.error: except os.error:
fnames = [] fnames = []
...@@ -82,31 +83,9 @@ def find_best_ssl_dir(sources): ...@@ -82,31 +83,9 @@ def find_best_ssl_dir(sources):
print "Found an SSL directory at '%s'" % (best_name,) print "Found an SSL directory at '%s'" % (best_name,)
else: else:
print "Could not find an SSL directory in '%s'" % (sources,) print "Could not find an SSL directory in '%s'" % (sources,)
sys.stdout.flush()
return best_name return best_name
def run_32all_py():
# ms\32all.bat will reconfigure OpenSSL and then try to build
# all outputs (debug/nondebug/dll/lib). So we filter the file
# to exclude any "nmake" commands and then execute.
tempname = "ms\\32all_py.bat"
in_bat = open("ms\\32all.bat")
temp_bat = open(tempname,"w")
while 1:
cmd = in_bat.readline()
print 'cmd', repr(cmd)
if not cmd: break
if cmd.strip()[:5].lower() == "nmake":
continue
temp_bat.write(cmd)
in_bat.close()
temp_bat.close()
os.system(tempname)
try:
os.remove(tempname)
except:
pass
def run_configure(configure, do_script): def run_configure(configure, do_script):
os.system("perl Configure "+configure) os.system("perl Configure "+configure)
os.system(do_script) os.system(do_script)
...@@ -117,12 +96,14 @@ def main(): ...@@ -117,12 +96,14 @@ def main():
arch = "x86" arch = "x86"
debug = False debug = False
configure = "VC-WIN32" configure = "VC-WIN32"
makefile = "32.mak" do_script = "ms\\do_masm"
makefile = "ms\\nt.mak"
elif sys.argv[1] == "Debug": elif sys.argv[1] == "Debug":
arch = "x86" arch = "x86"
debug = True debug = True
configure = "VC-WIN32" configure = "VC-WIN32"
makefile="d32.mak" do_script = "ms\\do_masm"
makefile="ms\\d32.mak"
elif sys.argv[1] == "ReleaseItanium": elif sys.argv[1] == "ReleaseItanium":
arch = "ia64" arch = "ia64"
debug = False debug = False
...@@ -148,8 +129,9 @@ def main(): ...@@ -148,8 +129,9 @@ def main():
sys.exit(1) sys.exit(1)
print "Found a working perl at '%s'" % (perl,) print "Found a working perl at '%s'" % (perl,)
sys.stdout.flush()
# Look for SSL 2 levels up from pcbuild - ie, same place zlib etc all live. # Look for SSL 2 levels up from pcbuild - ie, same place zlib etc all live.
ssl_dir = find_best_ssl_dir(("../..",)) ssl_dir = find_best_ssl_dir(("..\\..",))
if ssl_dir is None: if ssl_dir is None:
sys.exit(1) sys.exit(1)
...@@ -159,29 +141,35 @@ def main(): ...@@ -159,29 +141,35 @@ def main():
# If the ssl makefiles do not exist, we invoke Perl to generate them. # If the ssl makefiles do not exist, we invoke Perl to generate them.
if not os.path.isfile(makefile): if not os.path.isfile(makefile):
print "Creating the makefiles..." print "Creating the makefiles..."
sys.stdout.flush()
# Put our working Perl at the front of our path # Put our working Perl at the front of our path
os.environ["PATH"] = os.path.split(perl)[0] + \ os.environ["PATH"] = os.path.dirname(perl) + \
os.pathsep + \ os.pathsep + \
os.environ["PATH"] os.environ["PATH"]
if arch=="x86": if arch=="x86" and debug:
run_32all_py() # the do_masm script in openssl doesn't generate a debug
else: # build makefile so we generate it here:
run_configure(configure, do_script) os.system("perl util\mk1mf.pl debug "+configure+" >"+makefile)
run_configure(configure, do_script)
# Now run make. # Now run make.
print "Executing nmake over the ssl makefiles..." print "Executing nmake over the ssl makefiles..."
rc = os.system("nmake /nologo -f "+makefile) sys.stdout.flush()
rc = os.system("nmake /nologo PERL=\"%s\" -f \"%s\"" %(perl, makefile))
if rc: if rc:
print "Executing d32.mak failed" print "Executing "+makefile+" failed"
print rc print rc
sys.exit(rc) sys.exit(rc)
finally: finally:
os.chdir(old_cd) os.chdir(old_cd)
# And finally, we can build the _ssl module itself for Python. # And finally, we can build the _ssl module itself for Python.
defs = "SSL_DIR=%s" % (ssl_dir,) defs = "SSL_DIR=\"%s\"" % (ssl_dir,)
if debug: if debug:
defs = defs + " " + "DEBUG=1" defs = defs + " " + "DEBUG=1"
rc = os.system('nmake /nologo -f _ssl.mak ' + defs + " " + make_flags) makeCommand = 'nmake /nologo -f _ssl.mak ' + defs + " " + make_flags
print "Executing:", makeCommand
sys.stdout.flush()
rc = os.system(makeCommand)
sys.exit(rc) sys.exit(rc)
if __name__=='__main__': if __name__=='__main__':
......
...@@ -89,7 +89,8 @@ extensions = [ ...@@ -89,7 +89,8 @@ extensions = [
'_msi.pyd', '_msi.pyd',
'_ctypes.pyd', '_ctypes.pyd',
'_ctypes_test.pyd', '_ctypes_test.pyd',
'_sqlite3.pyd' '_sqlite3.pyd',
'_hashlib.pyd'
] ]
# Well-known component UUIDs # Well-known component UUIDs
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment