diff options
Diffstat (limited to 'src/distutils2/compiler/ccompiler.py')
| -rw-r--r-- | src/distutils2/compiler/ccompiler.py | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/distutils2/compiler/ccompiler.py b/src/distutils2/compiler/ccompiler.py index 025febd..c9bb129 100644 --- a/src/distutils2/compiler/ccompiler.py +++ b/src/distutils2/compiler/ccompiler.py @@ -10,9 +10,8 @@ import os import re from distutils2.errors import (CompileError, LinkError, UnknownFileError, - DistutilsPlatformError, DistutilsModuleError) -from distutils2.spawn import spawn -from distutils2.util import split_quoted, execute, newer_group + DistutilsPlatformError, DistutilsModuleError) +from distutils2.util import split_quoted, execute, newer_group, spawn from distutils2 import log from shutil import move @@ -76,7 +75,7 @@ def customize_compiler(compiler): compiler.shared_lib_extension = so_ext -class CCompiler: +class CCompiler(object): """Abstract base class to define the interface that must be implemented by real compiler classes. Also has some utility methods used by several compiler classes. @@ -800,14 +799,16 @@ class CCompiler: library_dirs = [] fd, fname = tempfile.mkstemp(".c", funcname, text=True) f = os.fdopen(fd, "w") - for incl in includes: - f.write("""#include "%s"\n""" % incl) - f.write("""\ + try: + for incl in includes: + f.write("""#include "%s"\n""" % incl) + f.write("""\ main (int argc, char **argv) { %s(); } """ % funcname) - f.close() + finally: + f.close() try: objects = self.compile([fname], include_dirs=include_dirs) except CompileError: @@ -938,8 +939,10 @@ main (int argc, char **argv) { if os.path.isdir(name) or name == '': return if self.dry_run: + head = '' for part in name.split(os.sep): - self.log(part) + log.info("created directory %s%s", head, part) + head += part + os.sep return os.makedirs(name, mode) @@ -1048,7 +1051,7 @@ def new_compiler(plat=None, compiler=None, verbose=0, dry_run=0, force=0): module_name = "distutils2.compiler." + module_name __import__ (module_name) module = sys.modules[module_name] - klass = vars(module)[class_name] + cls = vars(module)[class_name] except ImportError: raise DistutilsModuleError, \ "can't compile C/C++ code: unable to load module '%s'" % \ @@ -1061,7 +1064,7 @@ def new_compiler(plat=None, compiler=None, verbose=0, dry_run=0, force=0): # XXX The None is necessary to preserve backwards compatibility # with classes that expect verbose to be the first positional # argument. - return klass(None, dry_run, force) + return cls(None, dry_run, force) def gen_preprocess_options(macros, include_dirs): |
