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

Skip to content

Commit 6e08d22

Browse files
committed
Add a default implementation of compile() to the base class.
The default implementation calls _compile() to compile individual files. This method must be implemented by the subclass. This change factors out most of the remaining common code in all the compilers except mwerks.
1 parent 0747121 commit 6e08d22

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

Lib/distutils/ccompiler.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,8 +644,27 @@ def compile(self, sources, output_dir=None, macros=None,
644644
645645
Raises CompileError on failure.
646646
"""
647-
pass
648647

648+
# A concrete compiler class can either override this method
649+
# entirely or implement _compile().
650+
651+
macros, objects, extra_postargs, pp_opts, build = \
652+
self._setup_compile(output_dir, macros, include_dirs, sources,
653+
depends, extra_postargs)
654+
cc_args = self._get_cc_args(pp_opts, debug, extra_preargs)
655+
656+
for obj, (src, ext) in build.items():
657+
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
658+
659+
# Return *all* object filenames, not just the ones we just built.
660+
return objects
661+
662+
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
663+
"""Compile 'src' to product 'obj'."""
664+
665+
# A concrete compiler class that does not override compile()
666+
# should implement _compile().
667+
pass
649668

650669
def create_static_lib (self,
651670
objects,

0 commit comments

Comments
 (0)