1515import os
1616import glob
1717
18- from SCons.Tool.MSCommon.vc import find_vc_pdir
18+ from SCons.Tool.MSCommon.vc import find_vc_pdir, msvc_toolset_versions
1919
2020Import(
2121 'env',
@@ -43,13 +43,17 @@ localWin10Lib = env.SharedLibrary(
4343# UWP dlls can only be dynamically linked with the CRT,
4444# but some systems might not have this version of the CRT.
4545# Therefore, we must include it.
46- # VS 2017 keeps changing the path to reflect the latest major.minor.build version which we canot easily find out.
47- # Therefore Search these versioned directories from newest to oldest to collect all the files we need.
46+ # Search available toolset directories from newest to oldest to collect all the files we need.
4847msvc = env.get('MSVC_VERSION')
49- vcRedistDirs = glob.glob(os.path.join(
50- find_vc_pdir(env, msvc),
51- rf"Redist\MSVC\{msvc}*\x86\Microsoft.VC{msvc.replace('.', '')}.CRT"
52- ))
48+ toolsets = msvc_toolset_versions(msvc, full=True)
49+ print(toolsets)
50+ vcRedistDirs = [
51+ os.path.join(
52+ find_vc_pdir(env, msvc),
53+ rf"Redist\MSVC\{toolset}\x86\Microsoft.VC{msvc.replace('.', '')}.CRT"
54+ )
55+ for toolset in toolsets
56+ ]
5357if len(vcRedistDirs)==0:
5458 raise RuntimeError("Could not locate vc redistributables. Perhaps the Universal Windows Platform component in visual Studio is not installed")
5559vcRedistDirs.sort(reverse=True)
@@ -60,6 +64,9 @@ for fn in ("msvcp140.dll", "vccorlib140.dll", "vcruntime140.dll"):
6064 env.Install(sourceDir, path)
6165 break
6266 else:
63- raise RuntimeError("Could not locate %s. Perhaps the Universal Windows Platform component in visual Studio is not installed"%fn)
67+ raise RuntimeError(
68+ f"Could not locate {path!r}. "
69+ "Perhaps the Universal Windows Platform component in visual Studio is not installed"
70+ )
6471
6572Return(['localWin10Lib'])
0 commit comments