]> granicus.if.org Git - python/commitdiff
Add a default implementation of compile() to the base class.
authorJeremy Hylton <jeremy@alum.mit.edu>
Tue, 18 Jun 2002 18:42:41 +0000 (18:42 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Tue, 18 Jun 2002 18:42:41 +0000 (18:42 +0000)
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.

Lib/distutils/ccompiler.py

index 50246b8961e8da17aafdc1850a5e7b1cadb31360..f1a50cbddcf79432c9ae39d0d7dbf8460ff37b18 100644 (file)
@@ -644,8 +644,27 @@ class CCompiler:
 
         Raises CompileError on failure.
         """
-        pass
 
+        # A concrete compiler class can either override this method
+        # entirely or implement _compile().
+        
+        macros, objects, extra_postargs, pp_opts, build = \
+                self._setup_compile(output_dir, macros, include_dirs, sources,
+                                    depends, extra_postargs)
+        cc_args = self._get_cc_args(pp_opts, debug, extra_preargs)
+
+        for obj, (src, ext) in build.items():
+            self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
+
+        # Return *all* object filenames, not just the ones we just built.
+        return objects
+
+    def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
+        """Compile 'src' to product 'obj'."""
+        
+        # A concrete compiler class that does not override compile()
+        # should implement _compile().
+        pass
 
     def create_static_lib (self,
                            objects,