summarylogtreecommitdiffstats
path: root/0098-distutils-add-windmc-to-cygwinccompiler.patch
blob: fafce741ac9c791ba8a846b36a3bfcf0bb40419b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
From 0c751ecfc03048c60a59b090cf93f64d09255c4b 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 098/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 75bc17b..6a40e80 100644
--- a/Lib/distutils/cygwinccompiler.py
+++ b/Lib/distutils/cygwinccompiler.py
@@ -170,6 +170,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] +
@@ -264,9 +286,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.33.0