Beispiel #1
0
        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();
            }
        }
Beispiel #2
0
 public override void ErrorReceived(string s, bool force)
 {
     if (s != null && (force || TAPApp.Verbose > 0))
     {
         TAPApp.ELog(s);
     }
 }
Beispiel #3
0
        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);
            }
        }