diff options
author | Greg Ward <gward@python.net> | 2000-06-21 02:58:46 (GMT) |
---|---|---|
committer | Greg Ward <gward@python.net> | 2000-06-21 02:58:46 (GMT) |
commit | 3ff3b039ac25f70cf6be3775dca0e21c2666d3d3 (patch) | |
tree | d229a2ee9257400ec6f6cf234ea1772e6ceaf0fa /Lib/distutils/unixccompiler.py | |
parent | a4ca07cc8c4626e5e9b94f27da75959bba14ffac (diff) | |
download | cpython-3ff3b039ac25f70cf6be3775dca0e21c2666d3d3.zip cpython-3ff3b039ac25f70cf6be3775dca0e21c2666d3d3.tar.gz cpython-3ff3b039ac25f70cf6be3775dca0e21c2666d3d3.tar.bz2 |
Added 'preprocess()' method to CCompiler interface, and implemented
it in UnixCCompiler. Still needs to be implemented in MSVCCompiler (and
whatever other compiler classes are lurking out there, waiting to be
checked in).
Diffstat (limited to 'Lib/distutils/unixccompiler.py')
-rw-r--r-- | Lib/distutils/unixccompiler.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/Lib/distutils/unixccompiler.py b/Lib/distutils/unixccompiler.py index 4d38e4d..47d8ad6 100644 --- a/Lib/distutils/unixccompiler.py +++ b/Lib/distutils/unixccompiler.py @@ -21,6 +21,7 @@ import string, re, os from types import * from copy import copy from distutils import sysconfig +from distutils.dep_util import newer from distutils.ccompiler import \ CCompiler, gen_preprocess_options, gen_lib_options from distutils.errors import \ @@ -104,6 +105,37 @@ class UnixCCompiler (CCompiler): # __init__ () + 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) + cc_args = ['-E'] + pp_opts + if output_file: + cc_args.extend(['-o', output_file]) + if extra_preargs: + cc_args[:0] = extra_preargs + if extra_postargs: + extra_postargs.extend(extra_postargs) + + # We need to preprocess: either we're being forced to, or the + # source file is newer than the target (or the target doesn't + # exist). + if self.force or (output_file and newer(source, output_file)): + if output_file: + self.mkpath(os.path.dirname(output_file)) + try: + self.spawn ([self.cc] + cc_args) + except DistutilsExecError, msg: + raise CompileError, msg + + def compile (self, sources, output_dir=None, |