public void Runner(object o) { ScriptPath path = (ScriptPath)o; if (!Single) { ForwardOutput("# " + path.ToString(), false, true, Client.OutputReceived); } try { int exit = 1; string exe = Compile(path, Client.TapWasUpdated); if (exe != null) { exit = Run(exe); } TAPApp.VLog(2, "Exit code from {0}: {1}", path, exit); } catch (Exception e) { TAPApp.ELog("Exception running {0}: {1}", path, e.ToString()); } finally { TAPApp.DLog(3, "{0} done.", path); TAPParser.End(); Running = false; Done.Set(); } }
string Compile(ScriptPath spath, bool tapwasupdated) { string path = spath.Path; if (!File.Exists(path)) { throw new FileNotFoundException("source file not found", path); } string outpath = TapFromSource(spath); string pdbpath = PdbFromTap(outpath); string[] sa = GetSubjectAssemblies(); // this includes tap.exe copied with CopyMe TAPApp.VLog(3, "subject assemblies:" + string.Join(",", sa.ToArray())); if (!tapwasupdated && !TAPApp.IsOutdated(outpath, path) && !TAPApp.IsOutdated(pdbpath, path) && !IsOutdated(outpath, sa)) { TAPApp.VLog(2, outpath + " is up to date"); return(outpath); } TAPApp.VLog(3, "building {0}", outpath); using (CodeDomProvider prov = new CSharpCodeProvider(new Dictionary <string, string> { { "CompilerVersion", "v3.5" } })) { // maybe make configurable in a <system.codedom><compilers>... var cp = new CompilerParameters(); cp.GenerateExecutable = true; cp.IncludeDebugInformation = true; cp.OutputAssembly = outpath; //cp.CompilerOptions+=String.Concat("/d:DEBUG /lib:\"",GetMyImagePath(),"\""); #if __MonoCS__ cp.CompilerOptions += "/d:DEBUG /nowarn:169"; #else cp.CompilerOptions += string.Concat("/d:DEBUG /pdb:", pdbpath); #endif cp.ReferencedAssemblies.Add("System.dll"); cp.ReferencedAssemblies.Add("System.Core.dll"); cp.ReferencedAssemblies.AddRange(sa); cp.ReferencedAssemblies.AddRange(TAPApp.Refs.ToArray()); CompilerResults cr = prov.CompileAssemblyFromFile(cp, new [] { path }); bool errors = cr.Errors.Count > 0; if (errors) { TAPApp.ELog("Errors building"); } if (errors || TAPApp.Verbose > 1) { foreach (string i in cr.Output) { TAPApp.Log(i); } } if (!errors) { return(cr.PathToAssembly); } return(null); } }
static bool IsOutdated(string obj, string[] src) { string first = src.FirstOrDefault(x => TAPApp.IsOutdated(obj, x)); if (first != null) { TAPApp.VLog(2, "{0} is newer than {1}", first, obj); return(true); } return(false); }
bool CopyMe(string targetpath) { string me = GetMyImagePath(); string to = Path.Combine(targetpath, Path.GetFileName(me)); if (TAPApp.IsOutdated(to, me)) { TAPApp.VLog(2, "copy from {0} to {1}", me, to); File.Copy(me, to, true); // this can be removed once all the bugs are fixed :-) string pdb = TAPApp.PdbFromExe(me); string pdbto = TAPApp.PdbFromExe(to); File.Copy(pdb, pdbto, true); return(true); } return(false); }
public void Run(ScriptPath[] srcs) { int maxtasks = TAPApp.MaxTasks; TAPApp.VLog(3, "Max. {0} {1}.", maxtasks, maxtasks == 1?"task":"parallel tasks"); int k = 0; bool single = srcs.Length == 1; do { bool waiting = k != srcs.Length; int running = CountRunningTasks(); if (!waiting && running == 0) { TAPParser.EndTotal(); } ReapHead(); if (waiting) { running = CountRunningTasks(); while (running < maxtasks) { if (k != srcs.Length) { AddTask(srcs[k], single); ++k; ++running; } else { break; } } } if (Tasks.Count == 0) { break; } TaskDone.WaitOne(); } while(true); TAPApp.DLog(3, "TaskMgr done."); }
public void TaskComplete() { TAPApp.VLog(3, "TaskComplete"); TAPParser.UpdateTotals(); TAPParser.ShowSubtotals(); }