summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/cygwinccompiler.py
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2002-06-13 17:28:18 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2002-06-13 17:28:18 (GMT)
commit1bba31d9a2dd24824a36b7e02cab7a9502587269 (patch)
tree73251af664eaf462bf848864c6af00c3761eacbd /Lib/distutils/cygwinccompiler.py
parent6864d30dfedc7325540fbed580dc35d24b56a41d (diff)
downloadcpython-1bba31d9a2dd24824a36b7e02cab7a9502587269.zip
cpython-1bba31d9a2dd24824a36b7e02cab7a9502587269.tar.gz
cpython-1bba31d9a2dd24824a36b7e02cab7a9502587269.tar.bz2
Refactor compile() method implementations.
Always use _setup_compile() to do the grunt work of processing arguments, figuring out which files to compile, and emitting debug messages for files that are up-to-date. Use _get_cc_args() when possible.
Diffstat (limited to 'Lib/distutils/cygwinccompiler.py')
-rw-r--r--Lib/distutils/cygwinccompiler.py85
1 files changed, 29 insertions, 56 deletions
diff --git a/Lib/distutils/cygwinccompiler.py b/Lib/distutils/cygwinccompiler.py
index 443c9bc..302293a 100644
--- a/Lib/distutils/cygwinccompiler.py
+++ b/Lib/distutils/cygwinccompiler.py
@@ -62,10 +62,7 @@ class CygwinCCompiler (UnixCCompiler):
shared_lib_format = "%s%s"
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)
@@ -74,11 +71,12 @@ class CygwinCCompiler (UnixCCompiler):
(status, details))
if status is not CONFIG_H_OK:
self.warn(
- "Python's pyconfig.h doesn't seem to support your compiler. " +
- ("Reason: %s." % details) +
- "Compiling may fail because of undefined preprocessor macros.")
+ "Python's pyconfig.h doesn't seem to support your compiler. "
+ "Reason: %s. "
+ "Compiling may fail because of undefined preprocessor macros."
+ % details)
- (self.gcc_version, self.ld_version, self.dllwrap_version) = \
+ self.gcc_version, self.ld_version, self.dllwrap_version = \
get_versions()
self.debug_print(self.compiler_type + ": gcc %s, ld %s, dllwrap %s\n" %
(self.gcc_version,
@@ -120,58 +118,33 @@ class CygwinCCompiler (UnixCCompiler):
# we put here a adapted version of it.
# (If we would call compile() in the base class, it would do some
# initializations a second time, this is why all is done here.)
- def compile (self,
- sources,
- output_dir=None,
- macros=None,
- include_dirs=None,
- debug=0,
- extra_preargs=None,
- extra_postargs=None):
-
- (output_dir, macros, include_dirs) = \
- self._fix_compile_args (output_dir, macros, include_dirs)
- (objects, skip_sources) = self._prep_compile (sources, output_dir)
-
- # Figure out the options for the compiler command line.
- pp_opts = gen_preprocess_options (macros, include_dirs)
- cc_args = pp_opts + ['-c']
- if debug:
- cc_args[:0] = ['-g']
- if extra_preargs:
- cc_args[:0] = extra_preargs
- if extra_postargs is None:
- extra_postargs = []
-
- # Compile all source files that weren't eliminated by
- # '_prep_compile()'.
- for i in range (len (sources)):
- src = sources[i] ; obj = objects[i]
- ext = (os.path.splitext (src))[1]
- if skip_sources[src]:
- log.debug("skipping %s (%s up-to-date)", src, obj)
- else:
- self.mkpath (os.path.dirname (obj))
- if ext == '.rc' or ext == '.res':
- # gcc needs '.res' and '.rc' compiled to object files !!!
- try:
- self.spawn (["windres","-i",src,"-o",obj])
- except DistutilsExecError, msg:
- raise CompileError, msg
- else: # for other files use the C-compiler
- try:
- self.spawn (self.compiler_so + cc_args +
- [src, '-o', obj] +
- extra_postargs)
- except DistutilsExecError, msg:
- raise CompileError, msg
+ def compile(self, sources,
+ output_dir=None, macros=None, include_dirs=None, debug=0,
+ extra_preargs=None, extra_postargs=None, depends=None):
+
+ macros, objects, extra_postargs, pp_opts, build = \
+ self._setup_compile(output_dir, macros, include_dirs, sources,
+ depends, extra_postargs)
+ cc_args = self._get_cc_args(pp_opts, debug, extra_preargs)
+
+ for obj, (src, ext) in build.items():
+ if ext == '.rc' or ext == '.res':
+ # gcc needs '.res' and '.rc' compiled to object files !!!
+ try:
+ self.spawn (["windres","-i",src,"-o",obj])
+ except DistutilsExecError, msg:
+ raise CompileError, msg
+ else: # for other files use the C-compiler
+ try:
+ self.spawn (self.compiler_so + cc_args +
+ [src, '-o', obj] +
+ extra_postargs)
+ except DistutilsExecError, msg:
+ raise CompileError, msg
# Return *all* object filenames, not just the ones we just built.
return objects
- # compile ()
-
-
def link (self,
target_desc,
objects,