diff options
author | Greg Ward <gward@python.net> | 1999-09-13 03:07:24 (GMT) |
---|---|---|
committer | Greg Ward <gward@python.net> | 1999-09-13 03:07:24 (GMT) |
commit | 9b17cb58198365c9eac65a1823b7e72279caa332 (patch) | |
tree | 452bfacef31d5fb7975604ffed2e7de4cbb5ec08 /Lib | |
parent | 1ae32466792dde8eab7cafc933f1dbb5984847f6 (diff) | |
download | cpython-9b17cb58198365c9eac65a1823b7e72279caa332.zip cpython-9b17cb58198365c9eac65a1823b7e72279caa332.tar.gz cpython-9b17cb58198365c9eac65a1823b7e72279caa332.tar.bz2 |
Added 'output_dir' attribute, and 'output_dir' parameter to several method
signatures, and updated some docstrings to reflect it.
Some comments added.
Added 'announce()' and 'move_file()' methods.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/distutils/ccompiler.py | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/Lib/distutils/ccompiler.py b/Lib/distutils/ccompiler.py index b1167ac..0e50533 100644 --- a/Lib/distutils/ccompiler.py +++ b/Lib/distutils/ccompiler.py @@ -12,6 +12,7 @@ from types import * from copy import copy from distutils.errors import * from distutils.spawn import spawn +from distutils.util import move_file class CCompiler: @@ -62,6 +63,10 @@ class CCompiler: self.verbose = verbose self.dry_run = dry_run + # 'output_dir': a common output directory for object, library, + # shared object, and shared library files + self.output_dir = None + # 'macros': a list of macro definitions (or undefinitions). A # macro definition is a 2-tuple (name, value), where the value is # either a string or None (no explicit value). A macro @@ -244,6 +249,7 @@ class CCompiler: def compile (self, sources, + output_dir=None, macros=None, includes=None): """Compile one or more C/C++ source files. 'sources' must be @@ -270,6 +276,7 @@ class CCompiler: def link_static_lib (self, objects, output_libname, + output_dir=None, libraries=None, library_dirs=None): """Link a bunch of stuff together to create a static library @@ -317,6 +324,7 @@ class CCompiler: def link_shared_lib (self, objects, output_libname, + output_dir=None, libraries=None, library_dirs=None, build_info=None): @@ -330,25 +338,37 @@ class CCompiler: def link_shared_object (self, objects, output_filename, + output_dir=None, libraries=None, library_dirs=None, build_info=None): """Link a bunch of stuff together to create a shared object - file. Much like 'link_shared_lib()', except the output - filename is explicitly supplied as 'output_filename'.""" + file. Much like 'link_shared_lib()', except the output filename + is explicitly supplied as 'output_filename'. If 'output_dir' is + supplied, 'output_filename' is relative to it + (i.e. 'output_filename' can provide directoriy components if + needed).""" pass # -- Filename mangling methods ------------------------------------- - def object_filenames (self, source_filenames): + # General principle for the filename-mangling methods: by default, + # don't include a directory component, no matter what the caller + # supplies. Eg. for UnixCCompiler, a source file of "foo/bar/baz.c" + # becomes "baz.o" or "baz.so", etc. (That way, it's easiest for the + # caller to decide where it wants to put/find the output file.) The + # 'output_dir' parameter overrides this, of course -- the directory + # component of the input filenames is replaced by 'output_dir'. + + def object_filenames (self, source_filenames, output_dir=None): """Return the list of object filenames corresponding to each specified source filename.""" pass def shared_object_filename (self, source_filename): """Return the shared object filename corresponding to a - specified source filename.""" + specified source filename (assuming the same directory).""" pass def library_filename (self, libname): @@ -362,7 +382,7 @@ class CCompiler: specified library name.""" pass - + # XXX ugh -- these should go! def object_name (self, inname): """Given a name with no extension, return the name + object extension""" return inname + self._obj_ext @@ -373,9 +393,16 @@ class CCompiler: # -- Utility methods ----------------------------------------------- + def announce (self, msg, level=1): + if self.verbose >= level: + print msg + def spawn (self, cmd): spawn (cmd, verbose=self.verbose, dry_run=self.dry_run) + def move_file (self, src, dst): + return move_file (src, dst, verbose=self.verbose, dry_run=self.dry_run) + # class CCompiler @@ -393,7 +420,7 @@ def new_compiler (plat=None, return UnixCCompiler (verbose, dry_run) elif plat == 'nt': from msvccompiler import MSVCCompiler - return MSVCCompiler ( verbose, dry_run ) + return MSVCCompiler (verbose, dry_run) else: raise DistutilsPlatformError, \ "don't know how to compile C/C++ code on platform %s" % plat |