blob: 07a7a0bee937e67d2c6b1483ed3eebfa5ffddb63 [file] [log] [blame]
From 4f1841b7211dd4d9557a868525b5005e4d67e55e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?=
<alexey.pawlow@gmail.com>
Date: Thu, 17 Jun 2021 18:52:28 +0530
Subject: [PATCH 086/N] distutils add windmc to cygwinccompiler
---
Lib/distutils/cygwinccompiler.py | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/Lib/distutils/cygwinccompiler.py b/Lib/distutils/cygwinccompiler.py
index 09b6eda..fcba43a 100644
--- a/Lib/distutils/cygwinccompiler.py
+++ b/Lib/distutils/cygwinccompiler.py
@@ -163,6 +163,28 @@ class CygwinCCompiler(UnixCCompiler):
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] +
@@ -257,9 +279,9 @@ class CygwinCCompiler(UnixCCompiler):
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
--
2.32.0