mirror of
https://github.com/python/cpython.git
synced 2025-09-28 03:13:48 +00:00
Add implementation of _compile() and use default compile() method.
This commit is contained in:
parent
6e08d22b1a
commit
1b046e4314
3 changed files with 32 additions and 83 deletions
|
@ -113,38 +113,21 @@ class CygwinCCompiler (UnixCCompiler):
|
||||||
|
|
||||||
# __init__ ()
|
# __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 = \
|
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
|
||||||
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':
|
if ext == '.rc' or ext == '.res':
|
||||||
# gcc needs '.res' and '.rc' compiled to object files !!!
|
# gcc needs '.res' and '.rc' compiled to object files !!!
|
||||||
try:
|
try:
|
||||||
self.spawn (["windres","-i",src,"-o",obj])
|
self.spawn(["windres", "-i", src, "-o", obj])
|
||||||
except DistutilsExecError, msg:
|
except DistutilsExecError, msg:
|
||||||
raise CompileError, msg
|
raise CompileError, msg
|
||||||
else: # for other files use the C-compiler
|
else: # for other files use the C-compiler
|
||||||
try:
|
try:
|
||||||
self.spawn (self.compiler_so + cc_args +
|
self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
|
||||||
[src, '-o', obj] +
|
|
||||||
extra_postargs)
|
extra_postargs)
|
||||||
except DistutilsExecError, msg:
|
except DistutilsExecError, msg:
|
||||||
raise CompileError, msg
|
raise CompileError, msg
|
||||||
|
|
||||||
# Return *all* object filenames, not just the ones we just built.
|
|
||||||
return objects
|
|
||||||
|
|
||||||
def link (self,
|
def link (self,
|
||||||
target_desc,
|
target_desc,
|
||||||
objects,
|
objects,
|
||||||
|
|
|
@ -76,42 +76,20 @@ class EMXCCompiler (UnixCCompiler):
|
||||||
|
|
||||||
# __init__ ()
|
# __init__ ()
|
||||||
|
|
||||||
# not much different of the compile method in UnixCCompiler,
|
def _compile(self, obj, src, ext, cc_args, extra_postargs):
|
||||||
# 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':
|
if ext == '.rc':
|
||||||
# gcc requires '.rc' compiled to binary ('.res') files !!!
|
# gcc requires '.rc' compiled to binary ('.res') files !!!
|
||||||
try:
|
try:
|
||||||
self.spawn (["rc","-r",src])
|
self.spawn(["rc", "-r", src])
|
||||||
except DistutilsExecError, msg:
|
except DistutilsExecError, msg:
|
||||||
raise CompileError, msg
|
raise CompileError, msg
|
||||||
else: # for other files use the C-compiler
|
else: # for other files use the C-compiler
|
||||||
try:
|
try:
|
||||||
self.spawn (self.compiler_so + cc_args +
|
self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
|
||||||
[src, '-o', obj] +
|
|
||||||
extra_postargs)
|
extra_postargs)
|
||||||
except DistutilsExecError, msg:
|
except DistutilsExecError, msg:
|
||||||
raise CompileError, msg
|
raise CompileError, msg
|
||||||
|
|
||||||
# Return *all* object filenames, not just the ones we just built.
|
|
||||||
return objects
|
|
||||||
|
|
||||||
# compile ()
|
|
||||||
|
|
||||||
|
|
||||||
def link (self,
|
def link (self,
|
||||||
target_desc,
|
target_desc,
|
||||||
objects,
|
objects,
|
||||||
|
|
|
@ -105,25 +105,13 @@ class UnixCCompiler(CCompiler):
|
||||||
except DistutilsExecError, msg:
|
except DistutilsExecError, msg:
|
||||||
raise CompileError, msg
|
raise CompileError, msg
|
||||||
|
|
||||||
def compile(self, sources,
|
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
|
||||||
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:
|
try:
|
||||||
self.spawn(self.compiler_so + cc_args +
|
self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
|
||||||
[src, '-o', obj] + extra_postargs)
|
extra_postargs)
|
||||||
except DistutilsExecError, msg:
|
except DistutilsExecError, msg:
|
||||||
raise CompileError, msg
|
raise CompileError, msg
|
||||||
|
|
||||||
# Return *all* object filenames, not just the ones we just built.
|
|
||||||
return objects
|
|
||||||
|
|
||||||
def create_static_lib(self, objects, output_libname,
|
def create_static_lib(self, objects, output_libname,
|
||||||
output_dir=None, debug=0):
|
output_dir=None, debug=0):
|
||||||
objects, output_dir = self._fix_object_args(objects, output_dir)
|
objects, output_dir = self._fix_object_args(objects, output_dir)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue