Skip to content

Commit d4970e1

Browse files
authored
Merge branch 'master' into fix-libclag-14-flags
2 parents 27ca4de + c3c27de commit d4970e1

32 files changed

+1535
-193
lines changed

benchmark.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from __future__ import absolute_import
77

88
import argparse
9+
import platform
910
import os
1011
import os.path as p
1112
import subprocess
@@ -31,7 +32,7 @@ def BuildYcmdLibsAndRunBenchmark( args, extra_args ):
3132

3233
os.environ[ 'YCM_BENCHMARK' ] = '1'
3334

34-
if args.msvc:
35+
if args.msvc and platform.system() == 'Windows':
3536
build_cmd.extend( [ '--msvc', str( args.msvc ) ] )
3637

3738
subprocess.check_call( build_cmd )

build.py

Lines changed: 70 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def Exit( self ):
9595
'09650af5c9dc39f0b40981bcdaa2170cbbc5bb003ac90cdb07fbb57381ac47b2'
9696
)
9797

98-
RUST_TOOLCHAIN = 'nightly-2021-10-26'
98+
RUST_TOOLCHAIN = 'nightly-2022-08-17'
9999
RUST_ANALYZER_DIR = p.join( DIR_OF_THIRD_PARTY, 'rust-analyzer' )
100100

101101
BUILD_ERROR_MESSAGE = (
@@ -115,6 +115,64 @@ def Exit( self ):
115115
'See the YCM docs for details on how to use a custom Clangd.' )
116116

117117

118+
def FindLatestMSVC( quiet ):
119+
ACCEPTABLE_VERSIONS = [ 17, 16, 15 ]
120+
121+
VSWHERE_EXE = os.path.join( os.environ[ 'ProgramFiles(x86)' ],
122+
'Microsoft Visual Studio',
123+
'Installer', 'vswhere.exe' )
124+
125+
if os.path.exists( VSWHERE_EXE ):
126+
if not quiet:
127+
print( "Calling vswhere -latest -installationVersion" )
128+
latest_full_v = subprocess.check_output(
129+
[ VSWHERE_EXE, '-latest', '-property', 'installationVersion' ]
130+
).strip().decode()
131+
if '.' in latest_full_v:
132+
try:
133+
latest_v = int( latest_full_v.split( '.' )[ 0 ] )
134+
except ValueError:
135+
raise ValueError( f"{latest_full_v} is not a version number." )
136+
137+
if not quiet:
138+
print( f'vswhere -latest returned version {latest_full_v}' )
139+
140+
if latest_v not in ACCEPTABLE_VERSIONS:
141+
if latest_v > 17:
142+
if not quiet:
143+
print( f'MSVC Version {latest_full_v} is newer than expected.' )
144+
else:
145+
raise ValueError(
146+
f'vswhere returned {latest_full_v} which is unexpected.'
147+
'Pass --msvc <version> argument.' )
148+
return latest_v
149+
else:
150+
if not quiet:
151+
print( f'vswhere returned nothing usable, {latest_full_v}' )
152+
153+
# Fall back to registry parsing, which works at least until MSVC 2019 (16)
154+
# but is likely failing on MSVC 2022 (17)
155+
if not quiet:
156+
print( "vswhere method failed, falling back to searching the registry" )
157+
158+
import winreg
159+
handle = winreg.ConnectRegistry( None, winreg.HKEY_LOCAL_MACHINE )
160+
msvc = None
161+
for i in ACCEPTABLE_VERSIONS:
162+
if not quiet:
163+
print( 'Trying to find '
164+
rf'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\{i}.0' )
165+
try:
166+
winreg.OpenKey( handle, rf'SOFTWARE\Microsoft\VisualStudio\{i}.0' )
167+
if not quiet:
168+
print( f"Found MSVC version {i}" )
169+
msvc = i
170+
break
171+
except FileNotFoundError:
172+
pass
173+
return msvc
174+
175+
118176
def RemoveDirectory( directory ):
119177
try_number = 0
120178
max_tries = 10
@@ -409,9 +467,11 @@ def ParseArguments():
409467
parser.add_argument( '--system-libclang', action = 'store_true',
410468
help = 'Use system libclang instead of downloading one '
411469
'from llvm.org. NOT RECOMMENDED OR SUPPORTED!' )
412-
parser.add_argument( '--msvc', type = int, choices = [ 15, 16, 17 ],
413-
default = 16, help = 'Choose the Microsoft Visual '
414-
'Studio version (default: %(default)s).' )
470+
if OnWindows():
471+
parser.add_argument( '--msvc', type = int, choices = [ 15, 16, 17 ],
472+
default=None,
473+
help= 'Choose the Microsoft Visual Studio version '
474+
'(default: %(default)s).' )
415475
parser.add_argument( '--ninja', action = 'store_true',
416476
help = 'Use Ninja build system.' )
417477
parser.add_argument( '--all',
@@ -490,6 +550,11 @@ def ParseArguments():
490550
# We always want a debug build when running with coverage enabled
491551
args.enable_debug = True
492552

553+
if OnWindows() and args.msvc is None:
554+
args.msvc = FindLatestMSVC( args.quiet )
555+
if args.msvc is None:
556+
raise FileNotFoundError( "Could not find a valid MSVC version." )
557+
493558
if args.core_tests:
494559
os.environ[ 'YCM_TESTRUN' ] = '1'
495560
elif os.environ.get( 'YCM_TESTRUN' ):
@@ -868,7 +933,7 @@ def EnableGoCompleter( args ):
868933
new_env.pop( 'GOROOT', None )
869934
new_env[ 'GOBIN' ] = p.join( new_env[ 'GOPATH' ], 'bin' )
870935

871-
gopls = 'golang.org/x/tools/gopls@v0.7.1'
936+
gopls = 'golang.org/x/tools/gopls@v0.9.4'
872937
CheckCall( [ go, 'install', gopls ],
873938
env = new_env,
874939
quiet = args.quiet,

cpp/ycm/CodePoint.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include <algorithm>
2222
#include <array>
23+
#include <cstdint>
2324
#include <cstring>
2425

2526
namespace YouCompleteMe {

cpp/ycm/CodePoint.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#ifndef CODE_POINT_H_3W0LNCLY
1919
#define CODE_POINT_H_3W0LNCLY
2020

21+
#include <cstdint>
2122
#include <stdexcept>
2223
#include <string>
2324
#include <vector>

0 commit comments

Comments
 (0)