public Task(AutoResetEvent done,TaskMgrClient client,ScriptPath path,bool single) { Done=done; Client=client; ScriptPath=path; Single=single; }
public Task(AutoResetEvent done, TaskMgrClient client, ScriptPath path, bool single) { Done = done; Client = client; ScriptPath = path; Single = single; }
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(); } }
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."); }
void AddTask(ScriptPath sp,bool single) { TAPApp.DLog(3,"Add task {0}",sp); var task=new Task(TaskDone,Client,sp,single); if(Tasks.Count==0) task.Head=true; task.Run(); Tasks.Enqueue(task); }
static string TapFromSource(ScriptPath s) { string rel = s.GetRelativePart(); rel = rel.Replace(Path.DirectorySeparatorChar, '_'); return(Path.Combine(TAPApp.Subject, ExtEx.Replace(rel, m => string.Concat("taps.", m.Groups[1].Value.Replace(".", "")), 1))); }
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); } }
void AddTask(ScriptPath sp, bool single) { TAPApp.DLog(3, "Add task {0}", sp); var task = new Task(TaskDone, Client, sp, single); if (Tasks.Count == 0) { task.Head = true; } task.Run(); Tasks.Enqueue(task); }
static string TapFromSource(ScriptPath s) { string rel=s.GetRelativePart(); rel=rel.Replace(Path.DirectorySeparatorChar,'_'); return Path.Combine(TAPApp.Subject,ExtEx.Replace(rel,m=> string.Concat("taps.",m.Groups[1].Value.Replace(".","")),1)); }
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; } }