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

Skip to content

Commit 1b046e4

Browse files
committed
Add implementation of _compile() and use default compile() method.
1 parent 6e08d22 commit 1b046e4

3 files changed

Lines changed: 33 additions & 84 deletions

File tree

Lib/distutils/cygwinccompiler.py

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -113,37 +113,20 @@ def __init__ (self, verbose=0, dry_run=0, force=0):
113113

114114
# __init__ ()
115115

116-
# not much different of the compile method in UnixCCompiler,
117-
# but we have to insert some lines in the middle of it, so
118-
# we put here a adapted version of it.
119-
# (If we would call compile() in the base class, it would do some
120-
# initializations a second time, this is why all is done here.)
121-
def compile(self, sources,
122-
output_dir=None, macros=None, include_dirs=None, debug=0,
123-
extra_preargs=None, extra_postargs=None, depends=None):
124-
125-
macros, objects, extra_postargs, pp_opts, build = \
126-
self._setup_compile(output_dir, macros, include_dirs, sources,
127-
depends, extra_postargs)
128-
cc_args = self._get_cc_args(pp_opts, debug, extra_preargs)
129-
130-
for obj, (src, ext) in build.items():
131-
if ext == '.rc' or ext == '.res':
132-
# gcc needs '.res' and '.rc' compiled to object files !!!
133-
try:
134-
self.spawn (["windres","-i",src,"-o",obj])
135-
except DistutilsExecError, msg:
136-
raise CompileError, msg
137-
else: # for other files use the C-compiler
138-
try:
139-
self.spawn (self.compiler_so + cc_args +
140-
[src, '-o', obj] +
141-
extra_postargs)
142-
except DistutilsExecError, msg:
143-
raise CompileError, msg
144-
145-
# Return *all* object filenames, not just the ones we just built.
146-
return objects
116+
117+
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
118+
if ext == '.rc' or ext == '.res':
119+
# gcc needs '.res' and '.rc' compiled to object files !!!
120+
try:
121+
self.spawn(["windres", "-i", src, "-o", obj])
122+
except DistutilsExecError, msg:
123+
raise CompileError, msg
124+
else: # for other files use the C-compiler
125+
try:
126+
self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
127+
extra_postargs)
128+
except DistutilsExecError, msg:
129+
raise CompileError, msg
147130

148131
def link (self,
149132
target_desc,

Lib/distutils/emxccompiler.py

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -76,41 +76,19 @@ def __init__ (self,
7676

7777
# __init__ ()
7878

79-
# not much different of the compile method in UnixCCompiler,
80-
# but we have to insert some lines in the middle of it, so
81-
# we put here a adapted version of it.
82-
# (If we would call compile() in the base class, it would do some
83-
# initializations a second time, this is why all is done here.)
84-
85-
def compile(self, sources,
86-
output_dir=None, macros=None, include_dirs=None, debug=0,
87-
extra_preargs=None, extra_postargs=None, depends=None):
88-
89-
macros, objects, extra_postargs, pp_opts, build = \
90-
self._setup_compile(output_dir, macros, include_dirs, sources,
91-
depends, extra_postargs)
92-
cc_args = self._get_cc_args(pp_opts, debug, extra_preargs)
93-
94-
for obj, (src, ext) in build.items():
95-
if ext == '.rc':
96-
# gcc requires '.rc' compiled to binary ('.res') files !!!
97-
try:
98-
self.spawn (["rc","-r",src])
99-
except DistutilsExecError, msg:
100-
raise CompileError, msg
101-
else: # for other files use the C-compiler
102-
try:
103-
self.spawn (self.compiler_so + cc_args +
104-
[src, '-o', obj] +
105-
extra_postargs)
106-
except DistutilsExecError, msg:
107-
raise CompileError, msg
108-
109-
# Return *all* object filenames, not just the ones we just built.
110-
return objects
111-
112-
# compile ()
113-
79+
def _compile(self, obj, src, ext, cc_args, extra_postargs):
80+
if ext == '.rc':
81+
# gcc requires '.rc' compiled to binary ('.res') files !!!
82+
try:
83+
self.spawn(["rc", "-r", src])
84+
except DistutilsExecError, msg:
85+
raise CompileError, msg
86+
else: # for other files use the C-compiler
87+
try:
88+
self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
89+
extra_postargs)
90+
except DistutilsExecError, msg:
91+
raise CompileError, msg
11492

11593
def link (self,
11694
target_desc,

Lib/distutils/unixccompiler.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -105,24 +105,12 @@ def preprocess(self, source,
105105
except DistutilsExecError, msg:
106106
raise CompileError, msg
107107

108-
def compile(self, sources,
109-
output_dir=None, macros=None, include_dirs=None, debug=0,
110-
extra_preargs=None, extra_postargs=None, depends=None):
111-
112-
macros, objects, extra_postargs, pp_opts, build = \
113-
self._setup_compile(output_dir, macros, include_dirs, sources,
114-
depends, extra_postargs)
115-
cc_args = self._get_cc_args(pp_opts, debug, extra_preargs)
116-
117-
for obj, (src, ext) in build.items():
118-
try:
119-
self.spawn(self.compiler_so + cc_args +
120-
[src, '-o', obj] + extra_postargs)
121-
except DistutilsExecError, msg:
122-
raise CompileError, msg
123-
124-
# Return *all* object filenames, not just the ones we just built.
125-
return objects
108+
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
109+
try:
110+
self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
111+
extra_postargs)
112+
except DistutilsExecError, msg:
113+
raise CompileError, msg
126114

127115
def create_static_lib(self, objects, output_libname,
128116
output_dir=None, debug=0):

0 commit comments

Comments
 (0)