Miss() public static method

public static Miss ( string hc, DataHashResult reason, string dir, string srcfile, string headerfile ) : void
hc string
reason DataHashResult
dir string
srcfile string
headerfile string
return void
示例#1
0
        /// <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);
        }
示例#2
0
        protected virtual void DoCacheMiss(ICompiler c, DataHash hc, IEnumerable <string> args, CClashRequest req, List <string> ifiles)
        {
            bool          good = true;
            CacheManifest m    = null;

            try
            {
                var idirs = c.GetUsedIncludeDirs(ifiles);
                if (idirs.Count < 1)
                {
                    throw new InvalidDataException(
                              string.Format("could not find any include folders?! [{0}]",
                                            string.Join(" ", args)));
                }
                #region process includes folders
                // save manifest and other things to cache
                var others = c.GetPotentialIncludeFiles(idirs, ifiles);
                m         = new CacheManifest();
                m.Request = req;
                m.PotentialNewIncludes = others;
                m.IncludeFiles         = new Dictionary <string, string>();
                m.TimeStamp            = DateTime.Now.ToString("s");
                m.SessionHash          = hc.SessionHash;

                #endregion

                var hashes = GetHashes(ifiles, c.WorkingDirectory);

                #region check include files

                foreach (var x in hashes)
                {
                    if (x.Value.Result == DataHashResult.Ok)
                    {
                        m.IncludeFiles[x.Key] = x.Value.Hash;
                    }
                    else
                    {
                        Logging.Emit("input hash error {0} {1}", x.Key, x.Value.Result);
                        Logging.Miss(hc.SessionHash, x.Value.Result, c.WorkingDirectory, c.SingleSourceFile, x.Key);
                        good      = false;
                        m.Disable = true;
                        break;
                    }
                }

                #endregion
            }
            finally
            {
                Unlock(CacheLockType.Read);
                if (good)
                {
                    Lock(CacheLockType.ReadWrite);
                    try
                    {
                        if (m != null)
                        {
                            SaveOutputsLocked(m, c);
                        }
                    }
                    finally
                    {
                        Unlock(CacheLockType.ReadWrite);
                    }
                }
            }
        }