Skip to content

Commit

Permalink
Merge pull request #1711 from sankhesh/msvc_preview
Browse files Browse the repository at this point in the history
msvc: Allow building with Visual Studio Preview versions
  • Loading branch information
mergify[bot] committed Dec 22, 2023
2 parents 0a276f7 + c7b4485 commit f4cfdb8
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,21 @@ def Exit( self ):
'See the YCM docs for details on how to use a custom Clangd.' )


def FindLatestMSVC( quiet ):
def FindLatestMSVC( quiet, preview=False ):
ACCEPTABLE_VERSIONS = [ 17, 16, 15 ]

VSWHERE_EXE = os.path.join( os.environ[ 'ProgramFiles(x86)' ],
'Microsoft Visual Studio',
'Installer', 'vswhere.exe' )

if os.path.exists( VSWHERE_EXE ):
vswhere_args = [ VSWHERE_EXE,
'-latest', '-property', 'installationVersion' ]
if preview:
vswhere_args.append( '-prerelease' )
if not quiet:
print( "Calling vswhere -latest -installationVersion" )
latest_full_v = subprocess.check_output(
[ VSWHERE_EXE, '-latest', '-property', 'installationVersion' ]
).strip().decode()
print( "Calling", *vswhere_args )
latest_full_v = subprocess.check_output( vswhere_args ).strip().decode()
if '.' in latest_full_v:
try:
latest_v = int( latest_full_v.split( '.' )[ 0 ] )
Expand Down Expand Up @@ -534,6 +536,10 @@ def ParseArguments():
action = 'store_true',
help = 'Compiling with sudo causes problems. If you'
' know what you are doing, proceed.' )
parser.add_argument( '--preview-msvc',
action = 'store_true',
help = 'Allow compiling against latest MSVC Preview'
' version.' )

# These options are deprecated.
parser.add_argument( '--omnisharp-completer', action = 'store_true',
Expand All @@ -555,7 +561,7 @@ def ParseArguments():
args.enable_debug = True

if OnWindows() and args.msvc is None:
args.msvc = FindLatestMSVC( args.quiet )
args.msvc = FindLatestMSVC( args.quiet, args.preview_msvc )
if args.msvc is None:
raise FileNotFoundError( "Could not find a valid MSVC version." )

Expand Down

0 comments on commit f4cfdb8

Please sign in to comment.