|
21 | 21 | from distutils.ccompiler import \ |
22 | 22 | CCompiler, gen_preprocess_options, gen_lib_options |
23 | 23 | from distutils.file_util import write_file |
24 | | - |
| 24 | +from distutils.dep_util import newer |
25 | 25 |
|
26 | 26 | class BCPPCompiler(CCompiler) : |
27 | 27 | """Concrete class that implements an interface to the Borland C/C++ |
@@ -373,3 +373,37 @@ def object_filenames (self, |
373 | 373 | return obj_names |
374 | 374 |
|
375 | 375 | # object_filenames () |
| 376 | + |
| 377 | + def preprocess (self, |
| 378 | + source, |
| 379 | + output_file=None, |
| 380 | + macros=None, |
| 381 | + include_dirs=None, |
| 382 | + extra_preargs=None, |
| 383 | + extra_postargs=None): |
| 384 | + |
| 385 | + (_, macros, include_dirs) = \ |
| 386 | + self._fix_compile_args(None, macros, include_dirs) |
| 387 | + pp_opts = gen_preprocess_options(macros, include_dirs) |
| 388 | + pp_args = ['cpp32.exe'] + pp_opts |
| 389 | + if output_file is not None: |
| 390 | + pp_args.append('-o' + output_file) |
| 391 | + if extra_preargs: |
| 392 | + pp_args[:0] = extra_preargs |
| 393 | + if extra_postargs: |
| 394 | + pp_args.extend(extra_postargs) |
| 395 | + pp_args.append(source) |
| 396 | + |
| 397 | + # We need to preprocess: either we're being forced to, or the |
| 398 | + # source file is newer than the target (or the target doesn't |
| 399 | + # exist). |
| 400 | + if self.force or output_file is None or newer(source, output_file): |
| 401 | + if output_file: |
| 402 | + self.mkpath(os.path.dirname(output_file)) |
| 403 | + try: |
| 404 | + self.spawn(pp_args) |
| 405 | + except DistutilsExecError, msg: |
| 406 | + print msg |
| 407 | + raise CompileError, msg |
| 408 | + |
| 409 | + # preprocess() |
0 commit comments