Skip to content

Commit

Permalink
msvc: register only the version that have been asked to (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kojoley authored May 23, 2024
1 parent cd7c153 commit 5cde9e8
Showing 1 changed file with 26 additions and 41 deletions.
67 changes: 26 additions & 41 deletions src/tools/msvc.jam
Original file line number Diff line number Diff line change
Expand Up @@ -1040,47 +1040,37 @@ class msvc-pch-generator : pch-generator
#
################################################################################

# Detects versions listed as '.known-versions' by checking registry information,
# Try to find and register a specified version by checking registry information,
# environment variables & default paths. Supports both native Windows and
# Cygwin.
#
local rule auto-detect-toolset-versions ( )
local rule try-auto-detect-version ( version )
{
if [ os.name ] in NT CYGWIN
if [ os.name ] in NT CYGWIN && $(.version-$(version)-reg)
{
# Get installation paths from the registry.
for local i in $(.known-versions)
local vc-path ;
for local x in "" "Wow6432Node\\"
{
if $(.version-$(i)-reg)
{
local vc-path ;
for local x in "" "Wow6432Node\\"
{
vc-path += [ W32_GETREG
"HKEY_LOCAL_MACHINE\\SOFTWARE\\"$(x)"\\Microsoft\\"$(.version-$(i)-reg)
: "ProductDir" ] ;
}
vc-path += [ W32_GETREG
"HKEY_LOCAL_MACHINE\\SOFTWARE\\"$(x)"\\Microsoft\\"$(.version-$(version)-reg)
: "ProductDir" ] ;
}

if $(vc-path)
{
vc-path = [ path.join [ path.make-NT $(vc-path[1]) ] "bin" ] ;
register-configuration $(i) : [ path.native $(vc-path[1]) ] ;
}
}
else
{
register-configuration $(i) : [ default-path $(i) ] ;
}
if $(vc-path)
{
vc-path = [ path.join [ path.make-NT $(vc-path[1]) ] "bin" ] ;
register-configuration $(version) : [ path.native $(vc-path[1]) ] ;
return true ;
}
}

# Check environment and default installation paths.
for local i in $(.known-versions)
local path = [ default-path $(version) ] ;
if $(path)
{
if ! $(i) in [ $(.versions).all ]
{
register-configuration $(i) : [ default-path $(i) ] ;
}
register-configuration $(version) : $(path) ;
return true ;
}
}

Expand Down Expand Up @@ -1255,19 +1245,19 @@ local rule configure-really ( version ? : options * )
# FIXME: consider whether an explicitly specified setup script
# should disable this logic. We already won't get here if
# there is a user specified command.
version = [ $(.versions).all ] ;
for local known in $(.known-versions)
for version in $(.known-versions)
{
if $(known) in $(version)
if [ try-auto-detect-version $(version) ]
{
version = $(known) ;
break ;
}
}
# version might still have multiple elements if no versions
# were auto-detected, but an unknown version was configured
# manually.
version = $(version[1]) ;
}
else if $(version)
{
# Version alias -> real version number.
version = [ resolve-possible-msvc-version-alias $(version) ] ;
try-auto-detect-version $(version) ;
}

# Handle a user-provided command, and deduce the version if necessary.
Expand Down Expand Up @@ -1364,8 +1354,6 @@ local rule configure-really ( version ? : options * )
}
}

# Version alias -> real version number.
version = [ resolve-possible-msvc-version-alias $(version) ] ;

# Check whether the selected configuration is already in use.
if $(version) in [ $(.versions).used ]
Expand Down Expand Up @@ -2223,9 +2211,6 @@ for local arch in [ MATCH "^\\.cpus-on-(.*)" : [ VARNAMES $(__name__) ] ]
;
.version-14.3-env = VS170COMNTOOLS ProgramFiles ProgramFiles(x86) ;

# Auto-detect all the available msvc installations on the system.
auto-detect-toolset-versions ;


# And finally trigger the actual Boost Build toolset registration.
register-toolset ;

1 comment on commit 5cde9e8

@grafikrobot
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this broke having only using msvc : all ; in user-config.jam.

Please sign in to comment.