[Python-checkins] CVS: distutils/distutils ccompiler.py,1.19,1.20 unixccompiler.py,1.23,1.24 msvccompiler.py,1.28,1.29

Greg Ward python-dev@python.org
Mon, 29 May 2000 18:56:47 -0700


Update of /cvsroot/python/distutils/distutils
In directory slayer.i.sourceforge.net:/tmp/cvs-serv1343

Modified Files:
	ccompiler.py unixccompiler.py msvccompiler.py 
Log Message:
Changed to catch compile/link failures and raise CompileError, LibError,
or LinkError (exception classes defined in ccompiler.py).

Index: ccompiler.py
===================================================================
RCS file: /cvsroot/python/distutils/distutils/ccompiler.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** ccompiler.py	2000/05/20 13:31:32	1.19
--- ccompiler.py	2000/05/30 01:56:43	1.20
***************
*** 6,10 ****
  # created 1999/07/05, Greg Ward
  
! __revision__ = "$Id: ccompiler.py,v 1.19 2000/05/20 13:31:32 gward Exp $"
  
  import sys, os
--- 6,10 ----
  # created 1999/07/05, Greg Ward
  
! __revision__ = "$Id: ccompiler.py,v 1.20 2000/05/30 01:56:43 gward Exp $"
  
  import sys, os
***************
*** 16,19 ****
--- 16,35 ----
  
  
+ # Exception classes used by the CCompiler implementation classes
+ class CCompilerError (Exception):
+     """Failure doing some compile/link operation."""
+ 
+ class CompileError (CCompilerError):
+     """Failure to compile one or more C/C++ source files."""
+ 
+ class LibError (CCompilerError):
+     """Failure to create a static library from one or more C/C++ object
+     files."""
+ 
+ class LinkError (CCompilerError):
+     """Failure to link one or more C/C++ object files into an executable
+     or shared library file."""
+ 
+ 
  class CCompiler:
      """Abstract base class to define the interface that must be implemented
***************
*** 457,461 ****
             class documentation.  In any event, they are intended as an
             escape hatch for those occasions when the abstract compiler
!            framework doesn't cut the mustard."""
             
          pass
--- 473,479 ----
             class documentation.  In any event, they are intended as an
             escape hatch for those occasions when the abstract compiler
!            framework doesn't cut the mustard.
! 
!            Raises CompileError on failure."""
             
          pass
***************
*** 482,486 ****
             included in the library (note that on most platforms, it is the
             compile step where this matters: the 'debug' flag is included
!            here just for consistency)."""
  
          pass
--- 500,506 ----
             included in the library (note that on most platforms, it is the
             compile step where this matters: the 'debug' flag is included
!            here just for consistency).
! 
!            Raises LibError on failure."""
  
          pass
***************
*** 532,537 ****
             'extra_preargs' and 'extra_postargs' are as for 'compile()'
             (except of course that they supply command-line arguments
!            for the particular linker being used)."""           
  
          pass
      
--- 552,559 ----
             'extra_preargs' and 'extra_postargs' are as for 'compile()'
             (except of course that they supply command-line arguments
!            for the particular linker being used).
  
+            Raises LinkError on failure."""
+ 
          pass
      
***************
*** 553,557 ****
             supplied, 'output_filename' is relative to it
             (i.e. 'output_filename' can provide directory components if
!            needed)."""
          pass
  
--- 575,581 ----
             supplied, 'output_filename' is relative to it
             (i.e. 'output_filename' can provide directory components if
!            needed).
! 
!            Raises LinkError on failure."""
          pass
  
***************
*** 571,575 ****
             'output_progname' should be the base name of the executable
             program--e.g. on Unix the same as the output filename, but
!            on DOS/Windows ".exe" will be appended."""
          pass
  
--- 595,601 ----
             'output_progname' should be the base name of the executable
             program--e.g. on Unix the same as the output filename, but
