]> granicus.if.org Git - python/commitdiff
Add implementation of _compile() and use default compile() method.
authorJeremy Hylton <jeremy@alum.mit.edu>
Tue, 18 Jun 2002 18:48:55 +0000 (18:48 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Tue, 18 Jun 2002 18:48:55 +0000 (18:48 +0000)
Lib/distutils/cygwinccompiler.py
Lib/distutils/emxccompiler.py
Lib/distutils/unixccompiler.py

index 302293ac25fc9947761147e9e5c6caf3bfedb4ae..9aabd8a66b19d0f855d126bf4c51ec93b810961b 100644 (file)
@@ -113,37 +113,20 @@ class CygwinCCompiler (UnixCCompiler):
 
     # __init__ ()
 
-    # not much different of the compile method in UnixCCompiler,
-    # but we have to insert some lines in the middle of it, so
-    # we put here a adapted version of it.
-    # (If we would call compile() in the base class, it would do some
-    # initializations a second time, this is why all is done here.)
-    def compile(self, sources,
-                output_dir=None, macros=None, include_dirs=None, debug=0,
-                extra_preargs=None, extra_postargs=None, depends=None):
-        
-        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():
-            if ext == '.rc' or ext == '.res':
-                # gcc needs '.res' and '.rc' compiled to object files !!!
-                try:
-                    self.spawn (["windres","-i",src,"-o",obj])
-                except DistutilsExecError, msg:
-                    raise CompileError, msg
-            else: # for other files use the C-compiler
-                try:
-                    self.spawn (self.compiler_so + cc_args +
-                            [src, '-o', obj] +
-                            extra_postargs)
-                except DistutilsExecError, msg:
-                    raise CompileError, msg
-
-        # 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):
+        if ext == '.rc' or ext == '.res':
+            # gcc needs '.res' and '.rc' compiled to object files !!!
+            try:
+                self.spawn(["windres", "-i", src, "-o", obj])
+            except DistutilsExecError, msg:
+                raise CompileError, msg
+        else: # for other files use the C-compiler
+            try:
+                self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
+                           extra_postargs)
+            except DistutilsExecError, msg:
+                raise CompileError, msg
 
     def link (self,
               target_desc,
index c2c73b0dec9ad19cbd3c8c2165f531d920dae556..2dc4fbd091d080c64ee66761b981fb1de063c9ff 100644 (file)
@@ -76,41 +76,19 @@ class EMXCCompiler (UnixCCompiler):
         
     # __init__ ()
 
-    # not much different of the compile method in UnixCCompiler,
-    # but we have to insert some lines in the middle of it, so
-    # we put here a adapted version of it.
-    # (If we would call compile() in the base class, it would do some 
-    # initializations a second time, this is why all is done here.)
-
-    def compile(self, sources,
-                output_dir=None, macros=None, include_dirs=None, debug=0,
-                extra_preargs=None, extra_postargs=None, depends=None):
-        
-        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():
-            if ext == '.rc':
-                # gcc requires '.rc' compiled to binary ('.res') files !!!
-                try:
-                    self.spawn (["rc","-r",src])
-                except DistutilsExecError, msg:
-                    raise CompileError, msg
-            else: # for other files use the C-compiler 
-                try:
-                    self.spawn (self.compiler_so + cc_args +
-                            [src, '-o', obj] +
-                            extra_postargs)
-                except DistutilsExecError, msg:
-                    raise CompileError, msg
-
-        # Return *all* object filenames, not just the ones we just built.
-        return objects
-
-    # compile ()
-
+    def _compile(self, obj, src, ext, cc_args, extra_postargs):
+        if ext == '.rc':
+            # gcc requires '.rc' compiled to binary ('.res') files !!!
+            try:
+                self.spawn(["rc", "-r", src])
+            except DistutilsExecError, msg:
+                raise CompileError, msg
+        else: # for other files use the C-compiler 
+            try:
+                self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
+                           extra_postargs)
+            except DistutilsExecError, msg:
+                raise CompileError, msg
 
     def link (self,
               target_desc,
index c887a8822610ca05d6b8e7561fba1e8150ce4b3a..d94c3840926be7502493e9926bac3cd6027d1f13 100644 (file)
@@ -105,24 +105,12 @@ class UnixCCompiler(CCompiler):
             except DistutilsExecError, msg:
                 raise CompileError, msg
 
-    def compile(self, sources,
-                output_dir=None, macros=None, include_dirs=None, debug=0,
-                extra_preargs=None, extra_postargs=None, depends=None):
-        
-        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():
-            try:
-                self.spawn(self.compiler_so + cc_args +
-                           [src, '-o', obj] + extra_postargs)
-            except DistutilsExecError, msg:
-                raise CompileError, msg
-
-        # 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):
+        try:
+            self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
+                       extra_postargs)
+        except DistutilsExecError, msg:
+            raise CompileError, msg
 
     def create_static_lib(self, objects, output_libname,
                           output_dir=None, debug=0):