[Python-checkins] python/dist/src/Lib/distutils unixccompiler.py,1.43,1.44

jhylton@users.sourceforge.net jhylton@users.sourceforge.net
Thu, 13 Jun 2002 08:14:15 -0700


Update of /cvsroot/python/python/dist/src/Lib/distutils
In directory usw-pr-cvs1:/tmp/cvs-serv25367

Modified Files:
	unixccompiler.py 
Log Message:
More style changes and little cleanups.

Remove __init__ that just called base class __init__ with same args.
Fold long argument lists into fewer, shorter lines.
Remove parens in tuple unpacks.
Don't put multiple statements on one line with a semicolon.
In find_library_file() compute the library_filename() upfront.


Index: unixccompiler.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/distutils/unixccompiler.py,v
retrieving revision 1.43
retrieving revision 1.44
diff -C2 -d -r1.43 -r1.44
*** unixccompiler.py	13 Jun 2002 15:01:38 -0000	1.43
--- unixccompiler.py	13 Jun 2002 15:14:10 -0000	1.44
***************
*** 80,99 ****
      static_lib_format = shared_lib_format = dylib_lib_format = "lib%s%s"
  
! 
! 
!     def __init__(self,
!                  verbose=0,
!                  dry_run=0,
!                  force=0):
!         CCompiler.__init__(self, verbose, dry_run, force)
! 
!     def preprocess(self,
!                    source,
!                    output_file=None,
!                    macros=None,
!                    include_dirs=None,
!                    extra_preargs=None,
!                    extra_postargs=None):
!         (_, macros, include_dirs) = \
              self._fix_compile_args(None, macros, include_dirs)
          pp_opts = gen_preprocess_options(macros, include_dirs)
--- 80,87 ----
      static_lib_format = shared_lib_format = dylib_lib_format = "lib%s%s"
  
!     def preprocess(self, source,
!                    output_file=None, macros=None, include_dirs=None,
!                    extra_preargs=None, extra_postargs=None):
!         ignore, macros, include_dirs = \
              self._fix_compile_args(None, macros, include_dirs)
          pp_opts = gen_preprocess_options(macros, include_dirs)
***************
*** 118,132 ****
                  raise CompileError, msg
  
!     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.
--- 106,115 ----
                  raise CompileError, msg
  
!     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.
***************
*** 143,147 ****
          # '_prep_compile()'.
          for i in range(len(sources)):
!             src = sources[i] ; obj = objects[i]
              if skip_sources[src]:
                  log.debug("skipping %s (%s up-to-date)", src, obj)
--- 126,131 ----
          # '_prep_compile()'.
          for i in range(len(sources)):
!             src = sources[i]
!             obj = objects[i]
              if skip_sources[src]:
                  log.debug("skipping %s (%s up-to-date)", src, obj)
***************
*** 150,155 ****
                  try:
                      self.spawn(self.compiler_so + cc_args +
!                                [src, '-o', obj] +
!                                extra_postargs)
                  except DistutilsExecError, msg:
                      raise CompileError, msg
--- 134,138 ----
                  try:
                      self.spawn(self.compiler_so + cc_args +
!                                [src, '-o', obj] + extra_postargs)
                  except DistutilsExecError, msg:
                      raise CompileError, msg
***************
*** 158,167 ****
          return objects
  
!     def create_static_lib(self,
!                           objects,
!                           output_libname,
!                           output_dir=None,
!                           debug=0):
!         (objects, output_dir) = self._fix_object_args(objects, output_dir)
  
          output_filename = \
--- 141,147 ----
          return objects
  
!     def create_static_lib(self, objects, output_libname,
!                           output_dir=None, debug=0):
!         objects, output_dir = self._fix_object_args(objects, output_dir)
  
          output_filename = \
***************
*** 187,209 ****
              log.debug("skipping %s (up-to-date)", output_filename)
  
!     def link(self,
!              target_desc,
!              objects,
!              output_filename,
!              output_dir=None,
!              libraries=None,
!              library_dirs=None,
!              runtime_library_dirs=None,
!              export_symbols=None,
!              debug=0,
!              extra_preargs=None,
!              extra_postargs=None,
!              build_temp=None):
!         (objects, output_dir) = self._fix_object_args(objects, output_dir)
!         (libraries, library_dirs, runtime_library_dirs) = \
              self._fix_lib_args(libraries, library_dirs, runtime_library_dirs)
  
!         lib_opts = gen_lib_options(self,
!                                    library_dirs, runtime_library_dirs,
                                     libraries)
          if type(output_dir) not in (StringType, NoneType):
--- 167,180 ----
              log.debug("skipping %s (up-to-date)", output_filename)
  
!     def link(self, target_desc, objects,
!              output_filename, output_dir=None, libraries=None,
!              library_dirs=None, runtime_library_dirs=None,
!              export_symbols=None, debug=0, extra_preargs=None,
!              extra_postargs=None, build_temp=None):
!         objects, output_dir = self._fix_object_args(objects, output_dir)
!         libraries, library_dirs, runtime_library_dirs = \
              self._fix_lib_args(libraries, library_dirs, runtime_library_dirs)
  
!         lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs,
                                     libraries)
          if type(output_dir) not in (StringType, NoneType):
***************
*** 262,273 ****
  
      def find_library_file(self, dirs, lib, debug=0):
          for dir in dirs:
!             shared = os.path.join(
!                 dir, self.library_filename(lib, lib_type='shared'))
!             dylib = os.path.join(
!                 dir, self.library_filename(lib, lib_type='dylib'))
!             static = os.path.join(
!                 dir, self.library_filename(lib, lib_type='static'))
! 
              # We're second-guessing the linker here, with not much hard
              # data to go on: GCC seems to prefer the shared library, so I'm
--- 233,244 ----
  
      def find_library_file(self, dirs, lib, debug=0):
+         shared_f = self.library_filename(lib, lib_type='shared')
+         dylib_f = self.library_filename(lib, lib_type='dylib')
+         static_f = self.library_filename(lib, lib_type='static')
+         
          for dir in dirs:
!             shared = os.path.join(dir, shared_f)
!             dylib = os.path.join(dir, dylib_f)
!             static = os.path.join(dir, static_f)
              # We're second-guessing the linker here, with not much hard
              # data to go on: GCC seems to prefer the shared library, so I'm
***************
*** 280,285 ****
              elif os.path.exists(static):
                  return static
! 
!         else:
!             # Oops, didn't find it in *any* of 'dirs'
!             return None
--- 251,255 ----
              elif os.path.exists(static):
                  return static
!             
!         # Oops, didn't find it in *any* of 'dirs'
!         return None