[Distutils] patch for msvccompiler.py and build_ext.py, debug flag
Thomas Heller
thomas.heller@ion-tof.com
Wed, 9 Feb 2000 12:05:07 +0100
This patch against the current CVS version implements the --debug flag.
Also I've included the def-file kludge again, because I still
think if a def-file is present, it should be used, but I would
still like to hear opinions from more windows people here.
Other notes:
- The python15.lib is no longer set in msvccompiler
- We can still argue about the debug-flags to be used
I've tested this (with and without def-files, with and without
the debug flag) on numpy-15.2. It builds nicely in normal
and debug mode, and testwin.bat completes successfully.
Thomas Heller
PS: I'm still new to diff. If I've done somthing wrong, please complain!
diff -cr c:\distutils\distutils/command/build_ext.py
distutils/command/build_ext.py
*** c:\distutils\distutils/command/build_ext.py Wed Feb 9 09:10:32 2000
--- distutils/command/build_ext.py Wed Feb 9 11:54:04 2000
***************
*** 241,249 ****
libraries = build_info.get ('libraries')
library_dirs = build_info.get ('library_dirs')
extra_args = build_info.get ('extra_link_args') or []
if self.compiler.compiler_type == 'msvc':
! mod_name = string.split (extension_name, '.')[-1]
! extra_args.append ('/export:init%s' % mod_name)
ext_filename = self.extension_filename \
(extension_name, self.package)
--- 241,263 ----
libraries = build_info.get ('libraries')
library_dirs = build_info.get ('library_dirs')
extra_args = build_info.get ('extra_link_args') or []
+
if self.compiler.compiler_type == 'msvc':
! def_file = build_info.get ('def_file')
! if def_file is None:
! source_dir = os.path.dirname (sources[0])
! ext_base = (string.split (extension_name, '.'))[-1]
! def_file = os.path.join (source_dir, "%s.def" % ext_base)
! if not os.path.exists (def_file):
! ## self.warn ("file '%s' not found: " % def_file +
! ## "might have problems building DLL")
! def_file = None
!
! if def_file is not None:
! extra_args.append ('/DEF:' + def_file)
! else:
! modname = string.split (extension_name, '.')[-1]
! extra_args.append('/export:init%s'%modname)
ext_filename = self.extension_filename \
(extension_name, self.package)
diff -cr c:\distutils\distutils/msvccompiler.py distutils/msvccompiler.py
*** c:\distutils\distutils/msvccompiler.py Wed Feb 9 09:10:32 2000
--- distutils/msvccompiler.py Wed Feb 9 11:47:16 2000
***************
*** 114,123 ****
CCompiler.__init__ (self, verbose, dry_run, force)
- # XXX This is a nasty dependency to add on something otherwise
- # pretty clean. move it to build_ext under an nt specific part.
- # shared libraries need to link against python15.lib
- self.add_library ( "python" + sys.version[0] + sys.version[2] )
self.add_library_dir( os.path.join( sys.exec_prefix, 'libs' ) )
self.cc = _find_exe("cl.exe")
--- 114,119 ----
***************
*** 133,140 ****
--- 129,142 ----
os.environ['path'] = string.join(path,';')
self.preprocess_options = None
self.compile_options = [ '/nologo', '/Ox', '/MD' ]
+ self.compile_options_debug = [
+ '/nologo', '/Od', '/MDd', '/Z7', '/D_DEBUG'
+ ]
self.ldflags_shared = ['/DLL', '/nologo', '/INCREMENTAL:NO']
+ self.ldflags_shared_debug = [
+ '/DLL', '/nologo', '/INCREMENTAL:no', '/pdb:None', '/DEBUG'
+ ]
self.ldflags_static = [ '/nologo']
***************
*** 176,181 ****
--- 178,188 ----
base_pp_opts.append('/c')
+ if debug:
+ compile_options = self.compile_options_debug
+ else:
+ compile_options = self.compile_options
+
for srcFile in sources:
base,ext = os.path.splitext(srcFile)
objFile = base + ".obj"
***************
*** 188,198 ****
inputOpt = fileOpt + srcFile
outputOpt = "/Fo" + objFile
! cc_args = self.compile_options + \
base_pp_opts + \
[outputOpt, inputOpt]
! if debug:
! pass # XXX what goes here?
if extra_preargs:
cc_args[:0] = extra_preargs
if extra_postargs:
--- 195,204 ----
inputOpt = fileOpt + srcFile
outputOpt = "/Fo" + objFile
! cc_args = compile_options + \
base_pp_opts + \
[outputOpt, inputOpt]
!
if extra_preargs:
cc_args[:0] = extra_preargs
if extra_postargs:
***************
*** 250,257 ****
# XXX should we sanity check the library name? (eg. no
# slashes)
! self.link_shared_object (objects,
! self.shared_library_name(output_libname))
def link_shared_object (self,
objects,
--- 256,270 ----
# XXX should we sanity check the library name? (eg. no
# slashes)
! self.link_shared_object (objects=objects,
! output_libname=\
!
self.shared_library_name(output_libname),
! output_dir=output_dir,
! libraries=libraries,
! library_dirs=library_dirs,
! debug=debug,
! extra_preargs=extra_preargs,
! extra_postargs=extra_postargs)
def link_shared_object (self,
objects,
***************
*** 259,264 ****
--- 272,278 ----
output_dir=None,
libraries=None,
library_dirs=None,
+ debug=0,
extra_preargs=None,
extra_postargs=None):
"""Link a bunch of stuff together to create a shared object
***************
*** 273,282 ****
self.library_dirs + library_dirs,
self.libraries + libraries)
- ld_args = self.ldflags_shared + lib_opts + \
- objects + ['/OUT:' + output_filename]
if debug:
! pass # XXX what goes here?
if extra_preargs:
ld_args[:0] = extra_preargs
if extra_postargs:
--- 287,304 ----
self.library_dirs + library_dirs,
self.libraries + libraries)
if debug:
! ldflags = self.ldflags_shared_debug
! basename, ext = os.path.splitext (output_filename)
! #XXX not sure this belongs here
! # extensions in debug_mode are named 'module_d.pyd'
! output_filename = basename + '_d' + ext
! else:
! ldflags = self.ldflags_shared
!
! ld_args = ldflags + lib_opts + \
! objects + ['/OUT:' + output_filename]
!
if extra_preargs:
ld_args[:0] = extra_preargs
if extra_postargs: