[pypy-svn] pypy default: On Windows, eci.compile_shared_lib() will now build a DLL when there are "exported symbols",

amauryfa commits-noreply at bitbucket.org
Tue Jan 18 18:08:31 CET 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: 
Changeset: r40883:0ad077caf958
Date: 2011-01-18 14:12 +0100
http://bitbucket.org/pypy/pypy/changeset/0ad077caf958/

Log:	On Windows, eci.compile_shared_lib() will now build a DLL when there
	are "exported symbols", even when there are no source files. This
	allows ll2ctypes to call functions in static libraries, and
	module/_ssl/test now works on windows.

diff --git a/pypy/translator/platform/__init__.py b/pypy/translator/platform/__init__.py
--- a/pypy/translator/platform/__init__.py
+++ b/pypy/translator/platform/__init__.py
@@ -176,8 +176,11 @@
     def _finish_linking(self, ofiles, eci, outputfilename, standalone):
         if outputfilename is None:
             outputfilename = ofiles[0].purebasename
-        exe_name = py.path.local(os.path.join(str(ofiles[0].dirpath()),
-                                              outputfilename))
+        if ofiles:
+            dirname = ofiles[0].dirpath()
+        else:
+            dirname = udir.join('module_cache')
+        exe_name = dirname.join(outputfilename)
         if standalone:
             if self.exe_ext:
                 exe_name += '.' + self.exe_ext

diff --git a/pypy/rlib/ropenssl.py b/pypy/rlib/ropenssl.py
--- a/pypy/rlib/ropenssl.py
+++ b/pypy/rlib/ropenssl.py
@@ -6,7 +6,8 @@
 import sys
 
 if sys.platform == 'win32' and platform.name != 'mingw32':
-    libraries = ['libeay32', 'ssleay32', 'user32', 'advapi32', 'gdi32']
+    libraries = ['libeay32', 'ssleay32',
+                 'user32', 'advapi32', 'gdi32', 'msvcrt', 'ws2_32']
     includes = [
         # ssl.h includes winsock.h, which will conflict with our own
         # need of winsock2.  Remove this when separate compilation is
@@ -26,7 +27,7 @@
 eci = ExternalCompilationInfo(
     libraries = libraries,
     includes = includes,
-    export_symbols = ['SSL_load_error_strings'],
+    export_symbols = [],
     )
 
 eci = rffi_platform.configure_external_library(
@@ -82,6 +83,7 @@
 
 def external(name, argtypes, restype, **kw):
     kw['compilation_info'] = eci
+    eci.export_symbols += (name,)
     return rffi.llexternal(
         name, argtypes, restype, **kw)
 
@@ -110,7 +112,9 @@
 ssl_external('SSL_set_accept_state', [SSL], lltype.Void)
 ssl_external('SSL_connect', [SSL], rffi.INT)
 ssl_external('SSL_do_handshake', [SSL], rffi.INT)
+ssl_external('SSL_shutdown', [SSL], rffi.INT)
 ssl_external('SSL_get_error', [SSL, rffi.INT], rffi.INT)
+ssl_external('SSL_set_read_ahead', [SSL, rffi.INT], lltype.Void)
 
 ssl_external('ERR_get_error', [], rffi.INT)
 ssl_external('ERR_error_string', [rffi.ULONG, rffi.CCHARP], rffi.CCHARP)

diff --git a/pypy/translator/tool/cbuild.py b/pypy/translator/tool/cbuild.py
--- a/pypy/translator/tool/cbuild.py
+++ b/pypy/translator/tool/cbuild.py
@@ -1,4 +1,5 @@
 import py
+import sys
 
 from pypy.tool.autopath import pypydir
 from pypy.translator.platform import host
@@ -269,10 +270,15 @@
     def compile_shared_lib(self, outputfilename=None):
         self = self.convert_sources_to_files()
         if not self.separate_module_files:
-            return self
+            if sys.platform != 'win32':
+                return self
+            if not self.export_symbols:
+                return self
+            basepath = udir.join('module_cache')
+        else:
+            basepath = py.path.local(self.separate_module_files[0]).dirpath()
         if outputfilename is None:
             # find more or less unique name there
-            basepath = py.path.local(self.separate_module_files[0]).dirpath()
             pth = basepath.join('externmod').new(ext=host.so_ext)
             num = 0
             while pth.check():

diff --git a/pypy/translator/platform/windows.py b/pypy/translator/platform/windows.py
--- a/pypy/translator/platform/windows.py
+++ b/pypy/translator/platform/windows.py
@@ -169,8 +169,8 @@
 
         if self.version >= 80:
             # Tell the linker to generate a manifest file
-            temp_manifest = ofile.dirpath().join(
-                ofile.purebasename + '.manifest')
+            temp_manifest = exe_name.dirpath().join(
+                exe_name.purebasename + '.manifest')
             args += ["/MANIFEST", "/MANIFESTFILE:%s" % (temp_manifest,)]
 
         self._execute_c_compiler(self.link, args, exe_name)


More information about the Pypy-commit mailing list