Skip to content
This repository was archived by the owner on Feb 4, 2020. It is now read-only.

Commit ca27e39

Browse files
Cascadesizmmisha
authored andcommitted
Add check for toolsetVersion
1 parent 287ef11 commit ca27e39

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

clcache/__main__.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@
7171
NMPWAIT_WAIT_FOREVER = wintypes.DWORD(0xFFFFFFFF)
7272
ERROR_PIPE_BUSY = 231
7373

74+
# Toolset version 140
75+
# https://devblogs.microsoft.com/cppblog/side-by-side-minor-version-msvc-toolsets-in-visual-studio-2017/
76+
TOOLSET_VERSION_140 = 140
77+
7478
# ManifestEntry: an entry in a manifest file
7579
# `includeFiles`: list of paths to include files, which this source file uses
7680
# `includesContentsHash`: hash of the contents of the includeFiles
@@ -1730,6 +1734,35 @@ def filterSourceFiles(cmdLine: List[str], sourceFiles: List[Tuple[str, str]]) ->
17301734
if not (arg in setOfSources or arg.startswith(skippedArgs))
17311735
)
17321736

1737+
1738+
def findCompilerVersion(compiler: str) -> int:
1739+
compilerInfo = subprocess.Popen([compiler],
1740+
stdout=subprocess.PIPE,
1741+
stderr=subprocess.STDOUT)
1742+
compilerVersionLine = compilerInfo.communicate()[0].decode('utf-8').splitlines()[0]
1743+
compilerVersion = compilerVersionLine[compilerVersionLine.find("Version ") + 8:
1744+
compilerVersionLine.find(" for")]
1745+
return int(compilerVersion[:2] + compilerVersion[3:5])
1746+
1747+
1748+
def findToolsetVersion(compilerVersion: int) -> int:
1749+
versionMap = {1400: 80,
1750+
1500: 90,
1751+
1600: 100,
1752+
1700: 110,
1753+
1800: 120,
1754+
1900: 140}
1755+
1756+
if compilerVersion in versionMap:
1757+
return versionMap[compilerVersion]
1758+
elif 1910 <= compilerVersion < 1920:
1759+
return 141
1760+
elif 1920 <= compilerVersion < 1930:
1761+
return 142
1762+
else:
1763+
raise LogicException('Bad cl.exe version: {}'.format(compilerVersion))
1764+
1765+
17331766
def scheduleJobs(cache: Any, compiler: str, cmdLine: List[str], environment: Any,
17341767
sourceFiles: List[Tuple[str, str]], objectFiles: List[str]) -> int:
17351768
# Filter out all source files from the command line to form baseCmdLine
@@ -1740,7 +1773,8 @@ def scheduleJobs(cache: Any, compiler: str, cmdLine: List[str], environment: Any
17401773

17411774
def poolExecutor(*args, **kwargs) -> concurrent.futures.Executor:
17421775
if isTrackerEnabled():
1743-
return concurrent.futures.ProcessPoolExecutor(*args, **kwargs)
1776+
if findToolsetVersion(findCompilerVersion(compiler)) < TOOLSET_VERSION_140:
1777+
return concurrent.futures.ProcessPoolExecutor(*args, **kwargs)
17441778
return concurrent.futures.ThreadPoolExecutor(*args, **kwargs)
17451779

17461780
with poolExecutor(max_workers=min(jobCount(cmdLine), len(objectFiles))) as executor:

0 commit comments

Comments
 (0)