Skip to content

Commit

Permalink
distutils: add windmc to cygwinccompiler
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexpux authored and lazka committed Aug 25, 2023
1 parent e32105b commit 8936254
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions Lib/distutils/cygwinccompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,28 @@ def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
self.spawn(["windres", "-i", src, "-o", obj])
except DistutilsExecError as msg:
raise CompileError(msg)
elif ext == '.mc':
# Adapted from msvc9compiler:
#
# Compile .MC to .RC file to .RES file.
# * '-h dir' specifies the directory for the generated include file
# * '-r dir' specifies the target directory of the generated RC file and the binary message resource it includes
#
# For now (since there are no options to change this),
# we use the source-directory for the include file and
# the build directory for the RC file and message
# resources. This works at least for win32all.
h_dir = os.path.dirname(src)
rc_dir = os.path.dirname(obj)
try:
# first compile .MC to .RC and .H file
self.spawn(['windmc'] + ['-h', h_dir, '-r', rc_dir] + [src])
base, _ = os.path.splitext(os.path.basename(src))
rc_file = os.path.join(rc_dir, base + '.rc')
# then compile .RC to .RES file
self.spawn(['windres', '-i', rc_file, '-o', obj])
except DistutilsExecError as msg:
raise CompileError(msg)
else: # for other files use the C-compiler
try:
self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
Expand Down Expand Up @@ -264,9 +286,9 @@ def object_filenames(self, source_filenames, strip_dir=0, output_dir=''):
base, ext = os.path.splitext(src_name)
# use 'normcase' only for resource suffixes
ext_normcase = os.path.normcase(ext)
if ext_normcase in ['.rc','.res']:
if ext_normcase in ['.rc', '.res', '.mc']:
ext = ext_normcase
if ext not in (self.src_extensions + ['.rc','.res']):
if ext not in (self.src_extensions + ['.rc', '.res', '.mc']):
raise UnknownFileError("unknown file type '%s' (from '%s')" % \
(ext, src_name))
base = os.path.splitdrive(base)[1] # Chop off the drive
Expand Down

0 comments on commit 8936254

Please sign in to comment.