@@ -1318,17 +1318,34 @@ def postprocessObjectEvicted(cache, objectFile, cachekey, compilerResult):
13181318 return compilerResult
13191319
13201320
1321- def postprocessHeaderChangedMiss (
1322- cache , objectFile , manifestSection , manifest , manifestHash , includesContentHash , compilerResult ):
1321+ def createManifest (manifestHash , includePaths ):
1322+ baseDir = normalizeBaseDir (os .environ .get ('CLCACHE_BASEDIR' ))
1323+
1324+ includes = {path :getFileHash (path ) for path in includePaths }
1325+ includesContentHash = ManifestRepository .getIncludesContentHashForFiles (includes )
13231326 cachekey = Cache .getDirectCacheKey (manifestHash , includesContentHash )
1327+
1328+ # Create new manifest
1329+ if baseDir :
1330+ relocatableIncludePaths = {
1331+ collapseBasedirToPlaceholder (path , baseDir ):contentHash
1332+ for path , contentHash in includes .items ()
1333+ }
1334+ manifest = Manifest (relocatableIncludePaths , {})
1335+ else :
1336+ manifest = Manifest (includes , {})
1337+ manifest .includesContentToObjectMap [includesContentHash ] = cachekey
1338+ return manifest , cachekey
1339+
1340+
1341+ def postprocessHeaderChangedMiss (
1342+ cache , objectFile , manifestSection , manifestHash , sourceFile , compilerResult , stripIncludes ):
13241343 returnCode , compilerOutput , compilerStderr = compilerResult
1344+ includePaths , compilerOutput = parseIncludesSet (compilerOutput , sourceFile , stripIncludes )
13251345
13261346 removedItems = []
13271347 if returnCode == 0 and os .path .exists (objectFile ):
1328- while len (manifest .includesContentToObjectMap ) >= MAX_MANIFEST_HASHES :
1329- _ , objectHash = manifest .includesContentToObjectMap .popitem ()
1330- removedItems .append (objectHash )
1331- manifest .includesContentToObjectMap [includesContentHash ] = cachekey
1348+ manifest , cachekey = createManifest (manifestHash , includePaths )
13321349
13331350 with cache .lock , cache .statistics as stats :
13341351 stats .registerHeaderChangedMiss ()
@@ -1341,28 +1358,15 @@ def postprocessHeaderChangedMiss(
13411358
13421359
13431360def postprocessNoManifestMiss (
1344- cache , objectFile , manifestSection , manifestHash , baseDir , sourceFile , compilerResult , stripIncludes ):
1361+ cache , objectFile , manifestSection , manifestHash , sourceFile , compilerResult , stripIncludes ):
13451362 returnCode , compilerOutput , compilerStderr = compilerResult
13461363 includePaths , compilerOutput = parseIncludesSet (compilerOutput , sourceFile , stripIncludes )
13471364
13481365 manifest = None
13491366 cachekey = None
13501367
13511368 if returnCode == 0 and os .path .exists (objectFile ):
1352- includes = {path :getFileHash (path ) for path in includePaths }
1353- includesContentHash = ManifestRepository .getIncludesContentHashForFiles (includes )
1354- cachekey = Cache .getDirectCacheKey (manifestHash , includesContentHash )
1355-
1356- # Create new manifest
1357- if baseDir :
1358- relocatableIncludePaths = {
1359- collapseBasedirToPlaceholder (path , baseDir ):contentHash
1360- for path , contentHash in includes .items ()
1361- }
1362- manifest = Manifest (relocatableIncludePaths , {})
1363- else :
1364- manifest = Manifest (includes , {})
1365- manifest .includesContentToObjectMap [includesContentHash ] = cachekey
1369+ manifest , cachekey = createManifest (manifestHash , includePaths )
13661370
13671371 with cache .lock , cache .statistics as stats :
13681372 stats .registerSourceChangedMiss ()
@@ -1515,19 +1519,22 @@ def processDirect(cache, objectFile, compiler, cmdLine, sourceFile):
15151519 postProcessing = lambda compilerResult : postprocessObjectEvicted (
15161520 cache , objectFile , cachekey , compilerResult )
15171521 except IncludeChangedException :
1522+ createNewManifest = True
15181523 postProcessing = lambda compilerResult : postprocessHeaderChangedMiss (
1519- cache , objectFile , manifestSection , manifest , manifestHash , includesContentHash , compilerResult )
1524+ cache , objectFile , manifestSection , manifestHash , sourceFile , compilerResult , stripIncludes )
15201525 except IncludeNotFoundException :
15211526 # register nothing. This is probably just a compile error
15221527 postProcessing = None
15231528 else :
1524- origCmdLine = cmdLine
1525- stripIncludes = False
1526- if '/showIncludes' not in cmdLine :
1527- cmdLine = ['/showIncludes' ] + origCmdLine
1528- stripIncludes = True
1529+ createNewManifest = True
15291530 postProcessing = lambda compilerResult : postprocessNoManifestMiss (
1530- cache , objectFile , manifestSection , manifestHash , baseDir , sourceFile , compilerResult , stripIncludes )
1531+ cache , objectFile , manifestSection , manifestHash , sourceFile , compilerResult , stripIncludes )
1532+
1533+ if createNewManifest :
1534+ stripIncludes = False
1535+ if '/showIncludes' not in cmdLine :
1536+ cmdLine .insert (0 , '/showIncludes' )
1537+ stripIncludes = True
15311538
15321539 compilerResult = invokeRealCompiler (compiler , cmdLine , captureOutput = True )
15331540 if postProcessing :
0 commit comments