Commit e8c6ce46 authored by Greg Ward's avatar Greg Ward

Added 'debug' option, and changed compile/link calls to use it.

parent 32462001
...@@ -28,7 +28,9 @@ from distutils.ccompiler import new_compiler ...@@ -28,7 +28,9 @@ from distutils.ccompiler import new_compiler
class BuildLib (Command): class BuildLib (Command):
options = [] options = [('debug', 'g',
"compile with debugging information"),
]
def set_default_options (self): def set_default_options (self):
# List of libraries to build # List of libraries to build
...@@ -38,10 +40,13 @@ class BuildLib (Command): ...@@ -38,10 +40,13 @@ class BuildLib (Command):
self.include_dirs = None self.include_dirs = None
self.define = None self.define = None
self.undef = None self.undef = None
self.debug = None
# set_default_options() # set_default_options()
def set_final_options (self): def set_final_options (self):
self.set_undefined_options ('build',
('debug', 'debug'))
self.libraries = self.distribution.libraries self.libraries = self.distribution.libraries
if self.include_dirs is None: if self.include_dirs is None:
self.include_dirs = self.distribution.include_dirs or [] self.include_dirs = self.distribution.include_dirs or []
...@@ -146,12 +151,13 @@ class BuildLib (Command): ...@@ -146,12 +151,13 @@ class BuildLib (Command):
objects = self.compiler.compile (sources, objects = self.compiler.compile (sources,
macros=macros, macros=macros,
include_dirs=include_dirs, include_dirs=include_dirs,
output_dir=lib_dir) output_dir=lib_dir,
debug=self.debug)
# Now "link" the object files together into a static library. # Now "link" the object files together into a static library.
# (On Unix at least, this isn't really linking -- it just # (On Unix at least, this isn't really linking -- it just
# builds an archive. Whatever.) # builds an archive. Whatever.)
self.compiler.link_static_lib (objects, lib_name) self.compiler.link_static_lib (objects, lib_name, debug=self.debug)
# for libraries # for libraries
......
...@@ -58,6 +58,8 @@ class BuildExt (Command): ...@@ -58,6 +58,8 @@ class BuildExt (Command):
"directories to search for shared C libraries at runtime"), "directories to search for shared C libraries at runtime"),
('link-objects=', 'O', ('link-objects=', 'O',
"extra explicit link objects to include in the link"), "extra explicit link objects to include in the link"),
('debug', 'g',
"compile/link with debugging information"),
] ]
...@@ -73,12 +75,15 @@ class BuildExt (Command): ...@@ -73,12 +75,15 @@ class BuildExt (Command):
self.library_dirs = None self.library_dirs = None
self.rpath = None self.rpath = None
self.link_objects = None self.link_objects = None
self.debug = None
def set_final_options (self): def set_final_options (self):
from distutils import sysconfig from distutils import sysconfig
self.set_undefined_options ('build', ('build_platlib', 'build_dir')) self.set_undefined_options ('build',
('build_platlib', 'build_dir'),
('debug', 'debug'))
if self.package is None: if self.package is None:
self.package = self.distribution.ext_package self.package = self.distribution.ext_package
...@@ -223,7 +228,8 @@ class BuildExt (Command): ...@@ -223,7 +228,8 @@ class BuildExt (Command):
include_dirs = build_info.get ('include_dirs') include_dirs = build_info.get ('include_dirs')
self.compiler.compile (sources, self.compiler.compile (sources,
macros=macros, macros=macros,
include_dirs=include_dirs) include_dirs=include_dirs,
debug=self.debug)
# Now link the object files together into a "shared object" -- # Now link the object files together into a "shared object" --
# of course, first we have to figure out all the other things # of course, first we have to figure out all the other things
...@@ -236,7 +242,8 @@ class BuildExt (Command): ...@@ -236,7 +242,8 @@ class BuildExt (Command):
library_dirs = build_info.get ('library_dirs') library_dirs = build_info.get ('library_dirs')
extra_args = build_info.get ('extra_link_args') or [] extra_args = build_info.get ('extra_link_args') or []
if self.compiler.compiler_type == 'msvc': if self.compiler.compiler_type == 'msvc':
extra_args.append ('/export:init%s' % extension_name) mod_name = string.split (extension_name, '.')[-1]
extra_args.append ('/export:init%s' % mod_name)
ext_filename = self.extension_filename \ ext_filename = self.extension_filename \
(extension_name, self.package) (extension_name, self.package)
...@@ -246,7 +253,8 @@ class BuildExt (Command): ...@@ -246,7 +253,8 @@ class BuildExt (Command):
self.compiler.link_shared_object (objects, ext_filename, self.compiler.link_shared_object (objects, ext_filename,
libraries=libraries, libraries=libraries,
library_dirs=library_dirs, library_dirs=library_dirs,
extra_postargs=extra_args) extra_postargs=extra_args,
debug=self.debug)
# build_extensions () # build_extensions ()
......
...@@ -28,7 +28,9 @@ from distutils.ccompiler import new_compiler ...@@ -28,7 +28,9 @@ from distutils.ccompiler import new_compiler
class BuildLib (Command): class BuildLib (Command):
options = [] options = [('debug', 'g',
"compile with debugging information"),
]
def set_default_options (self): def set_default_options (self):
# List of libraries to build # List of libraries to build
...@@ -38,10 +40,13 @@ class BuildLib (Command): ...@@ -38,10 +40,13 @@ class BuildLib (Command):
self.include_dirs = None self.include_dirs = None
self.define = None self.define = None
self.undef = None self.undef = None
self.debug = None
# set_default_options() # set_default_options()
def set_final_options (self): def set_final_options (self):
self.set_undefined_options ('build',
('debug', 'debug'))
self.libraries = self.distribution.libraries self.libraries = self.distribution.libraries
if self.include_dirs is None: if self.include_dirs is None:
self.include_dirs = self.distribution.include_dirs or [] self.include_dirs = self.distribution.include_dirs or []
...@@ -146,12 +151,13 @@ class BuildLib (Command): ...@@ -146,12 +151,13 @@ class BuildLib (Command):
objects = self.compiler.compile (sources, objects = self.compiler.compile (sources,
macros=macros, macros=macros,
include_dirs=include_dirs, include_dirs=include_dirs,
output_dir=lib_dir) output_dir=lib_dir,
debug=self.debug)
# Now "link" the object files together into a static library. # Now "link" the object files together into a static library.
# (On Unix at least, this isn't really linking -- it just # (On Unix at least, this isn't really linking -- it just
# builds an archive. Whatever.) # builds an archive. Whatever.)
self.compiler.link_static_lib (objects, lib_name) self.compiler.link_static_lib (objects, lib_name, debug=self.debug)
# for libraries # for libraries
......
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