Mercurial > cpython-lru_cache-weakref
annotate Lib/distutils/msvccompiler.py @ 79675:c0a2294de787 2.7
Issue #16199: Backport 2to3 typo fix from 3.2.
| author | Chris Jerdonek <chris.jerdonek@gmail.com> |
|---|---|
| date | Thu, 11 Oct 2012 16:15:46 -0700 |
| parents | 3e2b7965ada9 |
| children |
| rev | line source |
|---|---|
|
13045
72058dc7d545
Lyle Johnson: added 'build_temp' parameter to 'link_shared_{lib,object}()'
Greg Ward <gward@python.net>
parents:
13015
diff
changeset
|
1 """distutils.msvccompiler |
|
11244
4385b1bcbc3b
Added msvccompiler module exactly as supplied by Perry Stoll.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
2 |
|
4385b1bcbc3b
Added msvccompiler module exactly as supplied by Perry Stoll.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
3 Contains MSVCCompiler, an implementation of the abstract CCompiler class |
|
29052
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
4 for the Microsoft Visual Studio. |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
5 """ |
|
11244
4385b1bcbc3b
Added msvccompiler module exactly as supplied by Perry Stoll.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
6 |
|
26210
f465d6692bde
Remove 'created by' lines; people can use CVS for this, and the information is often out of date
Andrew M. Kuchling <amk@amk.ca>
parents:
26036
diff
changeset
|
7 # Written by Perry Stoll |
|
11915
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
8 # hacked by Robin Becker and Thomas Heller to do a better job of |
|
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
9 # finding DevStudio (through the registry) |
|
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
10 |
|
11897
017e592c0fd2
Changed '__rcsid__' to '__revision__'.
Greg Ward <gward@python.net>
parents:
11750
diff
changeset
|
11 __revision__ = "$Id$" |
|
11244
4385b1bcbc3b
Added msvccompiler module exactly as supplied by Perry Stoll.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
12 |
|
57847
3e2b7965ada9
massive import cleaning in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51047
diff
changeset
|
13 import sys |
|
3e2b7965ada9
massive import cleaning in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51047
diff
changeset
|
14 import os |
|
3e2b7965ada9
massive import cleaning in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51047
diff
changeset
|
15 import string |
|
3e2b7965ada9
massive import cleaning in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51047
diff
changeset
|
16 |
|
3e2b7965ada9
massive import cleaning in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51047
diff
changeset
|
17 from distutils.errors import (DistutilsExecError, DistutilsPlatformError, |
|
3e2b7965ada9
massive import cleaning in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51047
diff
changeset
|
18 CompileError, LibError, LinkError) |
|
3e2b7965ada9
massive import cleaning in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51047
diff
changeset
|
19 from distutils.ccompiler import CCompiler, gen_lib_options |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23274
diff
changeset
|
20 from distutils import log |
|
11738
83d351f948ab
Stylistic changes to the registry-grovelling code: code formatting, changed
Greg Ward <gward@python.net>
parents:
11735
diff
changeset
|
21 |
|
12189
151b913e74a1
Patch from Thomas Heller: use the new winreg module if available.
Greg Ward <gward@python.net>
parents:
12165
diff
changeset
|
22 _can_read_reg = 0 |
|
151b913e74a1
Patch from Thomas Heller: use the new winreg module if available.
Greg Ward <gward@python.net>
parents:
12165
diff
changeset
|
23 try: |
|
13241
6104b61215e6
Simplify the registry-module-finding code: _winreg or win32api/win32con.
Greg Ward <gward@python.net>
parents:
13162
diff
changeset
|
24 import _winreg |
|
13162
c360806c06c7
On second thought, first try for _winreg, and then winreg. Only if both
Greg Ward <gward@python.net>
parents:
13160
diff
changeset
|
25 |
|
12189
151b913e74a1
Patch from Thomas Heller: use the new winreg module if available.
Greg Ward <gward@python.net>
parents:
12165
diff
changeset
|
26 _can_read_reg = 1 |
|
13160
139eaf2f96ab
Changed to use _winreg module instead of winreg.
Greg Ward <gward@python.net>
parents:
13045
diff
changeset
|
27 hkey_mod = _winreg |
|
12201
41dfc7d4a36b
Fixed my simplification to Thomas' patch: winreg and win32api export the same
Greg Ward <gward@python.net>
parents:
12190
diff
changeset
|
28 |
|
13160
139eaf2f96ab
Changed to use _winreg module instead of winreg.
Greg Ward <gward@python.net>
parents:
13045
diff
changeset
|
29 RegOpenKeyEx = _winreg.OpenKeyEx |
|
139eaf2f96ab
Changed to use _winreg module instead of winreg.
Greg Ward <gward@python.net>
parents:
13045
diff
changeset
|
30 RegEnumKey = _winreg.EnumKey |
|
139eaf2f96ab
Changed to use _winreg module instead of winreg.
Greg Ward <gward@python.net>
parents:
13045
diff
changeset
|
31 RegEnumValue = _winreg.EnumValue |
|
139eaf2f96ab
Changed to use _winreg module instead of winreg.
Greg Ward <gward@python.net>
parents:
13045
diff
changeset
|
32 RegError = _winreg.error |
|
12201
41dfc7d4a36b
Fixed my simplification to Thomas' patch: winreg and win32api export the same
Greg Ward <gward@python.net>
parents:
12190
diff
changeset
|
33 |
|
12189
151b913e74a1
Patch from Thomas Heller: use the new winreg module if available.
Greg Ward <gward@python.net>
parents:
12165
diff
changeset
|
34 except ImportError: |
|
151b913e74a1
Patch from Thomas Heller: use the new winreg module if available.
Greg Ward <gward@python.net>
parents:
12165
diff
changeset
|
35 try: |
|
151b913e74a1
Patch from Thomas Heller: use the new winreg module if available.
Greg Ward <gward@python.net>
parents:
12165
diff
changeset
|
36 import win32api |
|
151b913e74a1
Patch from Thomas Heller: use the new winreg module if available.
Greg Ward <gward@python.net>
parents:
12165
diff
changeset
|
37 import win32con |
|
151b913e74a1
Patch from Thomas Heller: use the new winreg module if available.
Greg Ward <gward@python.net>
parents:
12165
diff
changeset
|
38 _can_read_reg = 1 |
|
12190
94b601faebac
Simplified Thomas Heller's registry patch: just assign all those
Greg Ward <gward@python.net>
parents:
12189
diff
changeset
|
39 hkey_mod = win32con |
|
12201
41dfc7d4a36b
Fixed my simplification to Thomas' patch: winreg and win32api export the same
Greg Ward <gward@python.net>
parents:
12190
diff
changeset
|
40 |
|
41dfc7d4a36b
Fixed my simplification to Thomas' patch: winreg and win32api export the same
Greg Ward <gward@python.net>
parents:
12190
diff
changeset
|
41 RegOpenKeyEx = win32api.RegOpenKeyEx |
|
41dfc7d4a36b
Fixed my simplification to Thomas' patch: winreg and win32api export the same
Greg Ward <gward@python.net>
parents:
12190
diff
changeset
|
42 RegEnumKey = win32api.RegEnumKey |
|
41dfc7d4a36b
Fixed my simplification to Thomas' patch: winreg and win32api export the same
Greg Ward <gward@python.net>
parents:
12190
diff
changeset
|
43 RegEnumValue = win32api.RegEnumValue |
|
41dfc7d4a36b
Fixed my simplification to Thomas' patch: winreg and win32api export the same
Greg Ward <gward@python.net>
parents:
12190
diff
changeset
|
44 RegError = win32api.error |
|
41dfc7d4a36b
Fixed my simplification to Thomas' patch: winreg and win32api export the same
Greg Ward <gward@python.net>
parents:
12190
diff
changeset
|
45 |
|
12189
151b913e74a1
Patch from Thomas Heller: use the new winreg module if available.
Greg Ward <gward@python.net>
parents:
12165
diff
changeset
|
46 except ImportError: |
|
29918
ec9f18615485
Patch from John Anderson to enable VC 7.1 support.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
29117
diff
changeset
|
47 log.info("Warning: Can't read registry to find the " |
|
ec9f18615485
Patch from John Anderson to enable VC 7.1 support.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
29117
diff
changeset
|
48 "necessary compiler setting\n" |
|
ec9f18615485
Patch from John Anderson to enable VC 7.1 support.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
29117
diff
changeset
|
49 "Make sure that Python modules _winreg, " |
|
ec9f18615485
Patch from John Anderson to enable VC 7.1 support.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
29117
diff
changeset
|
50 "win32api or win32con are installed.") |
|
12189
151b913e74a1
Patch from Thomas Heller: use the new winreg module if available.
Greg Ward <gward@python.net>
parents:
12165
diff
changeset
|
51 pass |
|
12190
94b601faebac
Simplified Thomas Heller's registry patch: just assign all those
Greg Ward <gward@python.net>
parents:
12189
diff
changeset
|
52 |
|
94b601faebac
Simplified Thomas Heller's registry patch: just assign all those
Greg Ward <gward@python.net>
parents:
12189
diff
changeset
|
53 if _can_read_reg: |
|
29052
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
54 HKEYS = (hkey_mod.HKEY_USERS, |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
55 hkey_mod.HKEY_CURRENT_USER, |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
56 hkey_mod.HKEY_LOCAL_MACHINE, |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
57 hkey_mod.HKEY_CLASSES_ROOT) |
|
12189
151b913e74a1
Patch from Thomas Heller: use the new winreg module if available.
Greg Ward <gward@python.net>
parents:
12165
diff
changeset
|
58 |
|
29052
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
59 def read_keys(base, key): |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
60 """Return list of registry keys.""" |
|
11749
5c2770124904
Latest patch from Thomas Heller/Robin Becker:
Greg Ward <gward@python.net>
parents:
11738
diff
changeset
|
61 |
|
29052
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
62 try: |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
63 handle = RegOpenKeyEx(base, key) |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
64 except RegError: |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
65 return None |
|
11720
fdc9eeb89e0b
Revised version (thank to Thomas Heller and Robin Becker) that tries a lot
Greg Ward <gward@python.net>
parents:
11664
diff
changeset
|
66 L = [] |
|
29052
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
67 i = 0 |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
68 while 1: |
|
11720
fdc9eeb89e0b
Revised version (thank to Thomas Heller and Robin Becker) that tries a lot
Greg Ward <gward@python.net>
parents:
11664
diff
changeset
|
69 try: |
|
29052
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
70 k = RegEnumKey(handle, i) |
|
12190
94b601faebac
Simplified Thomas Heller's registry patch: just assign all those
Greg Ward <gward@python.net>
parents:
12189
diff
changeset
|
71 except RegError: |
|
29052
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
72 break |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
73 L.append(k) |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
74 i = i + 1 |
|
11720
fdc9eeb89e0b
Revised version (thank to Thomas Heller and Robin Becker) that tries a lot
Greg Ward <gward@python.net>
parents:
11664
diff
changeset
|
75 return L |
|
fdc9eeb89e0b
Revised version (thank to Thomas Heller and Robin Becker) that tries a lot
Greg Ward <gward@python.net>
parents:
11664
diff
changeset
|
76 |
|
29052
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
77 def read_values(base, key): |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
78 """Return dict of registry keys and values. |
|
11720
fdc9eeb89e0b
Revised version (thank to Thomas Heller and Robin Becker) that tries a lot
Greg Ward <gward@python.net>
parents:
11664
diff
changeset
|
79 |
|
29052
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
80 All names are converted to lowercase. |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
81 """ |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
82 try: |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
83 handle = RegOpenKeyEx(base, key) |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
84 except RegError: |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
85 return None |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
86 d = {} |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
87 i = 0 |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
88 while 1: |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
89 try: |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
90 name, value, type = RegEnumValue(handle, i) |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
91 except RegError: |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
92 break |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
93 name = name.lower() |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
94 d[convert_mbcs(name)] = convert_mbcs(value) |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
95 i = i + 1 |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
96 return d |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
97 |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
98 def convert_mbcs(s): |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
99 enc = getattr(s, "encode", None) |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
100 if enc is not None: |
|
11720
fdc9eeb89e0b
Revised version (thank to Thomas Heller and Robin Becker) that tries a lot
Greg Ward <gward@python.net>
parents:
11664
diff
changeset
|
101 try: |
|
29052
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
102 s = enc("mbcs") |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
103 except UnicodeError: |
|
11720
fdc9eeb89e0b
Revised version (thank to Thomas Heller and Robin Becker) that tries a lot
Greg Ward <gward@python.net>
parents:
11664
diff
changeset
|
104 pass |
|
29052
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
105 return s |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
106 |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
107 class MacroExpander: |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
108 |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
109 def __init__(self, version): |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
110 self.macros = {} |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
111 self.load_macros(version) |
|
11720
fdc9eeb89e0b
Revised version (thank to Thomas Heller and Robin Becker) that tries a lot
Greg Ward <gward@python.net>
parents:
11664
diff
changeset
|
112 |
|
29052
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
113 def set_macro(self, macro, path, key): |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
114 for base in HKEYS: |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
115 d = read_values(base, path) |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
116 if d: |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
117 self.macros["$(%s)" % macro] = d[key] |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
118 break |
|
32736
c3a096bfbd6b
Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents:
31129
diff
changeset
|
119 |
|
29052
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
120 def load_macros(self, version): |
|
29918
ec9f18615485
Patch from John Anderson to enable VC 7.1 support.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
29117
diff
changeset
|
121 vsbase = r"Software\Microsoft\VisualStudio\%0.1f" % version |
|
29052
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
122 self.set_macro("VCInstallDir", vsbase + r"\Setup\VC", "productdir") |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
123 self.set_macro("VSInstallDir", vsbase + r"\Setup\VS", "productdir") |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
124 net = r"Software\Microsoft\.NETFramework" |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
125 self.set_macro("FrameworkDir", net, "installroot") |
|
34033
163409a601be
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
34025
diff
changeset
|
126 try: |
|
163409a601be
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
34025
diff
changeset
|
127 if version > 7.0: |
|
163409a601be
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
34025
diff
changeset
|
128 self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv1.1") |
|
163409a601be
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
34025
diff
changeset
|
129 else: |
|
163409a601be
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
34025
diff
changeset
|
130 self.set_macro("FrameworkSDKDir", net, "sdkinstallroot") |
|
57847
3e2b7965ada9
massive import cleaning in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51047
diff
changeset
|
131 except KeyError: |
|
34025
7f95fe98d821
SF patch #1071739 (by Christos Georgiou)
Fredrik Lundh <fredrik@pythonware.com>
parents:
33965
diff
changeset
|
132 raise DistutilsPlatformError, \ |
|
39309
bde58a78fc71
Mention Cygwin in distutils error message about a missing VS 2003.
Martin v. Löwis <martin@v.loewis.de>
parents:
39046
diff
changeset
|
133 ("""Python was built with Visual Studio 2003; |
|
bde58a78fc71
Mention Cygwin in distutils error message about a missing VS 2003.
Martin v. Löwis <martin@v.loewis.de>
parents:
39046
diff
changeset
|
134 extensions must be built with a compiler than can generate compatible binaries. |
|
bde58a78fc71
Mention Cygwin in distutils error message about a missing VS 2003.
Martin v. Löwis <martin@v.loewis.de>
parents:
39046
diff
changeset
|
135 Visual Studio 2003 was not found on this system. If you have Cygwin installed, |
|
bde58a78fc71
Mention Cygwin in distutils error message about a missing VS 2003.
Martin v. Löwis <martin@v.loewis.de>
parents:
39046
diff
changeset
|
136 you can try compiling with MingW32, by passing "-c mingw32" to setup.py.""") |
|
11738
83d351f948ab
Stylistic changes to the registry-grovelling code: code formatting, changed
Greg Ward <gward@python.net>
parents:
11735
diff
changeset
|
137 |
|
29052
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
138 p = r"Software\Microsoft\NET Framework Setup\Product" |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
139 for base in HKEYS: |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
140 try: |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
141 h = RegOpenKeyEx(base, p) |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
142 except RegError: |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
143 continue |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
144 key = RegEnumKey(h, 0) |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
145 d = read_values(base, r"%s\%s" % (p, key)) |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
146 self.macros["$(FrameworkVersion)"] = d["version"] |
|
11720
fdc9eeb89e0b
Revised version (thank to Thomas Heller and Robin Becker) that tries a lot
Greg Ward <gward@python.net>
parents:
11664
diff
changeset
|
147 |
|
29052
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
148 def sub(self, s): |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
149 for k, v in self.macros.items(): |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
150 s = string.replace(s, k, v) |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
151 return s |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
152 |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
153 def get_build_version(): |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
154 """Return the version of MSVC that was used to build Python. |
|
11749
5c2770124904
Latest patch from Thomas Heller/Robin Becker:
Greg Ward <gward@python.net>
parents:
11738
diff
changeset
|
155 |
|
29052
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
156 For Python 2.3 and up, the version number is included in |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
157 sys.version. For earlier versions, assume the compiler is MSVC 6. |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
158 """ |
|
11738
83d351f948ab
Stylistic changes to the registry-grovelling code: code formatting, changed
Greg Ward <gward@python.net>
parents:
11735
diff
changeset
|
159 |
|
29052
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
160 prefix = "MSC v." |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
161 i = string.find(sys.version, prefix) |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
162 if i == -1: |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
163 return 6 |
|
29117
6ac0a672b082
Restore Python 1.5.2 compatibility.
Marc-André Lemburg <mal@egenix.com>
parents:
29054
diff
changeset
|
164 i = i + len(prefix) |
|
29052
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
165 s, rest = sys.version[i:].split(" ", 1) |
|
29918
ec9f18615485
Patch from John Anderson to enable VC 7.1 support.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
29117
diff
changeset
|
166 majorVersion = int(s[:-2]) - 6 |
|
ec9f18615485
Patch from John Anderson to enable VC 7.1 support.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
29117
diff
changeset
|
167 minorVersion = int(s[2:3]) / 10.0 |
|
ec9f18615485
Patch from John Anderson to enable VC 7.1 support.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
29117
diff
changeset
|
168 # I don't think paths are affected by minor version in version 6 |
|
ec9f18615485
Patch from John Anderson to enable VC 7.1 support.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
29117
diff
changeset
|
169 if majorVersion == 6: |
|
ec9f18615485
Patch from John Anderson to enable VC 7.1 support.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
29117
diff
changeset
|
170 minorVersion = 0 |
|
ec9f18615485
Patch from John Anderson to enable VC 7.1 support.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
29117
diff
changeset
|
171 if majorVersion >= 6: |
|
ec9f18615485
Patch from John Anderson to enable VC 7.1 support.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
29117
diff
changeset
|
172 return majorVersion + minorVersion |
|
29052
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
173 # else we don't know what version of the compiler this is |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
174 return None |
|
32736
c3a096bfbd6b
Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents:
31129
diff
changeset
|
175 |
|
36619
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
176 def get_build_architecture(): |
|
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
177 """Return the processor architecture. |
|
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
178 |
|
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
179 Possible results are "Intel", "Itanium", or "AMD64". |
|
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
180 """ |
|
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
181 |
|
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
182 prefix = " bit (" |
|
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
183 i = string.find(sys.version, prefix) |
|
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
184 if i == -1: |
|
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
185 return "Intel" |
|
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
186 j = string.find(sys.version, ")", i) |
|
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
187 return sys.version[i+len(prefix):j] |
|
36630
eb0977932e2d
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
36619
diff
changeset
|
188 |
|
41347
7dee7f7d29f0
SF #1685563, MSVCCompiler creates redundant and long PATH strings
Neal Norwitz <nnorwitz@gmail.com>
parents:
39309
diff
changeset
|
189 def normalize_and_reduce_paths(paths): |
|
7dee7f7d29f0
SF #1685563, MSVCCompiler creates redundant and long PATH strings
Neal Norwitz <nnorwitz@gmail.com>
parents:
39309
diff
changeset
|
190 """Return a list of normalized paths with duplicates removed. |
|
7dee7f7d29f0
SF #1685563, MSVCCompiler creates redundant and long PATH strings
Neal Norwitz <nnorwitz@gmail.com>
parents:
39309
diff
changeset
|
191 |
|
7dee7f7d29f0
SF #1685563, MSVCCompiler creates redundant and long PATH strings
Neal Norwitz <nnorwitz@gmail.com>
parents:
39309
diff
changeset
|
192 The current order of paths is maintained. |
|
7dee7f7d29f0
SF #1685563, MSVCCompiler creates redundant and long PATH strings
Neal Norwitz <nnorwitz@gmail.com>
parents:
39309
diff
changeset
|
193 """ |
|
7dee7f7d29f0
SF #1685563, MSVCCompiler creates redundant and long PATH strings
Neal Norwitz <nnorwitz@gmail.com>
parents:
39309
diff
changeset
|
194 # Paths are normalized so things like: /a and /a/ aren't both preserved. |
|
7dee7f7d29f0
SF #1685563, MSVCCompiler creates redundant and long PATH strings
Neal Norwitz <nnorwitz@gmail.com>
parents:
39309
diff
changeset
|
195 reduced_paths = [] |
|
7dee7f7d29f0
SF #1685563, MSVCCompiler creates redundant and long PATH strings
Neal Norwitz <nnorwitz@gmail.com>
parents:
39309
diff
changeset
|
196 for p in paths: |
|
7dee7f7d29f0
SF #1685563, MSVCCompiler creates redundant and long PATH strings
Neal Norwitz <nnorwitz@gmail.com>
parents:
39309
diff
changeset
|
197 np = os.path.normpath(p) |
|
7dee7f7d29f0
SF #1685563, MSVCCompiler creates redundant and long PATH strings
Neal Norwitz <nnorwitz@gmail.com>
parents:
39309
diff
changeset
|
198 # XXX(nnorwitz): O(n**2), if reduced_paths gets long perhaps use a set. |
|
7dee7f7d29f0
SF #1685563, MSVCCompiler creates redundant and long PATH strings
Neal Norwitz <nnorwitz@gmail.com>
parents:
39309
diff
changeset
|
199 if np not in reduced_paths: |
|
7dee7f7d29f0
SF #1685563, MSVCCompiler creates redundant and long PATH strings
Neal Norwitz <nnorwitz@gmail.com>
parents:
39309
diff
changeset
|
200 reduced_paths.append(np) |
|
7dee7f7d29f0
SF #1685563, MSVCCompiler creates redundant and long PATH strings
Neal Norwitz <nnorwitz@gmail.com>
parents:
39309
diff
changeset
|
201 return reduced_paths |
|
36619
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
202 |
|
11244
4385b1bcbc3b
Added msvccompiler module exactly as supplied by Perry Stoll.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
203 |
|
11260
eaeea9e42369
Ditched redundant docstrings and comments (overlap with ccompiler.py).
Greg Ward <gward@python.net>
parents:
11244
diff
changeset
|
204 class MSVCCompiler (CCompiler) : |
|
eaeea9e42369
Ditched redundant docstrings and comments (overlap with ccompiler.py).
Greg Ward <gward@python.net>
parents:
11244
diff
changeset
|
205 """Concrete class that implements an interface to Microsoft Visual C++, |
|
eaeea9e42369
Ditched redundant docstrings and comments (overlap with ccompiler.py).
Greg Ward <gward@python.net>
parents:
11244
diff
changeset
|
206 as defined by the CCompiler abstract class.""" |
|
11244
4385b1bcbc3b
Added msvccompiler module exactly as supplied by Perry Stoll.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
207 |
|
11337
334100218a4b
Catch up with latest changes in CCompiler:
Greg Ward <gward@python.net>
parents:
11260
diff
changeset
|
208 compiler_type = 'msvc' |
|
334100218a4b
Catch up with latest changes in CCompiler:
Greg Ward <gward@python.net>
parents:
11260
diff
changeset
|
209 |
|
13015
affe10c3b92e
Define the 'executables' class attribute so the CCompiler constructor
Greg Ward <gward@python.net>
parents:
12793
diff
changeset
|
210 # Just set this so CCompiler's constructor doesn't barf. We currently |
|
affe10c3b92e
Define the 'executables' class attribute so the CCompiler constructor
Greg Ward <gward@python.net>
parents:
12793
diff
changeset
|
211 # don't use the 'set_executables()' bureaucracy provided by CCompiler, |
|
affe10c3b92e
Define the 'executables' class attribute so the CCompiler constructor
Greg Ward <gward@python.net>
parents:
12793
diff
changeset
|
212 # as it really isn't necessary for this sort of single-compiler class. |
|
affe10c3b92e
Define the 'executables' class attribute so the CCompiler constructor
Greg Ward <gward@python.net>
parents:
12793
diff
changeset
|
213 # Would be nice to have a consistent interface with UnixCCompiler, |
|
affe10c3b92e
Define the 'executables' class attribute so the CCompiler constructor
Greg Ward <gward@python.net>
parents:
12793
diff
changeset
|
214 # though, so it's worth thinking about. |
|
affe10c3b92e
Define the 'executables' class attribute so the CCompiler constructor
Greg Ward <gward@python.net>
parents:
12793
diff
changeset
|
215 executables = {} |
|
affe10c3b92e
Define the 'executables' class attribute so the CCompiler constructor
Greg Ward <gward@python.net>
parents:
12793
diff
changeset
|
216 |
|
11915
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
217 # Private class data (need to distinguish C from C++ source for compiler) |
|
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
218 _c_extensions = ['.c'] |
|
14267
98608429ca6e
Add ".cxx" to the list of known C++ extensions.
Greg Ward <gward@python.net>
parents:
13844
diff
changeset
|
219 _cpp_extensions = ['.cc', '.cpp', '.cxx'] |
|
14699
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
220 _rc_extensions = ['.rc'] |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
221 _mc_extensions = ['.mc'] |
|
11915
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
222 |
|
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
223 # Needed for the filename generation methods provided by the |
|
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
224 # base class, CCompiler. |
|
14699
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
225 src_extensions = (_c_extensions + _cpp_extensions + |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
226 _rc_extensions + _mc_extensions) |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
227 res_extension = '.res' |
|
11915
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
228 obj_extension = '.obj' |
|
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
229 static_lib_extension = '.lib' |
|
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
230 shared_lib_extension = '.dll' |
|
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
231 static_lib_format = shared_lib_format = '%s%s' |
|
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
232 exe_extension = '.exe' |
|
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
233 |
|
29052
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
234 def __init__ (self, verbose=0, dry_run=0, force=0): |
|
11360
4c7d6043b43a
Catch up with changes in 'gen_lib_options()':
Greg Ward <gward@python.net>
parents:
11337
diff
changeset
|
235 CCompiler.__init__ (self, verbose, dry_run, force) |
|
29052
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
236 self.__version = get_build_version() |
|
36619
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
237 self.__arch = get_build_architecture() |
|
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
238 if self.__arch == "Intel": |
|
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
239 # x86 |
|
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
240 if self.__version >= 7: |
|
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
241 self.__root = r"Software\Microsoft\VisualStudio" |
|
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
242 self.__macros = MacroExpander(self.__version) |
|
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
243 else: |
|
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
244 self.__root = r"Software\Microsoft\Devstudio" |
|
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
245 self.__product = "Visual Studio version %s" % self.__version |
|
29052
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
246 else: |
|
36619
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
247 # Win64. Assume this was built with the platform SDK |
|
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
248 self.__product = "Microsoft SDK compiler %s" % (self.__version + 6) |
|
36630
eb0977932e2d
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
36619
diff
changeset
|
249 |
|
34684
f87a8d0df125
Patch #1075887: Don't require MSVC in distutils if there is nothing
Martin v. Löwis <martin@v.loewis.de>
parents:
34033
diff
changeset
|
250 self.initialized = False |
|
f87a8d0df125
Patch #1075887: Don't require MSVC in distutils if there is nothing
Martin v. Löwis <martin@v.loewis.de>
parents:
34033
diff
changeset
|
251 |
|
f87a8d0df125
Patch #1075887: Don't require MSVC in distutils if there is nothing
Martin v. Löwis <martin@v.loewis.de>
parents:
34033
diff
changeset
|
252 def initialize(self): |
|
36616
c36e37a18f1a
Let the SDK setup override distutils logic.
Martin v. Löwis <martin@v.loewis.de>
parents:
35323
diff
changeset
|
253 self.__paths = [] |
|
45413
8a187f562959
Removed uses of dict.has_key() from distutils, and uses of
Guido van Rossum <guido@python.org>
parents:
44117
diff
changeset
|
254 if "DISTUTILS_USE_SDK" in os.environ and "MSSdk" in os.environ and self.find_exe("cl.exe"): |
|
36616
c36e37a18f1a
Let the SDK setup override distutils logic.
Martin v. Löwis <martin@v.loewis.de>
parents:
35323
diff
changeset
|
255 # Assume that the SDK set up everything alright; don't try to be |
|
c36e37a18f1a
Let the SDK setup override distutils logic.
Martin v. Löwis <martin@v.loewis.de>
parents:
35323
diff
changeset
|
256 # smarter |
|
c36e37a18f1a
Let the SDK setup override distutils logic.
Martin v. Löwis <martin@v.loewis.de>
parents:
35323
diff
changeset
|
257 self.cc = "cl.exe" |
|
c36e37a18f1a
Let the SDK setup override distutils logic.
Martin v. Löwis <martin@v.loewis.de>
parents:
35323
diff
changeset
|
258 self.linker = "link.exe" |
|
c36e37a18f1a
Let the SDK setup override distutils logic.
Martin v. Löwis <martin@v.loewis.de>
parents:
35323
diff
changeset
|
259 self.lib = "lib.exe" |
|
c36e37a18f1a
Let the SDK setup override distutils logic.
Martin v. Löwis <martin@v.loewis.de>
parents:
35323
diff
changeset
|
260 self.rc = "rc.exe" |
|
c36e37a18f1a
Let the SDK setup override distutils logic.
Martin v. Löwis <martin@v.loewis.de>
parents:
35323
diff
changeset
|
261 self.mc = "mc.exe" |
|
c36e37a18f1a
Let the SDK setup override distutils logic.
Martin v. Löwis <martin@v.loewis.de>
parents:
35323
diff
changeset
|
262 else: |
|
c36e37a18f1a
Let the SDK setup override distutils logic.
Martin v. Löwis <martin@v.loewis.de>
parents:
35323
diff
changeset
|
263 self.__paths = self.get_msvc_paths("path") |
|
29918
ec9f18615485
Patch from John Anderson to enable VC 7.1 support.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
29117
diff
changeset
|
264 |
|
36616
c36e37a18f1a
Let the SDK setup override distutils logic.
Martin v. Löwis <martin@v.loewis.de>
parents:
35323
diff
changeset
|
265 if len (self.__paths) == 0: |
|
c36e37a18f1a
Let the SDK setup override distutils logic.
Martin v. Löwis <martin@v.loewis.de>
parents:
35323
diff
changeset
|
266 raise DistutilsPlatformError, \ |
|
36619
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
267 ("Python was built with %s, " |
|
36616
c36e37a18f1a
Let the SDK setup override distutils logic.
Martin v. Löwis <martin@v.loewis.de>
parents:
35323
diff
changeset
|
268 "and extensions need to be built with the same " |
|
36619
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
269 "version of the compiler, but it isn't installed." % self.__product) |
|
36616
c36e37a18f1a
Let the SDK setup override distutils logic.
Martin v. Löwis <martin@v.loewis.de>
parents:
35323
diff
changeset
|
270 |
|
c36e37a18f1a
Let the SDK setup override distutils logic.
Martin v. Löwis <martin@v.loewis.de>
parents:
35323
diff
changeset
|
271 self.cc = self.find_exe("cl.exe") |
|
c36e37a18f1a
Let the SDK setup override distutils logic.
Martin v. Löwis <martin@v.loewis.de>
parents:
35323
diff
changeset
|
272 self.linker = self.find_exe("link.exe") |
|
c36e37a18f1a
Let the SDK setup override distutils logic.
Martin v. Löwis <martin@v.loewis.de>
parents:
35323
diff
changeset
|
273 self.lib = self.find_exe("lib.exe") |
|
c36e37a18f1a
Let the SDK setup override distutils logic.
Martin v. Löwis <martin@v.loewis.de>
parents:
35323
diff
changeset
|
274 self.rc = self.find_exe("rc.exe") # resource compiler |
|
c36e37a18f1a
Let the SDK setup override distutils logic.
Martin v. Löwis <martin@v.loewis.de>
parents:
35323
diff
changeset
|
275 self.mc = self.find_exe("mc.exe") # message compiler |
|
c36e37a18f1a
Let the SDK setup override distutils logic.
Martin v. Löwis <martin@v.loewis.de>
parents:
35323
diff
changeset
|
276 self.set_path_env_var('lib') |
|
c36e37a18f1a
Let the SDK setup override distutils logic.
Martin v. Löwis <martin@v.loewis.de>
parents:
35323
diff
changeset
|
277 self.set_path_env_var('include') |
|
29052
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
278 |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
279 # extend the MSVC path with the current path |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
280 try: |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
281 for p in string.split(os.environ['path'], ';'): |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
282 self.__paths.append(p) |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
283 except KeyError: |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
284 pass |
|
41347
7dee7f7d29f0
SF #1685563, MSVCCompiler creates redundant and long PATH strings
Neal Norwitz <nnorwitz@gmail.com>
parents:
39309
diff
changeset
|
285 self.__paths = normalize_and_reduce_paths(self.__paths) |
|
29052
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
286 os.environ['path'] = string.join(self.__paths, ';') |
|
11749
5c2770124904
Latest patch from Thomas Heller/Robin Becker:
Greg Ward <gward@python.net>
parents:
11738
diff
changeset
|
287 |
|
11244
4385b1bcbc3b
Added msvccompiler module exactly as supplied by Perry Stoll.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
288 self.preprocess_options = None |
|
36619
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
289 if self.__arch == "Intel": |
|
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
290 self.compile_options = [ '/nologo', '/Ox', '/MD', '/W3', '/GX' , |
|
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
291 '/DNDEBUG'] |
|
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
292 self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3', '/GX', |
|
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
293 '/Z7', '/D_DEBUG'] |
|
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
294 else: |
|
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
295 # Win64 |
|
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
296 self.compile_options = [ '/nologo', '/Ox', '/MD', '/W3', '/GS-' , |
|
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
297 '/DNDEBUG'] |
|
b766ed03d425
Detect Win64 builds.
Martin v. Löwis <martin@v.loewis.de>
parents:
36616
diff
changeset
|
298 self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3', '/GS-', |
|
36630
eb0977932e2d
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
36619
diff
changeset
|
299 '/Z7', '/D_DEBUG'] |
|
11244
4385b1bcbc3b
Added msvccompiler module exactly as supplied by Perry Stoll.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
300 |
|
11720
fdc9eeb89e0b
Revised version (thank to Thomas Heller and Robin Becker) that tries a lot
Greg Ward <gward@python.net>
parents:
11664
diff
changeset
|
301 self.ldflags_shared = ['/DLL', '/nologo', '/INCREMENTAL:NO'] |
|
33954
0fe8a16a336a
Avoid a linker warning: MSVC 7 doesn't support /pdb:None, the debug
Thomas Heller <theller@ctypes.org>
parents:
32736
diff
changeset
|
302 if self.__version >= 7: |
|
0fe8a16a336a
Avoid a linker warning: MSVC 7 doesn't support /pdb:None, the debug
Thomas Heller <theller@ctypes.org>
parents:
32736
diff
changeset
|
303 self.ldflags_shared_debug = [ |
|
0fe8a16a336a
Avoid a linker warning: MSVC 7 doesn't support /pdb:None, the debug
Thomas Heller <theller@ctypes.org>
parents:
32736
diff
changeset
|
304 '/DLL', '/nologo', '/INCREMENTAL:no', '/DEBUG' |
|
0fe8a16a336a
Avoid a linker warning: MSVC 7 doesn't support /pdb:None, the debug
Thomas Heller <theller@ctypes.org>
parents:
32736
diff
changeset
|
305 ] |
|
0fe8a16a336a
Avoid a linker warning: MSVC 7 doesn't support /pdb:None, the debug
Thomas Heller <theller@ctypes.org>
parents:
32736
diff
changeset
|
306 else: |
|
0fe8a16a336a
Avoid a linker warning: MSVC 7 doesn't support /pdb:None, the debug
Thomas Heller <theller@ctypes.org>
parents:
32736
diff
changeset
|
307 self.ldflags_shared_debug = [ |
|
0fe8a16a336a
Avoid a linker warning: MSVC 7 doesn't support /pdb:None, the debug
Thomas Heller <theller@ctypes.org>
parents:
32736
diff
changeset
|
308 '/DLL', '/nologo', '/INCREMENTAL:no', '/pdb:None', '/DEBUG' |
|
0fe8a16a336a
Avoid a linker warning: MSVC 7 doesn't support /pdb:None, the debug
Thomas Heller <theller@ctypes.org>
parents:
32736
diff
changeset
|
309 ] |
|
11244
4385b1bcbc3b
Added msvccompiler module exactly as supplied by Perry Stoll.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
310 self.ldflags_static = [ '/nologo'] |
|
4385b1bcbc3b
Added msvccompiler module exactly as supplied by Perry Stoll.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
311 |
|
34743
b8d905ca9e99
Port bugfix from 2.4 maint.
Tim Peters <tim.peters@gmail.com>
parents:
34693
diff
changeset
|
312 self.initialized = True |
|
11244
4385b1bcbc3b
Added msvccompiler module exactly as supplied by Perry Stoll.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
313 |
|
4385b1bcbc3b
Added msvccompiler module exactly as supplied by Perry Stoll.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
314 # -- Worker methods ------------------------------------------------ |
|
4385b1bcbc3b
Added msvccompiler module exactly as supplied by Perry Stoll.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
315 |
|
14699
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
316 def object_filenames (self, |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
317 source_filenames, |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
318 strip_dir=0, |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
319 output_dir=''): |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
320 # Copied from ccompiler.py, extended to return .res as 'object'-file |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
321 # for .rc input file |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
322 if output_dir is None: output_dir = '' |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
323 obj_names = [] |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
324 for src_name in source_filenames: |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
325 (base, ext) = os.path.splitext (src_name) |
|
35323
3fa58e5bddfb
Patch #827386: Support absolute source paths in msvccompiler.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
34743
diff
changeset
|
326 base = os.path.splitdrive(base)[1] # Chop off the drive |
|
3fa58e5bddfb
Patch #827386: Support absolute source paths in msvccompiler.py.
Martin v. Löwis <martin@v.loewis.de>
parents:
34743
diff
changeset
|
327 base = base[os.path.isabs(base):] # If abs, chop off leading / |
|
14699
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
328 if ext not in self.src_extensions: |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
329 # Better to raise an exception instead of silently continuing |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
330 # and later complain about sources and targets having |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
331 # different lengths |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
332 raise CompileError ("Don't know how to compile %s" % src_name) |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
333 if strip_dir: |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
334 base = os.path.basename (base) |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
335 if ext in self._rc_extensions: |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
336 obj_names.append (os.path.join (output_dir, |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
337 base + self.res_extension)) |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
338 elif ext in self._mc_extensions: |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
339 obj_names.append (os.path.join (output_dir, |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
340 base + self.res_extension)) |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
341 else: |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
342 obj_names.append (os.path.join (output_dir, |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
343 base + self.obj_extension)) |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
344 return obj_names |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
345 |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
346 # object_filenames () |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
347 |
|
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
348 |
|
23823
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
349 def compile(self, sources, |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
350 output_dir=None, macros=None, include_dirs=None, debug=0, |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
351 extra_preargs=None, extra_postargs=None, depends=None): |
|
11244
4385b1bcbc3b
Added msvccompiler module exactly as supplied by Perry Stoll.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
352 |
|
34692
817e22506fa8
Remove a tab so that whitespace usage is consistent.
Brett Cannon <bcannon@gmail.com>
parents:
34684
diff
changeset
|
353 if not self.initialized: self.initialize() |
|
23823
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
354 macros, objects, extra_postargs, pp_opts, build = \ |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
355 self._setup_compile(output_dir, macros, include_dirs, sources, |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
356 depends, extra_postargs) |
|
11244
4385b1bcbc3b
Added msvccompiler module exactly as supplied by Perry Stoll.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
357 |
|
11915
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
358 compile_opts = extra_preargs or [] |
|
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
359 compile_opts.append ('/c') |
| 11735 | 360 if debug: |
|
23823
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
361 compile_opts.extend(self.compile_options_debug) |
| 11735 | 362 else: |
|
23823
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
363 compile_opts.extend(self.compile_options) |
|
14699
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
364 |
|
31129
be9ef9b92d61
Compile the files in the same order they are passed to the compiler.
Thomas Heller <theller@ctypes.org>
parents:
31039
diff
changeset
|
365 for obj in objects: |
|
be9ef9b92d61
Compile the files in the same order they are passed to the compiler.
Thomas Heller <theller@ctypes.org>
parents:
31039
diff
changeset
|
366 try: |
|
be9ef9b92d61
Compile the files in the same order they are passed to the compiler.
Thomas Heller <theller@ctypes.org>
parents:
31039
diff
changeset
|
367 src, ext = build[obj] |
|
be9ef9b92d61
Compile the files in the same order they are passed to the compiler.
Thomas Heller <theller@ctypes.org>
parents:
31039
diff
changeset
|
368 except KeyError: |
|
be9ef9b92d61
Compile the files in the same order they are passed to the compiler.
Thomas Heller <theller@ctypes.org>
parents:
31039
diff
changeset
|
369 continue |
|
23823
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
370 if debug: |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
371 # pass the full pathname to MSVC in debug mode, |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
372 # this allows the debugger to find the source file |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
373 # without asking the user to browse for it |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
374 src = os.path.abspath(src) |
|
14699
fa82820bd3ff
*Very* belated application of Thomas Heller's patch to handle
Greg Ward <gward@python.net>
parents:
14270
diff
changeset
|
375 |
|
23823
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
376 if ext in self._c_extensions: |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
377 input_opt = "/Tc" + src |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
378 elif ext in self._cpp_extensions: |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
379 input_opt = "/Tp" + src |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
380 elif ext in self._rc_extensions: |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
381 # compile .RC to .RES file |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
382 input_opt = src |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
383 output_opt = "/fo" + obj |
|
12790
f8c1c5b7dc9f
Changed to catch compile/link failures and raise CompileError, LibError,
Greg Ward <gward@python.net>
parents:
12717
diff
changeset
|
384 try: |
|
27564
256789aaacd6
Pass the preprocessor options also to the resource compiler
Thomas Heller <theller@ctypes.org>
parents:
26285
diff
changeset
|
385 self.spawn ([self.rc] + pp_opts + |
|
23823
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
386 [output_opt] + [input_opt]) |
|
12790
f8c1c5b7dc9f
Changed to catch compile/link failures and raise CompileError, LibError,
Greg Ward <gward@python.net>
parents:
12717
diff
changeset
|
387 except DistutilsExecError, msg: |
|
f8c1c5b7dc9f
Changed to catch compile/link failures and raise CompileError, LibError,
Greg Ward <gward@python.net>
parents:
12717
diff
changeset
|
388 raise CompileError, msg |
|
23823
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
389 continue |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
390 elif ext in self._mc_extensions: |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
391 |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
392 # Compile .MC to .RC file to .RES file. |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
393 # * '-h dir' specifies the directory for the |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
394 # generated include file |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
395 # * '-r dir' specifies the target directory of the |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
396 # generated RC file and the binary message resource |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
397 # it includes |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
398 # |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
399 # For now (since there are no options to change this), |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
400 # we use the source-directory for the include file and |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
401 # the build directory for the RC file and message |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
402 # resources. This works at least for win32all. |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
403 |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
404 h_dir = os.path.dirname (src) |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
405 rc_dir = os.path.dirname (obj) |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
406 try: |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
407 # first compile .MC to .RC and .H file |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
408 self.spawn ([self.mc] + |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
409 ['-h', h_dir, '-r', rc_dir] + [src]) |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
410 base, _ = os.path.splitext (os.path.basename (src)) |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
411 rc_file = os.path.join (rc_dir, base + '.rc') |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
412 # then compile .RC to .RES file |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
413 self.spawn ([self.rc] + |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
414 ["/fo" + obj] + [rc_file]) |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
415 |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
416 except DistutilsExecError, msg: |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
417 raise CompileError, msg |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
418 continue |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
419 else: |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
420 # how to handle this file? |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
421 raise CompileError ( |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
422 "Don't know how to compile %s to %s" % \ |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
423 (src, obj)) |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
424 |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
425 output_opt = "/Fo" + obj |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
426 try: |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
427 self.spawn ([self.cc] + compile_opts + pp_opts + |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
428 [input_opt, output_opt] + |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
429 extra_postargs) |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
430 except DistutilsExecError, msg: |
|
c48bf5df614a
Refactor compile() method implementations.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23668
diff
changeset
|
431 raise CompileError, msg |
|
11915
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
432 |
|
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
433 return objects |
|
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
434 |
|
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
435 # compile () |
|
11244
4385b1bcbc3b
Added msvccompiler module exactly as supplied by Perry Stoll.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
436 |
|
11260
eaeea9e42369
Ditched redundant docstrings and comments (overlap with ccompiler.py).
Greg Ward <gward@python.net>
parents:
11244
diff
changeset
|
437 |
|
11956
23fd7d10064e
Renamed 'link_static_lib() to 'create_static_lib()', and rewrote it create
Greg Ward <gward@python.net>
parents:
11915
diff
changeset
|
438 def create_static_lib (self, |
|
23fd7d10064e
Renamed 'link_static_lib() to 'create_static_lib()', and rewrote it create
Greg Ward <gward@python.net>
parents:
11915
diff
changeset
|
439 objects, |
|
23fd7d10064e
Renamed 'link_static_lib() to 'create_static_lib()', and rewrote it create
Greg Ward <gward@python.net>
parents:
11915
diff
changeset
|
440 output_libname, |
|
23fd7d10064e
Renamed 'link_static_lib() to 'create_static_lib()', and rewrote it create
Greg Ward <gward@python.net>
parents:
11915
diff
changeset
|
441 output_dir=None, |
|
23fd7d10064e
Renamed 'link_static_lib() to 'create_static_lib()', and rewrote it create
Greg Ward <gward@python.net>
parents:
11915
diff
changeset
|
442 debug=0, |
|
26036
771b6f521b95
This patch fixes the following bugs:
Gustavo Niemeyer <gustavo@niemeyer.net>
parents:
23917
diff
changeset
|
443 target_lang=None): |
|
11244
4385b1bcbc3b
Added msvccompiler module exactly as supplied by Perry Stoll.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
444 |
|
34693
604ff98915ec
Remove some more tab usage to prevent an error when run as ``python -tt``.
Brett Cannon <bcannon@gmail.com>
parents:
34692
diff
changeset
|
445 if not self.initialized: self.initialize() |
|
12056
1e5cd70cee10
Added 'runtime_library_dirs' parameter to 'link_*()' methods, and warn that
Greg Ward <gward@python.net>
parents:
12016
diff
changeset
|
446 (objects, output_dir) = self._fix_object_args (objects, output_dir) |
|
11915
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
447 output_filename = \ |
|
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
448 self.library_filename (output_libname, output_dir=output_dir) |
|
11244
4385b1bcbc3b
Added msvccompiler module exactly as supplied by Perry Stoll.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
449 |
|
11915
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
450 if self._need_link (objects, output_filename): |
|
11956
23fd7d10064e
Renamed 'link_static_lib() to 'create_static_lib()', and rewrote it create
Greg Ward <gward@python.net>
parents:
11915
diff
changeset
|
451 lib_args = objects + ['/OUT:' + output_filename] |
|
11915
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
452 if debug: |
|
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
453 pass # XXX what goes here? |
|
12790
f8c1c5b7dc9f
Changed to catch compile/link failures and raise CompileError, LibError,
Greg Ward <gward@python.net>
parents:
12717
diff
changeset
|
454 try: |
|
13015
affe10c3b92e
Define the 'executables' class attribute so the CCompiler constructor
Greg Ward <gward@python.net>
parents:
12793
diff
changeset
|
455 self.spawn ([self.lib] + lib_args) |
|
12790
f8c1c5b7dc9f
Changed to catch compile/link failures and raise CompileError, LibError,
Greg Ward <gward@python.net>
parents:
12717
diff
changeset
|
456 except DistutilsExecError, msg: |
|
f8c1c5b7dc9f
Changed to catch compile/link failures and raise CompileError, LibError,
Greg Ward <gward@python.net>
parents:
12717
diff
changeset
|
457 raise LibError, msg |
| 21267 | 458 |
|
11915
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
459 else: |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23274
diff
changeset
|
460 log.debug("skipping %s (up-to-date)", output_filename) |
|
11244
4385b1bcbc3b
Added msvccompiler module exactly as supplied by Perry Stoll.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
461 |
|
11956
23fd7d10064e
Renamed 'link_static_lib() to 'create_static_lib()', and rewrote it create
Greg Ward <gward@python.net>
parents:
11915
diff
changeset
|
462 # create_static_lib () |
| 21267 | 463 |
|
14890
afd7ece37c46
Big patch from Rene Liebscher to simplify the CCompiler API and
Greg Ward <gward@python.net>
parents:
14699
diff
changeset
|
464 def link (self, |
|
afd7ece37c46
Big patch from Rene Liebscher to simplify the CCompiler API and
Greg Ward <gward@python.net>
parents:
14699
diff
changeset
|
465 target_desc, |
|
afd7ece37c46
Big patch from Rene Liebscher to simplify the CCompiler API and
Greg Ward <gward@python.net>
parents:
14699
diff
changeset
|
466 objects, |
|
afd7ece37c46
Big patch from Rene Liebscher to simplify the CCompiler API and
Greg Ward <gward@python.net>
parents:
14699
diff
changeset
|
467 output_filename, |
|
afd7ece37c46
Big patch from Rene Liebscher to simplify the CCompiler API and
Greg Ward <gward@python.net>
parents:
14699
diff
changeset
|
468 output_dir=None, |
|
afd7ece37c46
Big patch from Rene Liebscher to simplify the CCompiler API and
Greg Ward <gward@python.net>
parents:
14699
diff
changeset
|
469 libraries=None, |
|
afd7ece37c46
Big patch from Rene Liebscher to simplify the CCompiler API and
Greg Ward <gward@python.net>
parents:
14699
diff
changeset
|
470 library_dirs=None, |
|
afd7ece37c46
Big patch from Rene Liebscher to simplify the CCompiler API and
Greg Ward <gward@python.net>
parents:
14699
diff
changeset
|
471 runtime_library_dirs=None, |
|
afd7ece37c46
Big patch from Rene Liebscher to simplify the CCompiler API and
Greg Ward <gward@python.net>
parents:
14699
diff
changeset
|
472 export_symbols=None, |
|
afd7ece37c46
Big patch from Rene Liebscher to simplify the CCompiler API and
Greg Ward <gward@python.net>
parents:
14699
diff
changeset
|
473 debug=0, |
|
afd7ece37c46
Big patch from Rene Liebscher to simplify the CCompiler API and
Greg Ward <gward@python.net>
parents:
14699
diff
changeset
|
474 extra_preargs=None, |
|
afd7ece37c46
Big patch from Rene Liebscher to simplify the CCompiler API and
Greg Ward <gward@python.net>
parents:
14699
diff
changeset
|
475 extra_postargs=None, |
|
26036
771b6f521b95
This patch fixes the following bugs:
Gustavo Niemeyer <gustavo@niemeyer.net>
parents:
23917
diff
changeset
|
476 build_temp=None, |
|
771b6f521b95
This patch fixes the following bugs:
Gustavo Niemeyer <gustavo@niemeyer.net>
parents:
23917
diff
changeset
|
477 target_lang=None): |
|
11244
4385b1bcbc3b
Added msvccompiler module exactly as supplied by Perry Stoll.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
478 |
|
34693
604ff98915ec
Remove some more tab usage to prevent an error when run as ``python -tt``.
Brett Cannon <bcannon@gmail.com>
parents:
34692
diff
changeset
|
479 if not self.initialized: self.initialize() |
|
12056
1e5cd70cee10
Added 'runtime_library_dirs' parameter to 'link_*()' methods, and warn that
Greg Ward <gward@python.net>
parents:
12016
diff
changeset
|
480 (objects, output_dir) = self._fix_object_args (objects, output_dir) |
|
1e5cd70cee10
Added 'runtime_library_dirs' parameter to 'link_*()' methods, and warn that
Greg Ward <gward@python.net>
parents:
12016
diff
changeset
|
481 (libraries, library_dirs, runtime_library_dirs) = \ |
|
1e5cd70cee10
Added 'runtime_library_dirs' parameter to 'link_*()' methods, and warn that
Greg Ward <gward@python.net>
parents:
12016
diff
changeset
|
482 self._fix_lib_args (libraries, library_dirs, runtime_library_dirs) |
|
1e5cd70cee10
Added 'runtime_library_dirs' parameter to 'link_*()' methods, and warn that
Greg Ward <gward@python.net>
parents:
12016
diff
changeset
|
483 |
|
12412
ae525ab23eef
Added 'link_executable()' method (Berthold Hoellmann).
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
484 if runtime_library_dirs: |
|
12056
1e5cd70cee10
Added 'runtime_library_dirs' parameter to 'link_*()' methods, and warn that
Greg Ward <gward@python.net>
parents:
12016
diff
changeset
|
485 self.warn ("I don't know what to do with 'runtime_library_dirs': " |
|
1e5cd70cee10
Added 'runtime_library_dirs' parameter to 'link_*()' methods, and warn that
Greg Ward <gward@python.net>
parents:
12016
diff
changeset
|
486 + str (runtime_library_dirs)) |
| 21267 | 487 |
|
12016
13fd0dfec560
Changed to pay attention to the 'runtime_library_dirs' list (= 'rpath'
Greg Ward <gward@python.net>
parents:
11956
diff
changeset
|
488 lib_opts = gen_lib_options (self, |
|
12056
1e5cd70cee10
Added 'runtime_library_dirs' parameter to 'link_*()' methods, and warn that
Greg Ward <gward@python.net>
parents:
12016
diff
changeset
|
489 library_dirs, runtime_library_dirs, |
|
12016
13fd0dfec560
Changed to pay attention to the 'runtime_library_dirs' list (= 'rpath'
Greg Ward <gward@python.net>
parents:
11956
diff
changeset
|
490 libraries) |
|
11915
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
491 if output_dir is not None: |
|
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
492 output_filename = os.path.join (output_dir, output_filename) |
| 11735 | 493 |
|
11915
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
494 if self._need_link (objects, output_filename): |
|
11244
4385b1bcbc3b
Added msvccompiler module exactly as supplied by Perry Stoll.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
495 |
|
14890
afd7ece37c46
Big patch from Rene Liebscher to simplify the CCompiler API and
Greg Ward <gward@python.net>
parents:
14699
diff
changeset
|
496 if target_desc == CCompiler.EXECUTABLE: |
|
afd7ece37c46
Big patch from Rene Liebscher to simplify the CCompiler API and
Greg Ward <gward@python.net>
parents:
14699
diff
changeset
|
497 if debug: |
|
afd7ece37c46
Big patch from Rene Liebscher to simplify the CCompiler API and
Greg Ward <gward@python.net>
parents:
14699
diff
changeset
|
498 ldflags = self.ldflags_shared_debug[1:] |
|
afd7ece37c46
Big patch from Rene Liebscher to simplify the CCompiler API and
Greg Ward <gward@python.net>
parents:
14699
diff
changeset
|
499 else: |
|
afd7ece37c46
Big patch from Rene Liebscher to simplify the CCompiler API and
Greg Ward <gward@python.net>
parents:
14699
diff
changeset
|
500 ldflags = self.ldflags_shared[1:] |
|
11915
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
501 else: |
|
14890
afd7ece37c46
Big patch from Rene Liebscher to simplify the CCompiler API and
Greg Ward <gward@python.net>
parents:
14699
diff
changeset
|
502 if debug: |
|
afd7ece37c46
Big patch from Rene Liebscher to simplify the CCompiler API and
Greg Ward <gward@python.net>
parents:
14699
diff
changeset
|
503 ldflags = self.ldflags_shared_debug |
|
afd7ece37c46
Big patch from Rene Liebscher to simplify the CCompiler API and
Greg Ward <gward@python.net>
parents:
14699
diff
changeset
|
504 else: |
|
afd7ece37c46
Big patch from Rene Liebscher to simplify the CCompiler API and
Greg Ward <gward@python.net>
parents:
14699
diff
changeset
|
505 ldflags = self.ldflags_shared |
|
11244
4385b1bcbc3b
Added msvccompiler module exactly as supplied by Perry Stoll.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
506 |
|
12717
0a6af59ebffd
Added support for the 'export_symbols' parameter to 'link_shared_object()'
Greg Ward <gward@python.net>
parents:
12412
diff
changeset
|
507 export_opts = [] |
|
0a6af59ebffd
Added support for the 'export_symbols' parameter to 'link_shared_object()'
Greg Ward <gward@python.net>
parents:
12412
diff
changeset
|
508 for sym in (export_symbols or []): |
|
0a6af59ebffd
Added support for the 'export_symbols' parameter to 'link_shared_object()'
Greg Ward <gward@python.net>
parents:
12412
diff
changeset
|
509 export_opts.append("/EXPORT:" + sym) |
|
0a6af59ebffd
Added support for the 'export_symbols' parameter to 'link_shared_object()'
Greg Ward <gward@python.net>
parents:
12412
diff
changeset
|
510 |
| 21267 | 511 ld_args = (ldflags + lib_opts + export_opts + |
|
12717
0a6af59ebffd
Added support for the 'export_symbols' parameter to 'link_shared_object()'
Greg Ward <gward@python.net>
parents:
12412
diff
changeset
|
512 objects + ['/OUT:' + output_filename]) |
|
11244
4385b1bcbc3b
Added msvccompiler module exactly as supplied by Perry Stoll.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
513 |
|
13798
031dae08a0a9
Patch from Rene Liebscher: generate an /IMPLIB: option to ensure that
Greg Ward <gward@python.net>
parents:
13241
diff
changeset
|
514 # The MSVC linker generates .lib and .exp files, which cannot be |
|
031dae08a0a9
Patch from Rene Liebscher: generate an /IMPLIB: option to ensure that
Greg Ward <gward@python.net>
parents:
13241
diff
changeset
|
515 # suppressed by any linker switches. The .lib files may even be |
|
031dae08a0a9
Patch from Rene Liebscher: generate an /IMPLIB: option to ensure that
Greg Ward <gward@python.net>
parents:
13241
diff
changeset
|
516 # needed! Make sure they are generated in the temporary build |
|
031dae08a0a9
Patch from Rene Liebscher: generate an /IMPLIB: option to ensure that
Greg Ward <gward@python.net>
parents:
13241
diff
changeset
|
517 # directory. Since they have different names for debug and release |
|
031dae08a0a9
Patch from Rene Liebscher: generate an /IMPLIB: option to ensure that
Greg Ward <gward@python.net>
parents:
13241
diff
changeset
|
518 # builds, they can go into the same directory. |
|
14890
afd7ece37c46
Big patch from Rene Liebscher to simplify the CCompiler API and
Greg Ward <gward@python.net>
parents:
14699
diff
changeset
|
519 if export_symbols is not None: |
|
afd7ece37c46
Big patch from Rene Liebscher to simplify the CCompiler API and
Greg Ward <gward@python.net>
parents:
14699
diff
changeset
|
520 (dll_name, dll_ext) = os.path.splitext( |
|
afd7ece37c46
Big patch from Rene Liebscher to simplify the CCompiler API and
Greg Ward <gward@python.net>
parents:
14699
diff
changeset
|
521 os.path.basename(output_filename)) |
|
afd7ece37c46
Big patch from Rene Liebscher to simplify the CCompiler API and
Greg Ward <gward@python.net>
parents:
14699
diff
changeset
|
522 implib_file = os.path.join( |
|
afd7ece37c46
Big patch from Rene Liebscher to simplify the CCompiler API and
Greg Ward <gward@python.net>
parents:
14699
diff
changeset
|
523 os.path.dirname(objects[0]), |
|
afd7ece37c46
Big patch from Rene Liebscher to simplify the CCompiler API and
Greg Ward <gward@python.net>
parents:
14699
diff
changeset
|
524 self.library_filename(dll_name)) |
|
afd7ece37c46
Big patch from Rene Liebscher to simplify the CCompiler API and
Greg Ward <gward@python.net>
parents:
14699
diff
changeset
|
525 ld_args.append ('/IMPLIB:' + implib_file) |
|
13798
031dae08a0a9
Patch from Rene Liebscher: generate an /IMPLIB: option to ensure that
Greg Ward <gward@python.net>
parents:
13241
diff
changeset
|
526 |
|
11915
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
527 if extra_preargs: |
|
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
528 ld_args[:0] = extra_preargs |
|
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
529 if extra_postargs: |
|
13798
031dae08a0a9
Patch from Rene Liebscher: generate an /IMPLIB: option to ensure that
Greg Ward <gward@python.net>
parents:
13241
diff
changeset
|
530 ld_args.extend(extra_postargs) |
|
11244
4385b1bcbc3b
Added msvccompiler module exactly as supplied by Perry Stoll.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
531 |
|
11915
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
532 self.mkpath (os.path.dirname (output_filename)) |
|
12790
f8c1c5b7dc9f
Changed to catch compile/link failures and raise CompileError, LibError,
Greg Ward <gward@python.net>
parents:
12717
diff
changeset
|
533 try: |
|
14890
afd7ece37c46
Big patch from Rene Liebscher to simplify the CCompiler API and
Greg Ward <gward@python.net>
parents:
14699
diff
changeset
|
534 self.spawn ([self.linker] + ld_args) |
|
12790
f8c1c5b7dc9f
Changed to catch compile/link failures and raise CompileError, LibError,
Greg Ward <gward@python.net>
parents:
12717
diff
changeset
|
535 except DistutilsExecError, msg: |
|
f8c1c5b7dc9f
Changed to catch compile/link failures and raise CompileError, LibError,
Greg Ward <gward@python.net>
parents:
12717
diff
changeset
|
536 raise LinkError, msg |
|
11244
4385b1bcbc3b
Added msvccompiler module exactly as supplied by Perry Stoll.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
537 |
|
11915
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
538 else: |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
23274
diff
changeset
|
539 log.debug("skipping %s (up-to-date)", output_filename) |
|
11244
4385b1bcbc3b
Added msvccompiler module exactly as supplied by Perry Stoll.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
540 |
|
14890
afd7ece37c46
Big patch from Rene Liebscher to simplify the CCompiler API and
Greg Ward <gward@python.net>
parents:
14699
diff
changeset
|
541 # link () |
|
12412
ae525ab23eef
Added 'link_executable()' method (Berthold Hoellmann).
Greg Ward <gward@python.net>
parents:
12407
diff
changeset
|
542 |
|
11244
4385b1bcbc3b
Added msvccompiler module exactly as supplied by Perry Stoll.
Greg Ward <gward@python.net>
parents:
diff
changeset
|
543 |
|
11915
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
544 # -- Miscellaneous methods ----------------------------------------- |
|
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
545 # These are all used by the 'gen_lib_options() function, in |
|
7922d08426ca
Serious overhaul of the C compiler interface and the two classes that
Greg Ward <gward@python.net>
parents:
11897
diff
changeset
|
546 # ccompiler.py. |
|
11360
4c7d6043b43a
Catch up with changes in 'gen_lib_options()':
Greg Ward <gward@python.net>
parents:
11337
diff
changeset
|
547 |
|
4c7d6043b43a
Catch up with changes in 'gen_lib_options()':
Greg Ward <gward@python.net>
parents:
11337
diff
changeset
|
548 def library_dir_option (self, dir): |
|
4c7d6043b43a
Catch up with changes in 'gen_lib_options()':
Greg Ward <gward@python.net>
parents:
11337
diff
changeset
|
549 return "/LIBPATH:" + dir |
|
4c7d6043b43a
Catch up with changes in 'gen_lib_options()':
Greg Ward <gward@python.net>
parents:
11337
diff
changeset
|
550 |
|
12016
13fd0dfec560
Changed to pay attention to the 'runtime_library_dirs' list (= 'rpath'
Greg Ward <gward@python.net>
parents:
11956
diff
changeset
|
551 def runtime_library_dir_option (self, dir): |
|
13fd0dfec560
Changed to pay attention to the 'runtime_library_dirs' list (= 'rpath'
Greg Ward <gward@python.net>
parents:
11956
diff
changeset
|
552 raise DistutilsPlatformError, \ |
|
13fd0dfec560
Changed to pay attention to the 'runtime_library_dirs' list (= 'rpath'
Greg Ward <gward@python.net>
parents:
11956
diff
changeset
|
553 "don't know how to set runtime library search path for MSVC++" |
|
13fd0dfec560
Changed to pay attention to the 'runtime_library_dirs' list (= 'rpath'
Greg Ward <gward@python.net>
parents:
11956
diff
changeset
|
554 |
|
11360
4c7d6043b43a
Catch up with changes in 'gen_lib_options()':
Greg Ward <gward@python.net>
parents:
11337
diff
changeset
|
555 def library_option (self, lib): |
|
4c7d6043b43a
Catch up with changes in 'gen_lib_options()':
Greg Ward <gward@python.net>
parents:
11337
diff
changeset
|
556 return self.library_filename (lib) |
|
4c7d6043b43a
Catch up with changes in 'gen_lib_options()':
Greg Ward <gward@python.net>
parents:
11337
diff
changeset
|
557 |
|
4c7d6043b43a
Catch up with changes in 'gen_lib_options()':
Greg Ward <gward@python.net>
parents:
11337
diff
changeset
|
558 |
|
13844
b37f08635023
Added 'debug' flag to 'find_library_file()', and changed code to handle it.
Greg Ward <gward@python.net>
parents:
13799
diff
changeset
|
559 def find_library_file (self, dirs, lib, debug=0): |
|
b37f08635023
Added 'debug' flag to 'find_library_file()', and changed code to handle it.
Greg Ward <gward@python.net>
parents:
13799
diff
changeset
|
560 # Prefer a debugging library if found (and requested), but deal |
|
b37f08635023
Added 'debug' flag to 'find_library_file()', and changed code to handle it.
Greg Ward <gward@python.net>
parents:
13799
diff
changeset
|
561 # with it if we don't have one. |
|
b37f08635023
Added 'debug' flag to 'find_library_file()', and changed code to handle it.
Greg Ward <gward@python.net>
parents:
13799
diff
changeset
|
562 if debug: |
|
b37f08635023
Added 'debug' flag to 'find_library_file()', and changed code to handle it.
Greg Ward <gward@python.net>
parents:
13799
diff
changeset
|
563 try_names = [lib + "_d", lib] |
|
b37f08635023
Added 'debug' flag to 'find_library_file()', and changed code to handle it.
Greg Ward <gward@python.net>
parents:
13799
diff
changeset
|
564 else: |
|
b37f08635023
Added 'debug' flag to 'find_library_file()', and changed code to handle it.
Greg Ward <gward@python.net>
parents:
13799
diff
changeset
|
565 try_names = [lib] |
|
11360
4c7d6043b43a
Catch up with changes in 'gen_lib_options()':
Greg Ward <gward@python.net>
parents:
11337
diff
changeset
|
566 for dir in dirs: |
|
13844
b37f08635023
Added 'debug' flag to 'find_library_file()', and changed code to handle it.
Greg Ward <gward@python.net>
parents:
13799
diff
changeset
|
567 for name in try_names: |
|
b37f08635023
Added 'debug' flag to 'find_library_file()', and changed code to handle it.
Greg Ward <gward@python.net>
parents:
13799
diff
changeset
|
568 libfile = os.path.join(dir, self.library_filename (name)) |
|
b37f08635023
Added 'debug' flag to 'find_library_file()', and changed code to handle it.
Greg Ward <gward@python.net>
parents:
13799
diff
changeset
|
569 if os.path.exists(libfile): |
|
b37f08635023
Added 'debug' flag to 'find_library_file()', and changed code to handle it.
Greg Ward <gward@python.net>
parents:
13799
diff
changeset
|
570 return libfile |
|
11360
4c7d6043b43a
Catch up with changes in 'gen_lib_options()':
Greg Ward <gward@python.net>
parents:
11337
diff
changeset
|
571 else: |
|
4c7d6043b43a
Catch up with changes in 'gen_lib_options()':
Greg Ward <gward@python.net>
parents:
11337
diff
changeset
|
572 # Oops, didn't find it in *any* of 'dirs' |
|
4c7d6043b43a
Catch up with changes in 'gen_lib_options()':
Greg Ward <gward@python.net>
parents:
11337
diff
changeset
|
573 return None |
|
4c7d6043b43a
Catch up with changes in 'gen_lib_options()':
Greg Ward <gward@python.net>
parents:
11337
diff
changeset
|
574 |
|
4c7d6043b43a
Catch up with changes in 'gen_lib_options()':
Greg Ward <gward@python.net>
parents:
11337
diff
changeset
|
575 # find_library_file () |
|
4c7d6043b43a
Catch up with changes in 'gen_lib_options()':
Greg Ward <gward@python.net>
parents:
11337
diff
changeset
|
576 |
|
29052
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
577 # Helper methods for using the MSVC registry settings |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
578 |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
579 def find_exe(self, exe): |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
580 """Return path to an MSVC executable program. |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
581 |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
582 Tries to find the program in several places: first, one of the |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
583 MSVC program search paths from the registry; next, the directories |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
584 in the PATH environment variable. If any of those work, return an |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
585 absolute path that is known to exist. If none of them work, just |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
586 return the original program name, 'exe'. |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
587 """ |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
588 |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
589 for p in self.__paths: |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
590 fn = os.path.join(os.path.abspath(p), exe) |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
591 if os.path.isfile(fn): |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
592 return fn |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
593 |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
594 # didn't find it; try existing path |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
595 for p in string.split(os.environ['Path'],';'): |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
596 fn = os.path.join(os.path.abspath(p),exe) |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
597 if os.path.isfile(fn): |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
598 return fn |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
599 |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
600 return exe |
|
32736
c3a096bfbd6b
Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents:
31129
diff
changeset
|
601 |
|
29052
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
602 def get_msvc_paths(self, path, platform='x86'): |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
603 """Get a list of devstudio directories (include, lib or path). |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
604 |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
605 Return a list of strings. The list will be empty if unable to |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
606 access the registry or appropriate registry keys not found. |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
607 """ |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
608 |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
609 if not _can_read_reg: |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
610 return [] |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
611 |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
612 path = path + " dirs" |
|
29918
ec9f18615485
Patch from John Anderson to enable VC 7.1 support.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
29117
diff
changeset
|
613 if self.__version >= 7: |
|
ec9f18615485
Patch from John Anderson to enable VC 7.1 support.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
29117
diff
changeset
|
614 key = (r"%s\%0.1f\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directories" |
|
ec9f18615485
Patch from John Anderson to enable VC 7.1 support.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
29117
diff
changeset
|
615 % (self.__root, self.__version)) |
|
29052
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
616 else: |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
617 key = (r"%s\6.0\Build System\Components\Platforms" |
|
29054
2b0c0bda5cca
Replace line somehow deleted before last checkin.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
29052
diff
changeset
|
618 r"\Win32 (%s)\Directories" % (self.__root, platform)) |
|
29052
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
619 |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
620 for base in HKEYS: |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
621 d = read_values(base, key) |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
622 if d: |
|
29918
ec9f18615485
Patch from John Anderson to enable VC 7.1 support.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
29117
diff
changeset
|
623 if self.__version >= 7: |
|
29052
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
624 return string.split(self.__macros.sub(d[path]), ";") |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
625 else: |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
626 return string.split(d[path], ";") |
|
31039
6cf09be0491d
See SF #848614: distutils' msvccompiler now tries to detect that MSVC6
Thomas Heller <theller@ctypes.org>
parents:
29918
diff
changeset
|
627 # MSVC 6 seems to create the registry entries we need only when |
|
6cf09be0491d
See SF #848614: distutils' msvccompiler now tries to detect that MSVC6
Thomas Heller <theller@ctypes.org>
parents:
29918
diff
changeset
|
628 # the GUI is run. |
|
6cf09be0491d
See SF #848614: distutils' msvccompiler now tries to detect that MSVC6
Thomas Heller <theller@ctypes.org>
parents:
29918
diff
changeset
|
629 if self.__version == 6: |
|
6cf09be0491d
See SF #848614: distutils' msvccompiler now tries to detect that MSVC6
Thomas Heller <theller@ctypes.org>
parents:
29918
diff
changeset
|
630 for base in HKEYS: |
|
6cf09be0491d
See SF #848614: distutils' msvccompiler now tries to detect that MSVC6
Thomas Heller <theller@ctypes.org>
parents:
29918
diff
changeset
|
631 if read_values(base, r"%s\6.0" % self.__root) is not None: |
|
6cf09be0491d
See SF #848614: distutils' msvccompiler now tries to detect that MSVC6
Thomas Heller <theller@ctypes.org>
parents:
29918
diff
changeset
|
632 self.warn("It seems you have Visual Studio 6 installed, " |
|
6cf09be0491d
See SF #848614: distutils' msvccompiler now tries to detect that MSVC6
Thomas Heller <theller@ctypes.org>
parents:
29918
diff
changeset
|
633 "but the expected registry settings are not present.\n" |
|
6cf09be0491d
See SF #848614: distutils' msvccompiler now tries to detect that MSVC6
Thomas Heller <theller@ctypes.org>
parents:
29918
diff
changeset
|
634 "You must at least run the Visual Studio GUI once " |
|
6cf09be0491d
See SF #848614: distutils' msvccompiler now tries to detect that MSVC6
Thomas Heller <theller@ctypes.org>
parents:
29918
diff
changeset
|
635 "so that these entries are created.") |
|
37966
895b7daba2d6
Put break at correct level so *all* root HKEYs acutally get checked for
Trent Mick <trentm@activestate.com>
parents:
36630
diff
changeset
|
636 break |
|
29052
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
637 return [] |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
638 |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
639 def set_path_env_var(self, name): |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
640 """Set environment variable 'name' to an MSVC path type value. |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
641 |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
642 This is equivalent to a SET command prior to execution of spawned |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
643 commands. |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
644 """ |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
645 |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
646 if name == "lib": |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
647 p = self.get_msvc_paths("library") |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
648 else: |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
649 p = self.get_msvc_paths(name) |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
650 if p: |
|
143fff8d2189
Variant of SF patch 614770: MSVC 7 support
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
27564
diff
changeset
|
651 os.environ[name] = string.join(p, ';') |
|
44117
ead0d47b012b
Applied my patch #1455 with some extra fixes for VS 2005
Christian Heimes <christian@cheimes.de>
parents:
41347
diff
changeset
|
652 |
|
ead0d47b012b
Applied my patch #1455 with some extra fixes for VS 2005
Christian Heimes <christian@cheimes.de>
parents:
41347
diff
changeset
|
653 |
|
ead0d47b012b
Applied my patch #1455 with some extra fixes for VS 2005
Christian Heimes <christian@cheimes.de>
parents:
41347
diff
changeset
|
654 if get_build_version() >= 8.0: |
|
ead0d47b012b
Applied my patch #1455 with some extra fixes for VS 2005
Christian Heimes <christian@cheimes.de>
parents:
41347
diff
changeset
|
655 log.debug("Importing new compiler from distutils.msvc9compiler") |
|
ead0d47b012b
Applied my patch #1455 with some extra fixes for VS 2005
Christian Heimes <christian@cheimes.de>
parents:
41347
diff
changeset
|
656 OldMSVCCompiler = MSVCCompiler |
|
ead0d47b012b
Applied my patch #1455 with some extra fixes for VS 2005
Christian Heimes <christian@cheimes.de>
parents:
41347
diff
changeset
|
657 from distutils.msvc9compiler import MSVCCompiler |
|
46331
a93d2919ea59
Issue #2513: enable 64bit cross compilation on windows.
Mark Hammond <mhammond@skippinet.com.au>
parents:
45413
diff
changeset
|
658 # get_build_architecture not really relevant now we support cross-compile |
|
44117
ead0d47b012b
Applied my patch #1455 with some extra fixes for VS 2005
Christian Heimes <christian@cheimes.de>
parents:
41347
diff
changeset
|
659 from distutils.msvc9compiler import MacroExpander |
