Skip to content

Commit 8936254

Browse files
Alexpuxlazka
authored andcommitted
distutils: add windmc to cygwinccompiler
1 parent e32105b commit 8936254

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

Lib/distutils/cygwinccompiler.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,28 @@ def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
170170
self.spawn(["windres", "-i", src, "-o", obj])
171171
except DistutilsExecError as msg:
172172
raise CompileError(msg)
173+
elif ext == '.mc':
174+
# Adapted from msvc9compiler:
175+
#
176+
# Compile .MC to .RC file to .RES file.
177+
# * '-h dir' specifies the directory for the generated include file
178+
# * '-r dir' specifies the target directory of the generated RC file and the binary message resource it includes
179+
#
180+
# For now (since there are no options to change this),
181+
# we use the source-directory for the include file and
182+
# the build directory for the RC file and message
183+
# resources. This works at least for win32all.
184+
h_dir = os.path.dirname(src)
185+
rc_dir = os.path.dirname(obj)
186+
try:
187+
# first compile .MC to .RC and .H file
188+
self.spawn(['windmc'] + ['-h', h_dir, '-r', rc_dir] + [src])
189+
base, _ = os.path.splitext(os.path.basename(src))
190+
rc_file = os.path.join(rc_dir, base + '.rc')
191+
# then compile .RC to .RES file
192+
self.spawn(['windres', '-i', rc_file, '-o', obj])
193+
except DistutilsExecError as msg:
194+
raise CompileError(msg)
173195
else: # for other files use the C-compiler
174196
try:
175197
self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
@@ -264,9 +286,9 @@ def object_filenames(self, source_filenames, strip_dir=0, output_dir=''):
264286
base, ext = os.path.splitext(src_name)
265287
# use 'normcase' only for resource suffixes
266288
ext_normcase = os.path.normcase(ext)
267-
if ext_normcase in ['.rc','.res']:
289+
if ext_normcase in ['.rc', '.res', '.mc']:
268290
ext = ext_normcase
269-
if ext not in (self.src_extensions + ['.rc','.res']):
291+
if ext not in (self.src_extensions + ['.rc', '.res', '.mc']):
270292
raise UnknownFileError("unknown file type '%s' (from '%s')" % \
271293
(ext, src_name))
272294
base = os.path.splitdrive(base)[1] # Chop off the drive

0 commit comments

Comments
 (0)