|
15 | 15 | import os |
16 | 16 | import glob |
17 | 17 |
|
18 | | -from SCons.Tool.MSCommon.vc import find_vc_pdir |
| 18 | +from SCons.Tool.MSCommon.vc import find_vc_pdir, msvc_toolset_versions |
19 | 19 |
|
20 | 20 | Import( |
21 | 21 | 'env', |
@@ -43,23 +43,28 @@ localWin10Lib = env.SharedLibrary( |
43 | 43 | # UWP dlls can only be dynamically linked with the CRT, |
44 | 44 | # but some systems might not have this version of the CRT. |
45 | 45 | # 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. |
48 | 47 | msvc = 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 | +vcRedistDirs = [ |
| 50 | + os.path.join( |
| 51 | + find_vc_pdir(env, msvc), |
| 52 | + rf"Redist\MSVC\{toolset}\x86\Microsoft.VC{msvc.replace('.', '')}.CRT" |
| 53 | + ) |
| 54 | + for toolset in reversed(toolsets) |
| 55 | +] |
53 | 56 | if len(vcRedistDirs)==0: |
54 | 57 | raise RuntimeError("Could not locate vc redistributables. Perhaps the Universal Windows Platform component in visual Studio is not installed") |
55 | | -vcRedistDirs.sort(reverse=True) |
56 | 58 | for fn in ("msvcp140.dll", "vccorlib140.dll", "vcruntime140.dll"): |
57 | 59 | for vcRedistDir in vcRedistDirs: |
58 | 60 | path = os.path.join(vcRedistDir, fn) |
59 | 61 | if os.path.isfile(path): |
60 | 62 | env.Install(sourceDir, path) |
61 | 63 | break |
62 | 64 | else: |
63 | | - raise RuntimeError("Could not locate %s. Perhaps the Universal Windows Platform component in visual Studio is not installed"%fn) |
| 65 | + raise RuntimeError( |
| 66 | + f"Could not locate {path!r}. " |
| 67 | + "Perhaps the Universal Windows Platform component in visual Studio is not installed" |
| 68 | + ) |
64 | 69 |
|
65 | 70 | Return(['localWin10Lib']) |
0 commit comments