@@ -94,7 +94,7 @@ def do_pre_build(self, thebuilder):
9494 shell_env = shell_environment .GetEnvironment ()
9595 # Use the tools lib to determine the correct values for the vars that interest us.
9696 vs_vars = locate_tools .QueryVcVariables (
97- interesting_keys , VC_HOST_ARCH_TRANSLATOR [HostType ], vs_version = "vs2017" )
97+ interesting_keys , VC_HOST_ARCH_TRANSLATOR [HostType ], vs_version = "vs2017" , vc_version = vc_ver )
9898 for (k , v ) in vs_vars .items ():
9999 shell_env .set_shell_var (k , v )
100100
@@ -167,7 +167,7 @@ def do_pre_build(self, thebuilder):
167167 shell_env = shell_environment .GetEnvironment ()
168168 # Use the tools lib to determine the correct values for the vars that interest us.
169169 vs_vars = locate_tools .QueryVcVariables (
170- interesting_keys , VC_HOST_ARCH_TRANSLATOR [HostType ], vs_version = "vs2019" )
170+ interesting_keys , VC_HOST_ARCH_TRANSLATOR [HostType ], vs_version = "vs2019" , vc_version = vc_ver )
171171 for (k , v ) in vs_vars .items ():
172172 shell_env .set_shell_var (k , v )
173173
@@ -247,7 +247,7 @@ def do_pre_build(self, thebuilder):
247247 shell_env = shell_environment .GetEnvironment ()
248248 # Use the tools lib to determine the correct values for the vars that interest us.
249249 vs_vars = locate_tools .QueryVcVariables (
250- interesting_keys , VC_HOST_ARCH_TRANSLATOR [HostType ], vs_version = "VS2022" )
250+ interesting_keys , VC_HOST_ARCH_TRANSLATOR [HostType ], vs_version = "VS2022" , vc_version = vc_ver )
251251 for (k , v ) in vs_vars .items ():
252252 shell_env .set_shell_var (k , v )
253253
@@ -373,6 +373,10 @@ def _get_vc_version(self, path, varname):
373373 self .Logger .critical (
374374 "Failed to find VC tools. Might need to check for VS install" )
375375 return vc_ver
376- vc_ver = os .listdir (p2 )[- 1 ].strip () # get last in list
376+
377+ dirs = os .listdir (p2 )
378+ if len (dirs ) > 1 :
379+ logging .warning (f"Multiple VC versions found: [{ ', ' .join (dirs )} ]. Using { dirs [- 1 ]} " )
380+ vc_ver = dirs [- 1 ].strip () # get last in list
377381 self .Logger .debug ("Found VC Tool version is %s" % vc_ver )
378382 return vc_ver
0 commit comments