public DataHash DeriveHashKey(ICompiler comp, IEnumerable <string> args) { Logging.Emit("compiler is {0}", comp.CompilerExe); var comphash = DigestCompiler(comp.CompilerExe); if (comphash.Result == DataHashResult.Ok) { var srchash = hasher.DigestBinaryFile(comp.SingleSourceFile); if (srchash.Result == DataHashResult.Ok) { var buf = new StringBuilder(); buf.AppendLine(CacheInfo.CacheFormat); buf.AppendLine(srchash.Hash); buf.AppendLine(comp.WorkingDirectory); string incs = null; comp.EnvironmentVariables.TryGetValue("INCLUDE", out incs); if (incs != null) { buf.AppendLine(incs); } foreach (var a in args) { buf.AppendLine(a); } buf.AppendLine(comphash.Hash); comphash = hasher.DigestString(buf.ToString()); } } return(comphash); }
public DataHash DeriveHashKey(ICompiler comp, IEnumerable <string> args) { Logging.Emit("compiler is {0}", comp.CompilerExe); var tmp = DigestCompiler(comp.CompilerExe); var comphash = new DataHash() { InputName = tmp.InputName, Result = tmp.Result, Hash = tmp.Hash, }; if (comphash.Result == DataHashResult.Ok) { var buf = new StringWriter(); DataHash session; buf.WriteLine(CacheInfo.CacheFormat); // our compiler and folder buf.WriteLine(comphash.Hash); buf.WriteLine(comp.WorkingDirectory); buf.WriteLine(comp.SingleSourceFile); // important env vars foreach (var ename in new string[] { "INCLUDE", "LIB" }) { string ev = null; if (comp.EnvironmentVariables.TryGetValue(ename, out ev)) { if (!string.IsNullOrEmpty(ev)) { buf.WriteLine(ev); } } } // now all the command line options foreach (var a in args) { buf.WriteLine(a); } session = hasher.DigestString(buf.ToString()); comphash.SessionHash = session.Hash; comphash.Hash = comphash.SessionHash; } return(comphash); }