public void PostCompile(string file, string sourceTree, PluginLib.IErrorPublisher errorPublisher) { try { string path = System.Reflection.Assembly.GetEntryAssembly().Location; path = Path.Combine(path, "bin"); path = Path.Combine(path, "ScriptCompiler.exe"); } 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; 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 void CompileFile(string file, PluginLib.ICompileErrorPublisher compileErrorPublisher, PluginLib.IErrorPublisher errorPublisher) { try { string path = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location); path = Path.Combine(path, "bin"); path = Path.Combine(path, "ScriptCompiler.exe"); Process pi = new Process(); pi.StartInfo.FileName = path; pi.StartInfo.Arguments = file; pi.EnableRaisingEvents = true; pi.StartInfo.UseShellExecute = false; pi.StartInfo.CreateNoWindow = true; pi.StartInfo.RedirectStandardOutput = true; pi.Start(); pi.WaitForExit(); string str = ""; while ((str = pi.StandardOutput.ReadLine()) != null) { compileErrorPublisher.PushOutput(str + "\r\n"); if (str.Contains("ERROR: ")) { str = str.Replace("ERROR: ", ""); } if (str.Contains(',')) { int firstColon = 0; bool colonFond = false; for (; firstColon < str.Length; ++firstColon) { if (str[firstColon] == ':' && colonFond) { break; } else if (str[firstColon] == ':') { colonFond = true; } } string fileName = str.Substring(0, firstColon); string part = ""; int line = -1; int column = -1; //move to first number ++firstColon; for (; firstColon < str.Length; ++firstColon) { if (str[firstColon] == ',') { if (line == -1) { line = int.Parse(part); } else { column = int.Parse(part); } } if (str[firstColon] == ' ') { break; } part += str[firstColon]; } string msg = str.Substring(firstColon); PluginLib.CompileError error = new PluginLib.CompileError { File = fileName, Line = line, Message = msg }; compileErrorPublisher.PublishError(error); } } } catch (Exception ex) { errorPublisher.PublishError(ex); } }