[Python-checkins] CVS: distutils/distutils ccompiler.py,1.26,1.27

Greg Ward python-dev@python.org
Sat, 24 Jun 2000 19:08:20 -0700


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

Modified Files:
	ccompiler.py 
Log Message:
Introduced some bureaucracy for setting and tracking the executables
that a particular compiler system depends on.  This consists of the
'set_executables()' and 'set_executable()' methods, and a few lines in
the constructor that expect implementation classes to provide an
'executables' attribute, which we use to initialize several instance
attributes.  The default implementation is somewhat biased in favour of
a Unix/DOS "command-line" view of the world, but it shouldn't be too
hard to override this for operating systems with a more sophisticated
way of representing programs-to-execute.


Index: ccompiler.py
===================================================================
RCS file: /cvsroot/python/distutils/distutils/ccompiler.py,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -r1.26 -r1.27
*** ccompiler.py	2000/06/24 18:10:48	1.26
--- ccompiler.py	2000/06/25 02:08:18	1.27
***************
*** 13,17 ****
  from distutils.errors import *
  from distutils.spawn import spawn
! from distutils.util import move_file, mkpath, newer_pairwise, newer_group
  
  
--- 13,20 ----
  from distutils.errors import *
  from distutils.spawn import spawn
! from distutils.file_util import move_file
! from distutils.dir_util import mkpath
! from distutils.dep_util import newer_pairwise, newer_group
! from distutils.util import split_quoted
  
  
***************
*** 110,116 ****
--- 113,166 ----
          self.objects = []
  
+         for key in self.executables.keys():
+             self.set_executable(key, self.executables[key])
+ 
      # __init__ ()
  
  
+     def set_executables (self, **args):
+ 
+         """Define the executables (and options for them) that will be run
+         to perform the various stages of compilation.  The exact set of
+         executables that may be specified here depends on the compiler
+         class (via the 'executables' class attribute), but most will have:
+           compiler      the C/C++ compiler
+           linker_so     linker used to create shared objects and libraries
+           linker_exe    linker used to create binary executables
+           archiver      static library creator
+ 
+         On platforms with a command-line (Unix, DOS/Windows), each of these
+         is a string that will be split into executable name and (optional)
+         list of arguments.  (Splitting the string is done similarly to how
+         Unix shells operate: words are delimited by spaces, but quotes and
+         backslashes can override this.  See
+         'distutils.util.split_quoted()'.)
+         """
+ 
+         # Note that some CCompiler implementation classes will define class
+         # attributes 'cpp', 'cc', etc. with hard-coded executable names;
+         # this is appropriate when a compiler class is for exactly one
+         # compiler/OS combination (eg. MSVCCompiler).  Other compiler
+         # classes (UnixCCompiler, in particular) are driven by information
+         # discovered at run-time, since there are many different ways to do
+         # basically the same things with Unix C compilers.
+ 
+         for key in args.keys():
+             if not self.executables.has_key(key):
+                 raise ValueError, \
+                       "unknown executable '%s' for class %s" % \
+                       (key, self.__class__.__name__)
+             self.set_executable(key, args[key])
+ 
+     # set_executables ()
+ 
+     def set_executable(self, key, value):
+         if type(value) is StringType:
+             setattr(self, key, split_quoted(value))
+         else:
+             setattr(self, key, value)
+         
+ 
+ 
      def _find_macro (self, name):
          i = 0
***************
*** 430,433 ****
--- 480,485 ----
          with 'define_macro()' and 'undefine_macro()'.  'include_dirs' is a
          list of directory names that will be added to the default list.
+ 
+         Raises PreprocessError on failure.
          """
          pass
***************
*** 441,446 ****
                   extra_preargs=None,
                   extra_postargs=None):
!         """Compile one or more C/C++ source files.  'sources' must be a
!         list of strings, each one the name of a C/C++ source file.  Return
          a list of object filenames, one per source filename in 'sources'.
          Depending on the implementation, not all source files will
--- 493,501 ----
                   extra_preargs=None,
                   extra_postargs=None):
! 
!         """Compile one or more source files.  'sources' must be a list of
!         filenames, most likely C/C++ files, but in reality anything that
!         can be handled by a particular compiler and compiler class
!         (eg. MSVCCompiler can handle resource files in 'sources').  Return
          a list of object filenames, one per source filename in 'sources'.
          Depending on the implementation, not all source files will