public List <string> GetPotentialIncludeFiles(IEnumerable <string> incdirs, IEnumerable <string> incfiles) { List <string> possibles = new List <string>(); List <string> includelines = new List <string>(); var fullSrc = Path.GetFullPath(SingleSourceFile); foreach (var d in incdirs) { foreach (var f in (from x in incfiles where x.StartsWith(d, StringComparison.CurrentCultureIgnoreCase) select x)) { if (f != fullSrc) { var incpath = f.Substring(d.Length); includelines.Add(incpath.TrimStart('\\')); } } } HashSet <string> tmp = new HashSet <string>(includelines); foreach (var y in tmp) { foreach (var x in incdirs) { var p = Path.Combine(x, y); if (FileUtils.FileMissing(p)) { possibles.Add(p); } else { break; } } } return(possibles); }
public virtual bool FileMissing(string path) { return(FileUtils.FileMissing(path)); }
/// <summary> /// When this returns, we will hold the output cache mutex. /// </summary> /// <param name="commonkey"></param> /// <param name="manifest"></param> /// <returns></returns> public override bool CheckCache(ICompiler comp, IEnumerable <string> args, DataHash commonkey, out CacheManifest manifest) { manifest = null; Lock(CacheLockType.Read); manifest = GetCachedManifestLocked(commonkey); if (manifest != null) { #region build missed before if (manifest.Disable) { Logging.Emit("disabled by manifest"); return(false); } #region check includes foreach (var f in manifest.PotentialNewIncludes) { if (!FileUtils.FileMissing(f)) { Logging.Emit("detected added include file {0}", f); Logging.Miss(commonkey.SessionHash, DataHashResult.FileAdded, Directory.GetCurrentDirectory(), comp.SingleSourceFile, f); return(false); } } var files = new List <string>(); files.AddRange(manifest.IncludeFiles.Keys); var hashes = GetHashes(files, comp.WorkingDirectory); foreach (var h in hashes) { if (h.Value.Result == DataHashResult.Ok) { string mhash; if (manifest.IncludeFiles.TryGetValue(h.Key, out mhash)) { if (mhash != h.Value.Hash) { Logging.Emit("include file hash changed {0}", h.Key); Logging.Miss(commonkey.SessionHash, DataHashResult.FileChanged, Directory.GetCurrentDirectory(), comp.SingleSourceFile, h.Key); return(false); } } else { Logging.Emit("include file added {0}", h.Key); Logging.Miss(commonkey.SessionHash, DataHashResult.FileAdded, Directory.GetCurrentDirectory(), comp.SingleSourceFile, h.Key); return(false); } } else { Logging.Emit("include file hash error {0} {1}", h.Key, h.Value.Result); Logging.Miss(commonkey.SessionHash, h.Value.Result, Directory.GetCurrentDirectory(), comp.SingleSourceFile, h.Key); return(false); } } #endregion #region check pdb if (comp.AttemptPdb) { if (comp.PdbExistsAlready) { var pdbhash = hasher.DigestBinaryFile(comp.PdbFile); if (pdbhash.Hash != manifest.EarlierPdbHash) { outputCache.Remove(commonkey.Hash); Logging.Miss(commonkey.Hash, DataHashResult.FileChanged, commonkey.Hash, comp.PdbFile, ""); return(false); } } } #endregion #region check cached data exists foreach (var f in new string[] { F_Manifest, F_Object }) { if (!outputCache.ContainsEntry(commonkey.SessionHash, f)) { outputCache.Remove(commonkey.SessionHash); Logging.Miss(commonkey.SessionHash, DataHashResult.CacheCorrupt, commonkey.SessionHash, comp.SingleSourceFile, ""); return(false); } } #endregion if (Settings.MissLogEnabled) { Logging.Emit("hit hc={0},dir={1},src={2}", commonkey.Hash, comp.WorkingDirectory, comp.SingleSourceFile); } return(true); // cache hit, all includes match and no new files added #endregion } Logging.Miss(commonkey.Hash, DataHashResult.NoPreviousBuild, comp.WorkingDirectory, comp.SingleSourceFile, ""); return(false); }