public void CompileFile(string file, PluginLib.ICompileHelper compileErrorPublisher, PluginLib.IErrorPublisher errorPublisher) { pushedError = false; this.compileErrorPublisher = compileErrorPublisher; this.errorPublisher = errorPublisher; try { string path = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location); path = Path.Combine(path, "bin"); path = Path.Combine(path, "ScriptCompiler.exe"); // Check for spaces in paths and quote any paths that need to be quoted if (file.Contains(' ')) { file = String.Format("\"{0}\"", file); } foreach (string s in compileErrorPublisher.GetIncludeDirs()) { file = String.Format(file + " {1}{0}{1}", s, s.Contains(' ') ? "\"" : ""); } Process pi = new Process(); pi.StartInfo.FileName = path; pi.StartInfo.Arguments = file; pi.EnableRaisingEvents = true; pi.StartInfo.WorkingDirectory = compileErrorPublisher.GetProjectDirectory(); pi.StartInfo.UseShellExecute = false; pi.StartInfo.CreateNoWindow = true; pi.ErrorDataReceived += pi_ErrorDataReceived; pi.OutputDataReceived += pi_OutputDataReceived; pi.StartInfo.RedirectStandardError = true; pi.StartInfo.RedirectStandardOutput = true; pi.Start(); pi.BeginOutputReadLine(); pi.BeginErrorReadLine(); pi.WaitForExit(); if (pushedError) { compileErrorPublisher.PushOutput(String.Format("Compiling {0} Failed\r\n", file)); } else { compileErrorPublisher.PushOutput(String.Format("Compiling {0} Complete\r\n", file)); UrhoDumpAPI.CreateDumps(compileErrorPublisher.GetProjectDirectory(), compileErrorPublisher.GetProjectSourceTree()); } } catch (Exception ex) { errorPublisher.PublishError(ex); } }
public void CompileFile(string file, PluginLib.ICompileHelper compileErrorPublisher, PluginLib.IErrorPublisher errorPublisher) { pushedError = false; this.compileErrorPublisher = compileErrorPublisher; this.errorPublisher = errorPublisher; try { string path = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location); path = Path.Combine(path, "bin"); path = Path.Combine(path, "ScriptCompiler.exe"); // Check for spaces in paths and quote any paths that need to be quoted if (file.Contains(' ')) file = String.Format("\"{0}\"", file); foreach (string s in compileErrorPublisher.GetIncludeDirs()) file = String.Format(file + " {1}{0}{1}", s, s.Contains(' ') ? "\"" : ""); Process pi = new Process(); pi.StartInfo.FileName = path; pi.StartInfo.Arguments = file; pi.EnableRaisingEvents = true; pi.StartInfo.WorkingDirectory = compileErrorPublisher.GetProjectDirectory(); pi.StartInfo.UseShellExecute = false; pi.StartInfo.CreateNoWindow = true; pi.ErrorDataReceived += pi_ErrorDataReceived; pi.OutputDataReceived += pi_OutputDataReceived; pi.StartInfo.RedirectStandardError = true; pi.StartInfo.RedirectStandardOutput = true; pi.Start(); pi.BeginOutputReadLine(); pi.BeginErrorReadLine(); pi.WaitForExit(); if (pushedError) compileErrorPublisher.PushOutput(String.Format("Compiling {0} Failed\r\n", file)); else { compileErrorPublisher.PushOutput(String.Format("Compiling {0} Complete\r\n", file)); UrhoDumpAPI.CreateDumps(compileErrorPublisher.GetProjectDirectory(),compileErrorPublisher.GetProjectSourceTree()); } } catch (Exception ex) { errorPublisher.PublishError(ex); } }
public void CompileFile(string file, PluginLib.ICompileHelper compileErrorPublisher, PluginLib.IErrorPublisher errorPublisher) { pushedError = false; this.compileErrorPublisher = compileErrorPublisher; this.errorPublisher = errorPublisher; errorsPushed = 0; try { string path = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location); path = Path.Combine(path, "bin"); path = Path.Combine(path, "ScriptCompiler.exe"); string parentDir = Path.GetDirectoryName(file); if (!Directory.Exists(parentDir)) return; List<string> compileList = new List<string>(); foreach (string f in Directory.EnumerateFiles(parentDir)) { if (!File.Exists(f) || !Path.GetExtension(f).Equals(".as")) continue; compileList.Add(f); } int ct = 0; foreach (string f in compileList) { // Quote spaces if necessary string cmdLine = f; if (cmdLine.Contains(' ')) cmdLine = String.Format("\"{0}\"", cmdLine); // Append include directories, quoting any space containing paths foreach (string s in compileErrorPublisher.GetIncludeDirs()) cmdLine = String.Format(file + " {1}{0}{1}", s, s.Contains(' ') ? "\"" : ""); ++ct; compileErrorPublisher.PushOutput("────────────────────────────────────────────────────\r\n"); compileErrorPublisher.PushOutput(String.Format("Compiling: {0}\r\n", f, ct)); compileErrorPublisher.PushOutput(String.Format("{0} of {1}\r\n", ct, compileList.Count)); Process pi = new Process(); pi.StartInfo.FileName = path; pi.StartInfo.Arguments = cmdLine; pi.EnableRaisingEvents = true; pi.StartInfo.UseShellExecute = false; pi.StartInfo.CreateNoWindow = true; pi.StartInfo.RedirectStandardOutput = true; pi.ErrorDataReceived += pi_ErrorDataReceived; pi.Start(); pi.WaitForExit(); string str = ""; pushedError = false; while ((str = pi.StandardOutput.ReadLine()) != null) { if (UrhoCompiler.ProcessLine(str, compileErrorPublisher, errorPublisher)) { pushedError = true; ++errorsPushed; } } if (pushedError) { compileErrorPublisher.PushOutput(String.Format("Compiling {0} Failed\r\n", f)); } else { compileErrorPublisher.PushOutput(String.Format("Compiling {0} Complete\r\n", f)); } } if (errorsPushed == 0) UrhoDumpAPI.CreateDumps(compileErrorPublisher.GetProjectDirectory(), compileErrorPublisher.GetProjectSourceTree()); } catch (Exception ex) { errorPublisher.PublishError(ex); } }
public static bool ProcessLine(string str, PluginLib.ICompileHelper compileErrorPublisher, PluginLib.IErrorPublisher errorPublisher) { if (str == null) { return(false); } compileErrorPublisher.PushOutput(str + "\r\n"); bool isError = false; bool isWarning = false; if (str.Contains("ERROR: ")) { str = str.Replace("ERROR: ", ""); isError = true; } if (str.Contains("WARNING: ")) { str = str.Replace("WARNING: ", ""); isWarning = true; } if (isError || isWarning) { string[] words = str.Split(' '); //split on spaces int colonIndex = words[0].LastIndexOf(':'); if (colonIndex == -1) { return(false); //don't count this as an error } string fileName = words[0].Substring(0, colonIndex); string part = ""; int line = -1; int column = -1; //move to first number ++colonIndex; for (; colonIndex < str.Length; ++colonIndex) { if (str[colonIndex] == ',') { if (line == -1) { line = int.Parse(part); } else { column = int.Parse(part); } } if (str[colonIndex] == ' ') { break; } part += str[colonIndex]; } string msg = String.Join(" ", words, 1, words.Length - 1); // str.Substring(colonIndex); PluginLib.CompileError error = new PluginLib.CompileError { File = fileName, Line = line, Message = msg, IsError = isError }; compileErrorPublisher.PublishError(error); return(isError); } return(false); }