Commit 781da5cf authored by Tarek Ziadé's avatar Tarek Ziadé

Merged revisions 73354 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r73354 | tarek.ziade | 2009-06-11 11:55:09 +0200 (Thu, 11 Jun 2009) | 1 line

  pep8-fied cygwinccompiler module
........
parent e5ed970b
...@@ -84,8 +84,9 @@ def get_msvcr(): ...@@ -84,8 +84,9 @@ def get_msvcr():
raise ValueError("Unknown MS Compiler version %s " % msc_ver) raise ValueError("Unknown MS Compiler version %s " % msc_ver)
class CygwinCCompiler (UnixCCompiler): class CygwinCCompiler(UnixCCompiler):
""" Handles the Cygwin port of the GNU C compiler to Windows.
"""
compiler_type = 'cygwin' compiler_type = 'cygwin'
obj_extension = ".o" obj_extension = ".o"
static_lib_extension = ".a" static_lib_extension = ".a"
...@@ -94,11 +95,11 @@ class CygwinCCompiler (UnixCCompiler): ...@@ -94,11 +95,11 @@ class CygwinCCompiler (UnixCCompiler):
shared_lib_format = "%s%s" shared_lib_format = "%s%s"
exe_extension = ".exe" exe_extension = ".exe"
def __init__ (self, verbose=0, dry_run=0, force=0): def __init__(self, verbose=0, dry_run=0, force=0):
UnixCCompiler.__init__ (self, verbose, dry_run, force) UnixCCompiler.__init__(self, verbose, dry_run, force)
(status, details) = check_config_h() status, details = check_config_h()
self.debug_print("Python's GCC status: %s (details: %s)" % self.debug_print("Python's GCC status: %s (details: %s)" %
(status, details)) (status, details))
if status is not CONFIG_H_OK: if status is not CONFIG_H_OK:
...@@ -153,10 +154,8 @@ class CygwinCCompiler (UnixCCompiler): ...@@ -153,10 +154,8 @@ class CygwinCCompiler (UnixCCompiler):
# with MSVC 7.0 or later. # with MSVC 7.0 or later.
self.dll_libraries = get_msvcr() self.dll_libraries = get_msvcr()
# __init__ ()
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts): def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
"""Compiles the source by spawing GCC and windres if needed."""
if ext == '.rc' or ext == '.res': if ext == '.rc' or ext == '.res':
# gcc needs '.res' and '.rc' compiled to object files !!! # gcc needs '.res' and '.rc' compiled to object files !!!
try: try:
...@@ -170,21 +169,11 @@ class CygwinCCompiler (UnixCCompiler): ...@@ -170,21 +169,11 @@ class CygwinCCompiler (UnixCCompiler):
except DistutilsExecError as msg: except DistutilsExecError as msg:
raise CompileError(msg) raise CompileError(msg)
def link (self, def link(self, target_desc, objects, output_filename, output_dir=None,
target_desc, libraries=None, library_dirs=None, runtime_library_dirs=None,
objects, export_symbols=None, debug=0, extra_preargs=None,
output_filename, extra_postargs=None, build_temp=None, target_lang=None):
output_dir=None, """Link the objects."""
libraries=None,
library_dirs=None,
runtime_library_dirs=None,
export_symbols=None,
debug=0,
extra_preargs=None,
extra_postargs=None,
build_temp=None,
target_lang=None):
# use separate copies, so we can modify the lists # use separate copies, so we can modify the lists
extra_preargs = copy.copy(extra_preargs or []) extra_preargs = copy.copy(extra_preargs or [])
libraries = copy.copy(libraries or []) libraries = copy.copy(libraries or [])
...@@ -249,63 +238,44 @@ class CygwinCCompiler (UnixCCompiler): ...@@ -249,63 +238,44 @@ class CygwinCCompiler (UnixCCompiler):
if not debug: if not debug:
extra_preargs.append("-s") extra_preargs.append("-s")
UnixCCompiler.link(self, UnixCCompiler.link(self, target_desc, objects, output_filename,
target_desc, output_dir, libraries, library_dirs,
objects,
output_filename,
output_dir,
libraries,
library_dirs,
runtime_library_dirs, runtime_library_dirs,
None, # export_symbols, we do this in our def-file None, # export_symbols, we do this in our def-file
debug, debug, extra_preargs, extra_postargs, build_temp,
extra_preargs,
extra_postargs,
build_temp,
target_lang) target_lang)
# link ()
# -- Miscellaneous methods ----------------------------------------- # -- Miscellaneous methods -----------------------------------------
# overwrite the one from CCompiler to support rc and res-files def object_filenames(self, source_filenames, strip_dir=0, output_dir=''):
def object_filenames (self, """Adds supports for rc and res files."""
source_filenames, if output_dir is None:
strip_dir=0, output_dir = ''
output_dir=''):
if output_dir is None: output_dir = ''
obj_names = [] obj_names = []
for src_name in source_filenames: for src_name in source_filenames:
# use normcase to make sure '.rc' is really '.rc' and not '.RC' # use normcase to make sure '.rc' is really '.rc' and not '.RC'
(base, ext) = os.path.splitext (os.path.normcase(src_name)) base, ext = os.path.splitext(os.path.normcase(src_name))
if ext not in (self.src_extensions + ['.rc','.res']): if ext not in (self.src_extensions + ['.rc','.res']):
raise UnknownFileError("unknown file type '%s' (from '%s')" % \ raise UnknownFileError("unknown file type '%s' (from '%s')" % \
(ext, src_name)) (ext, src_name))
if strip_dir: if strip_dir:
base = os.path.basename (base) base = os.path.basename (base)
if ext == '.res' or ext == '.rc': if ext in ('.res', '.rc'):
# these need to be compiled to object files # these need to be compiled to object files
obj_names.append (os.path.join (output_dir, obj_names.append (os.path.join(output_dir,
base + ext + self.obj_extension)) base + ext + self.obj_extension))
else: else:
obj_names.append (os.path.join (output_dir, obj_names.append (os.path.join(output_dir,
base + self.obj_extension)) base + self.obj_extension))
return obj_names return obj_names
# object_filenames ()
# class CygwinCCompiler
# the same as cygwin plus some additional parameters # the same as cygwin plus some additional parameters
class Mingw32CCompiler (CygwinCCompiler): class Mingw32CCompiler(CygwinCCompiler):
""" Handles the Mingw32 port of the GNU C compiler to Windows.
"""
compiler_type = 'mingw32' compiler_type = 'mingw32'
def __init__ (self, def __init__(self, verbose=0, dry_run=0, force=0):
verbose=0,
dry_run=0,
force=0):
CygwinCCompiler.__init__ (self, verbose, dry_run, force) CygwinCCompiler.__init__ (self, verbose, dry_run, force)
...@@ -341,10 +311,6 @@ class Mingw32CCompiler (CygwinCCompiler): ...@@ -341,10 +311,6 @@ class Mingw32CCompiler (CygwinCCompiler):
# with MSVC 7.0 or later. # with MSVC 7.0 or later.
self.dll_libraries = get_msvcr() self.dll_libraries = get_msvcr()
# __init__ ()
# class Mingw32CCompiler
# Because these compilers aren't configured in Python's pyconfig.h file by # Because these compilers aren't configured in Python's pyconfig.h file by
# default, we should at least warn the user if he is using a unmodified # default, we should at least warn the user if he is using a unmodified
# version. # version.
......
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