Index: Lib/distutils/bcppcompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/bcppcompiler.py,v retrieving revision 1.18 diff -c -r1.18 bcppcompiler.py *** Lib/distutils/bcppcompiler.py 10 Nov 2004 22:23:13 -0000 1.18 --- Lib/distutils/bcppcompiler.py 17 Jun 2005 12:26:47 -0000 *************** *** 84,90 **** 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, --- 84,91 ---- def compile(self, sources, output_dir=None, macros=None, include_dirs=None, debug=0, ! extra_preargs=None, extra_postargs=None, depends=None, ! target_lang=None): macros, objects, extra_postargs, pp_opts, build = \ self._setup_compile(output_dir, macros, include_dirs, sources, Index: Lib/distutils/ccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/ccompiler.py,v retrieving revision 1.61 diff -c -r1.61 ccompiler.py *** Lib/distutils/ccompiler.py 10 Nov 2004 22:23:13 -0000 1.61 --- Lib/distutils/ccompiler.py 17 Jun 2005 12:26:49 -0000 *************** *** 633,639 **** def compile(self, sources, output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, ! extra_postargs=None, depends=None): """Compile one or more source files. 'sources' must be a list of filenames, most likely C/C++ --- 633,639 ---- def compile(self, sources, output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, ! extra_postargs=None, depends=None, target_lang=None): """Compile one or more source files. 'sources' must be a list of filenames, most likely C/C++ *************** *** 680,685 **** --- 680,688 ---- supports dependency tracking, but only at a coarse granularity. + 'target_lang' is a string that specifies the language of the + sources. + Raises CompileError on failure. """ *************** *** 696,707 **** src, ext = build[obj] except KeyError: continue ! 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() --- 699,712 ---- src, ext = build[obj] except KeyError: continue ! self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts, ! target_lang) # 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, ! target_lang): """Compile 'src' to product 'obj'.""" # A concrete compiler class that does not override compile() Index: Lib/distutils/cygwinccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/cygwinccompiler.py,v retrieving revision 1.29 diff -c -r1.29 cygwinccompiler.py *** Lib/distutils/cygwinccompiler.py 10 Nov 2004 22:23:14 -0000 1.29 --- Lib/distutils/cygwinccompiler.py 17 Jun 2005 12:26:49 -0000 *************** *** 137,143 **** # __init__ () ! 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: --- 137,144 ---- # __init__ () ! def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts, ! target_lang): if ext == '.rc' or ext == '.res': # gcc needs '.res' and '.rc' compiled to object files !!! try: *************** *** 145,152 **** 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 --- 146,163 ---- except DistutilsExecError, msg: raise CompileError, msg else: # for other files use the C-compiler + if target_lang == 'c++': + # Use C++ compiler but combine unique arguments from both + # C and C++ compilers + compiler = [self.compiler_cxx[0]] + for token in self.compiler_cxx[1:]: + if token not in self.compiler_so[1:]: + compiler.append(token) + compiler += self.compiler_so[1:] + else: + compiler = self.compiler_so try: ! self.spawn(compiler + cc_args + [src, '-o', obj] + extra_postargs) except DistutilsExecError, msg: raise CompileError, msg Index: Lib/distutils/emxccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/emxccompiler.py,v retrieving revision 1.11 diff -c -r1.11 emxccompiler.py *** Lib/distutils/emxccompiler.py 2 Dec 2003 12:17:59 -0000 1.11 --- Lib/distutils/emxccompiler.py 17 Jun 2005 12:26:50 -0000 *************** *** 74,80 **** # __init__ () ! def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts): if ext == '.rc': # gcc requires '.rc' compiled to binary ('.res') files !!! try: --- 74,81 ---- # __init__ () ! def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts, ! target_lang): if ext == '.rc': # gcc requires '.rc' compiled to binary ('.res') files !!! try: *************** *** 82,89 **** 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 --- 83,100 ---- except DistutilsExecError, msg: raise CompileError, msg else: # for other files use the C-compiler + if target_lang == 'c++': + # Use C++ compiler but combine unique arguments from both + # C and C++ compilers + compiler = [self.compiler_cxx[0]] + for token in self.compiler_cxx[1:]: + if token not in self.compiler_so[1:]: + compiler.append(token) + compiler += self.compiler_so[1:] + else: + compiler = self.compiler_so try: ! self.spawn(compiler + cc_args + [src, '-o', obj] + extra_postargs) except DistutilsExecError, msg: raise CompileError, msg Index: Lib/distutils/msvccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/msvccompiler.py,v retrieving revision 1.68 diff -c -r1.68 msvccompiler.py *** Lib/distutils/msvccompiler.py 12 Mar 2005 19:05:58 -0000 1.68 --- Lib/distutils/msvccompiler.py 17 Jun 2005 12:26:51 -0000 *************** *** 292,298 **** def compile(self, sources, output_dir=None, macros=None, include_dirs=None, debug=0, ! extra_preargs=None, extra_postargs=None, depends=None): if not self.initialized: self.initialize() macros, objects, extra_postargs, pp_opts, build = \ --- 292,299 ---- def compile(self, sources, output_dir=None, macros=None, include_dirs=None, debug=0, ! extra_preargs=None, extra_postargs=None, depends=None, ! target_lang=None): if not self.initialized: self.initialize() macros, objects, extra_postargs, pp_opts, build = \ Index: Lib/distutils/mwerkscompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/mwerkscompiler.py,v retrieving revision 1.13 diff -c -r1.13 mwerkscompiler.py *** Lib/distutils/mwerkscompiler.py 10 Nov 2004 22:23:14 -0000 1.13 --- Lib/distutils/mwerkscompiler.py 17 Jun 2005 12:26:51 -0000 *************** *** 67,73 **** debug=0, extra_preargs=None, extra_postargs=None, ! depends=None): (output_dir, macros, include_dirs) = \ self._fix_compile_args (output_dir, macros, include_dirs) self.__sources = sources --- 67,74 ---- debug=0, extra_preargs=None, extra_postargs=None, ! depends=None, ! target_lang=None): (output_dir, macros, include_dirs) = \ self._fix_compile_args (output_dir, macros, include_dirs) self.__sources = sources Index: Lib/distutils/unixccompiler.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/unixccompiler.py,v retrieving revision 1.56 diff -c -r1.56 unixccompiler.py *** Lib/distutils/unixccompiler.py 29 Aug 2004 16:40:55 -0000 1.56 --- Lib/distutils/unixccompiler.py 17 Jun 2005 12:26:52 -0000 *************** *** 107,115 **** except DistutilsExecError, msg: raise CompileError, msg ! 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 --- 107,126 ---- except DistutilsExecError, msg: raise CompileError, msg ! def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts, ! target_lang): ! if target_lang == 'c++': ! # Use C++ compiler but combine unique arguments from both ! # C and C++ compilers ! compiler = [self.compiler_cxx[0]] ! for token in self.compiler_cxx[1:]: ! if token not in self.compiler_so[1:]: ! compiler.append(token) ! compiler += self.compiler_so[1:] ! else: ! compiler = self.compiler_so try: ! self.spawn(compiler + cc_args + [src, '-o', obj] + extra_postargs) except DistutilsExecError, msg: raise CompileError, msg Index: Lib/distutils/command/build_ext.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/distutils/command/build_ext.py,v retrieving revision 1.98 diff -c -r1.98 build_ext.py *** Lib/distutils/command/build_ext.py 10 Nov 2004 22:23:15 -0000 1.98 --- Lib/distutils/command/build_ext.py 17 Jun 2005 12:26:52 -0000 *************** *** 461,473 **** for undef in ext.undef_macros: macros.append((undef,)) objects = self.compiler.compile(sources, output_dir=self.build_temp, macros=macros, include_dirs=ext.include_dirs, debug=self.debug, extra_postargs=extra_args, ! depends=ext.depends) # XXX -- this is a Vile HACK! # --- 461,477 ---- for undef in ext.undef_macros: macros.append((undef,)) + # Detect target language, if not provided + language = ext.language or self.compiler.detect_language(sources) + objects = self.compiler.compile(sources, output_dir=self.build_temp, macros=macros, include_dirs=ext.include_dirs, debug=self.debug, extra_postargs=extra_args, ! depends=ext.depends, ! target_lang=language) # XXX -- this is a Vile HACK! # *************** *** 487,495 **** objects.extend(ext.extra_objects) extra_args = ext.extra_link_args or [] - # Detect target language, if not provided - language = ext.language or self.compiler.detect_language(sources) - self.compiler.link_shared_object( objects, ext_filename, libraries=self.get_libraries(ext), --- 491,496 ----