!            on DOS/Windows ".exe" will be appended.
! 
!            Raises LinkError on failure."""
          pass
  

Index: unixccompiler.py
===================================================================
RCS file: /cvsroot/python/distutils/distutils/unixccompiler.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -r1.23 -r1.24
*** unixccompiler.py	2000/05/20 13:23:21	1.23
--- unixccompiler.py	2000/05/30 01:56:44	1.24
***************
*** 16,20 ****
  # created 1999/07/05, Greg Ward
  
! __revision__ = "$Id: unixccompiler.py,v 1.23 2000/05/20 13:23:21 gward Exp $"
  
  import string, re, os
--- 16,20 ----
  # created 1999/07/05, Greg Ward
  
! __revision__ = "$Id: unixccompiler.py,v 1.24 2000/05/30 01:56:44 gward Exp $"
  
  import string, re, os
***************
*** 22,26 ****
  from copy import copy
  from distutils import sysconfig
! from distutils.ccompiler import CCompiler, gen_preprocess_options, gen_lib_options
  
  # XXX Things not currently handled:
--- 22,29 ----
  from copy import copy
  from distutils import sysconfig
! from distutils.ccompiler import \
!      CCompiler, gen_preprocess_options, gen_lib_options, \
!      CompileError, LibError, LinkError
! from distutils.errors import DistutilsExecError
  
  # XXX Things not currently handled:
***************
*** 133,137 ****
              else:
                  self.mkpath (os.path.dirname (obj))
!                 self.spawn ([self.cc] + cc_args + [src, '-o', obj] + extra_postargs)
  
          # Return *all* object filenames, not just the ones we just built.
--- 136,145 ----
              else:
                  self.mkpath (os.path.dirname (obj))
!                 try:
!                     self.spawn ([self.cc] + cc_args +
!                                 [src, '-o', obj] +
!                                 extra_postargs)
!                 except DistutilsExecError, msg:
!                     raise CompileError, msg
  
          # Return *all* object filenames, not just the ones we just built.
***************
*** 165,169 ****
              # it for us, hence the check for leading colon.
              if self.ranlib[0] != ':':
!                 self.spawn ([self.ranlib, output_filename])
          else:
              self.announce ("skipping %s (up-to-date)" % output_filename)
--- 173,180 ----
              # it for us, hence the check for leading colon.
              if self.ranlib[0] != ':':
!                 try:
!                     self.spawn ([self.ranlib, output_filename])
!                 except DistutilsExecError, msg:
!                     raise LibError, msg
          else:
              self.announce ("skipping %s (up-to-date)" % output_filename)
***************
*** 230,234 ****
                  ld_args.extend (extra_postargs)
              self.mkpath (os.path.dirname (output_filename))
!             self.spawn ([self.ld_shared] + ld_args)
          else:
              self.announce ("skipping %s (up-to-date)" % output_filename)
--- 241,248 ----
                  ld_args.extend (extra_postargs)
              self.mkpath (os.path.dirname (output_filename))
!             try:
!                 self.spawn ([self.ld_shared] + ld_args)
!             except DistutilsExecError, msg:
!                 raise LinkError, msg
          else:
              self.announce ("skipping %s (up-to-date)" % output_filename)
***************
*** 268,272 ****
                  ld_args.extend (extra_postargs)
              self.mkpath (os.path.dirname (output_filename))
!             self.spawn ([self.ld_exec] + ld_args)
          else:
              self.announce ("skipping %s (up-to-date)" % output_filename)
--- 282,289 ----
                  ld_args.extend (extra_postargs)
              self.mkpath (os.path.dirname (output_filename))
!             try:
!                 self.spawn ([self.ld_exec] + ld_args)
!             except DistutilsExecError, msg:
!                 raise LinkError, msg
          else:
              self.announce ("skipping %s (up-to-date)" % output_filename)

Index: msvccompiler.py
===================================================================
RCS file: /cvsroot/python/distutils/distutils/msvccompiler.py,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -r1.28 -r1.29
*** msvccompiler.py	2000/05/20 13:23:21	1.28
--- msvccompiler.py	2000/05/30 01:56:44	1.29
***************
*** 9,13 ****
  #   finding DevStudio (through the registry)
  
! __revision__ = "$Id: msvccompiler.py,v 1.28 2000/05/20 13:23:21 gward Exp $"
  
  import sys, os, string
--- 9,13 ----
  #   finding DevStudio (through the registry)
  
! __revision__ = "$Id: msvccompiler.py,v 1.29 2000/05/30 01:56:44 gward Exp $"
  
  import sys, os, string
***************
*** 15,19 ****
  from distutils.errors import *
  from distutils.ccompiler import \
!      CCompiler, gen_preprocess_options, gen_lib_options
  
  
--- 15,20 ----
  from distutils.errors import *
  from distutils.ccompiler import \
!      CCompiler, gen_preprocess_options, gen_lib_options, \
!      CompileError, LibError, LinkError
  
  
***************
*** 262,268 ****
  
                  self.mkpath (os.path.dirname (obj))
!                 self.spawn ([self.cc] + compile_opts + pp_opts +
!                             [input_opt, output_opt] +
!                             extra_postargs)
  
          return objects
--- 263,272 ----
  
                  self.mkpath (os.path.dirname (obj))
!                 try:
!                     self.spawn ([self.cc] + compile_opts + pp_opts +
!                                 [input_opt, output_opt] +
!                                 extra_postargs)
!                 except DistutilsExecError, msg:
!                     raise CompileError, msg
  
          return objects
***************
*** 291,295 ****
              if extra_postargs:
                  lib_args.extend (extra_postargs)
!             self.spawn ([self.link] + ld_args)
          else:
              self.announce ("skipping %s (up-to-date)" % output_filename)
--- 295,303 ----
              if extra_postargs:
                  lib_args.extend (extra_postargs)
!             try:
!                 self.spawn ([self.link] + ld_args)
!             except DistutilsExecError, msg:
!                 raise LibError, msg
!                 
          else:
              self.announce ("skipping %s (up-to-date)" % output_filename)
***************
*** 371,375 ****
              print "  mkpath'ing:", os.path.dirname (output_filename)
              self.mkpath (os.path.dirname (output_filename))
!             self.spawn ([self.link] + ld_args)
  
          else:
--- 379,386 ----
              print "  mkpath'ing:", os.path.dirname (output_filename)
              self.mkpath (os.path.dirname (output_filename))
!             try:
!                 self.spawn ([self.link] + ld_args)
!             except DistutilsExecError, msg:
!                 raise LinkError, msg
  
          else:
***************
*** 421,425 ****
  
              self.mkpath (os.path.dirname (output_filename))
!             self.spawn ([self.link] + ld_args)
          else:
              self.announce ("skipping %s (up-to-date)" % output_filename)   
--- 432,439 ----
  
              self.mkpath (os.path.dirname (output_filename))
!             try:
!                 self.spawn ([self.link] + ld_args)
!             except DistutilsExecError, msg:
!                 raise LinkError, msg
          else:
              self.announce ("skipping %s (up-to-date)" % output_filename)