Skip to content

Commit 9173247

Browse files
committed
fix: fix build
Signed-off-by: Paolo Insogna <paolo@cowtech.it>
1 parent 7a36a54 commit 9173247

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

deps/libffi/preprocess_asm.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,42 @@ def split_command(value):
1818
return shlex.split(value, posix=(os.name != 'nt'))
1919

2020

21+
def resolve_msvc_cl():
22+
vcinstall = os.environ.get('VCINSTALLDIR')
23+
if not vcinstall:
24+
return None
25+
26+
tools_root = Path(vcinstall) / 'Tools' / 'MSVC'
27+
if not tools_root.is_dir():
28+
return None
29+
30+
vctools_version = os.environ.get('VCToolsVersion')
31+
candidates = []
32+
33+
if vctools_version:
34+
candidates.append(tools_root / vctools_version)
35+
36+
candidates.extend(sorted(tools_root.glob('*'), reverse=True))
37+
38+
for version_dir in candidates:
39+
cl_path = version_dir / 'bin' / 'Hostx64' / 'x64' / 'cl.exe'
40+
if cl_path.is_file():
41+
return [str(cl_path)]
42+
43+
return None
44+
45+
2146
def find_compiler(preferred=None):
2247
if preferred:
2348
command = split_command(preferred)
24-
if command and shutil.which(command[0]):
25-
return command
49+
if command:
50+
compiler_name = Path(command[0]).name.lower()
51+
if os.name == 'nt' and compiler_name in ('cl', 'cl.exe'):
52+
msvc = resolve_msvc_cl()
53+
if msvc:
54+
return msvc + command[1:]
55+
if shutil.which(command[0]):
56+
return command
2657

2758
for var in ('CC', 'CXX'):
2859
command = split_command(os.environ.get(var))

0 commit comments

Comments
 (0)