Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit db7aed5

Browse files
committed
[Patch #441691] preprocess() method for Borland C compiler.
I have no way of testing this.
1 parent 4d2dded commit db7aed5

1 file changed

Lines changed: 35 additions & 1 deletion

File tree

Lib/distutils/bcppcompiler.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from distutils.ccompiler import \
2222
CCompiler, gen_preprocess_options, gen_lib_options
2323
from distutils.file_util import write_file
24-
24+
from distutils.dep_util import newer
2525

2626
class BCPPCompiler(CCompiler) :
2727
"""Concrete class that implements an interface to the Borland C/C++
@@ -373,3 +373,37 @@ def object_filenames (self,
373373
return obj_names
374374

375375
# 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

Comments
 (0)