[Distutils] Patch to MSVCCompiler: 'export_symbols'

Greg Ward gward@python.net
Sat, 20 May 2000 09:01:52 -0400


OK, all your Windows experts: tell me if I got this right.  Here's a
patch to msvccompiler.py to add support for the 'export_symbol' keyword
argument to 'link_shared_lib()' and 'link_shared_object()'.  Right now
it turns a list of ['foo', 'bar', 'baz'] into additional arguments to
the linker:

   /EXPORT:foo /EXPORT:bar /EXPORT:baz

Is this the correct and/or optimal way to do it?

Here's the patch...

diff -c -r1.27 msvccompiler.py
*** msvccompiler.py     2000/04/19 02:16:49     1.27
--- msvccompiler.py     2000/05/20 12:59:04
***************
*** 304,309 ****
--- 304,310 ----
                           libraries=None,
                           library_dirs=None,
                           runtime_library_dirs=None,
+                          export_symbols=None,
                           debug=0,
                           extra_preargs=None,
                           extra_postargs=None):
***************
*** 313,318 ****
--- 314,321 ----
                                   output_dir=output_dir,
                                   libraries=libraries,
                                   library_dirs=library_dirs,
+                                  runtime_library_dirs=runtime_library_dirs,
+                                  export_symbols=export_symbols,
                                   debug=debug,
                                   extra_preargs=extra_preargs,
                                   extra_postargs=extra_postargs)
***************
*** 325,330 ****
--- 328,334 ----
                              libraries=None,
                              library_dirs=None,
                              runtime_library_dirs=None,
+                             export_symbols=None,
                              debug=0,
                              extra_preargs=None,
                              extra_postargs=None):
***************
*** 350,357 ****
              else:
                  ldflags = self.ldflags_shared
  
!             ld_args = ldflags + lib_opts + \
!                       objects + ['/OUT:' + output_filename]
  
              if extra_preargs:
                  ld_args[:0] = extra_preargs
--- 354,365 ----
              else:
                  ldflags = self.ldflags_shared
  
!             export_opts = []
!             for sym in (export_symbols or []):
!                 export_opts.append("/EXPORT:" + sym)
! 
!             ld_args = (ldflags + lib_opts + export_opts + 
!                        objects + ['/OUT:' + output_filename])
  
              if extra_preargs:
                  ld_args[:0] = extra_preargs

-- 
Greg Ward - Unix bigot                                  gward@python.net
http://starship.python.net/~gward/
Disclaimer: All rights reserved. Void where prohibited. Limit 1 per customer.