private static ExecutionCommand CreateExecutionCommand(NMEProject project, NMEProjectConfiguration configuration) { string exe = "haxelib"; string args = "run nme run \"" + project.TargetNMMLFile + "\" " + configuration.Platform.ToLower(); if (configuration.DebugMode) { args += " -debug"; } if (project.AdditionalArguments != "") { args += " " + project.AdditionalArguments; } if (configuration.AdditionalArguments != "") { args += " " + configuration.AdditionalArguments; } NativeExecutionCommand cmd = new NativeExecutionCommand(exe); cmd.Arguments = args; cmd.WorkingDirectory = project.BaseDirectory.FullPath; return(cmd); }
public static string GetHXMLData(NMEProject project, NMEProjectConfiguration configuration) { ProcessStartInfo info = new ProcessStartInfo(); info.FileName = "haxelib"; info.Arguments = "run nme update \"" + project.TargetNMMLFile + "\" " + configuration.Platform.ToLower() + " " + project.AdditionalArguments + " " + configuration.AdditionalArguments; info.UseShellExecute = false; info.RedirectStandardOutput = true; info.RedirectStandardError = true; info.WorkingDirectory = project.BaseDirectory; //info.WindowStyle = ProcessWindowStyle.Hidden; info.CreateNoWindow = true; using (Process process = Process.Start(info)) { process.WaitForExit(); } info.Arguments = "run nme display \"" + project.TargetNMMLFile + "\" " + configuration.Platform.ToLower() + " " + project.AdditionalArguments + " " + configuration.AdditionalArguments; using (Process process = Process.Start(info)) { string data = process.StandardOutput.ReadToEnd(); process.WaitForExit(); return(data.Replace(Environment.NewLine, " ")); } }
public static bool CanRun(NMEProject project, NMEProjectConfiguration configuration, ExecutionContext context) { ExecutionCommand cmd = CreateExecutionCommand(project, configuration); if (cmd == null) { return(false); } return(context.ExecutionHandler.CanExecute(cmd)); }
public static BuildResult Compile(NMEProject project, NMEProjectConfiguration configuration, IProgressMonitor monitor) { string args = "run nme build \"" + project.TargetNMMLFile + "\" " + configuration.Platform.ToLower(); if (configuration.DebugMode) { args += " -debug"; } if (project.AdditionalArguments != "") { args += " " + project.AdditionalArguments; } if (configuration.AdditionalArguments != "") { args += " " + configuration.AdditionalArguments; } string error = ""; int exitCode = DoCompilation("haxelib", args, project.BaseDirectory, monitor, ref error); BuildResult result = ParseOutput(project, error); if (result.CompilerOutput.Trim().Length != 0) { monitor.Log.WriteLine(result.CompilerOutput); } if (result.ErrorCount == 0 && exitCode != 0) { string errorMessage = File.ReadAllText(error); if (!string.IsNullOrEmpty(errorMessage)) { result.AddError(errorMessage); } else { result.AddError("Build failed. Go to \"Build Output\" for more information"); } } FileService.DeleteFile(error); return(result); }
public static void Clean(NMEProject project, NMEProjectConfiguration configuration, IProgressMonitor monitor) { ProcessStartInfo info = new ProcessStartInfo(); info.FileName = "haxelib"; info.Arguments = "run nme clean \"" + project.TargetNMMLFile + "\" " + configuration.Platform.ToLower() + " " + project.AdditionalArguments + " " + configuration.AdditionalArguments; info.UseShellExecute = false; info.RedirectStandardOutput = true; info.RedirectStandardError = true; info.WorkingDirectory = project.BaseDirectory; //info.WindowStyle = ProcessWindowStyle.Hidden; info.CreateNoWindow = true; using (Process process = Process.Start(info)) { process.WaitForExit(); } }
public static void Run(NMEProject project, NMEProjectConfiguration configuration, IProgressMonitor monitor, ExecutionContext context) { ExecutionCommand cmd = CreateExecutionCommand(project, configuration); IConsole console; if (configuration.ExternalConsole) { console = context.ExternalConsoleFactory.CreateConsole(false); } else { console = context.ConsoleFactory.CreateConsole(false); } AggregatedOperationMonitor operationMonitor = new AggregatedOperationMonitor(monitor); try { if (!context.ExecutionHandler.CanExecute(cmd)) { monitor.ReportError(String.Format("Cannot execute '{0}'.", cmd.CommandString), null); return; } IProcessAsyncOperation operation = context.ExecutionHandler.Execute(cmd, console); operationMonitor.AddOperation(operation); operation.WaitForCompleted(); monitor.Log.WriteLine("Player exited with code {0}.", operation.ExitCode); } catch (Exception) { monitor.ReportError(String.Format("Error while executing '{0}'.", cmd.CommandString), null); } finally { operationMonitor.Dispose(); console.Dispose(); } }
public void Load (NMEProjectConfiguration configuration) { mConfiguration = configuration; AdditionalArgumentsEntry.Text = configuration.AdditionalArguments; }
public void Load(NMEProjectConfiguration configuration) { mConfiguration = configuration; AdditionalArgumentsEntry.Text = configuration.AdditionalArguments; }
public static string GetCompletionData(Project project, string classPath, string fileName, int position) { if (!PropertyService.HasValue("HaxeBinding.EnableCompilationServer")) { PropertyService.Set("HaxeBinding.EnableCompilationServer", true); PropertyService.Set("HaxeBinding.CompilationServerPort", 6000); PropertyService.SaveProperties(); } string exe = "haxe"; string args = ""; if (project is NMEProject) { NMEProjectConfiguration configuration = project.GetConfiguration(MonoDevelop.Ide.IdeApp.Workspace.ActiveConfiguration) as NMEProjectConfiguration; string platform = configuration.Platform.ToLower(); string path = ((NMEProject)project).TargetNMMLFile; if (!File.Exists(path)) { path = Path.Combine(project.BaseDirectory, path); } DateTime time = File.GetLastWriteTime(Path.GetFullPath(path)); if (!time.Equals(cacheNMMLTime) || platform != cachePlatform || configuration.AdditionalArguments != cacheArgumentsPlatform || ((NMEProject)project).AdditionalArguments != cacheArgumentsGlobal) { cacheHXML = NMECommandLineToolsManager.GetHXMLData((NMEProject)project, configuration); cacheNMMLTime = time; cachePlatform = platform; cacheArgumentsGlobal = ((NMEProject)project).AdditionalArguments; cacheArgumentsPlatform = configuration.AdditionalArguments; } args = cacheHXML + " -D code_completion"; } else if (project is HaxeProject) { HaxeProjectConfiguration configuration = project.GetConfiguration(MonoDevelop.Ide.IdeApp.Workspace.ActiveConfiguration) as HaxeProjectConfiguration; args = "\"" + ((HaxeProject)project).TargetHXMLFile + "\" " + ((HaxeProject)project).AdditionalArguments + " " + configuration.AdditionalArguments; } else { return(""); } args += " -cp \"" + classPath + "\" --display \"" + fileName + "\"@" + position + " -D use_rtti_doc"; if (PropertyService.Get <bool> ("HaxeBinding.EnableCompilationServer")) { var port = PropertyService.Get <int> ("HaxeBinding.CompilationServerPort"); if (compilationServer == null || compilationServer.HasExited || port != compilationServerPort) { StartServer(); } try { if (!compilationServer.HasExited) { var client = new TcpClient("127.0.0.1", port); var writer = new StreamWriter(client.GetStream()); writer.WriteLine("--cwd " + project.BaseDirectory); // Instead of replacing spaces with newlines, replace only // if the space is followed by a dash. // TODO: Even more intelligent replacement so you can use folders // that contain the string sequence " -". writer.Write(args.Replace(" -", "\n-")); //writer.WriteLine("--connect " + port); writer.Write("\0"); writer.Flush(); var reader = new StreamReader(client.GetStream()); var lines = reader.ReadToEnd().Split('\n'); client.Close(); return(String.Join("\n", lines)); } } catch (Exception) { //MonoDevelop.Ide.MessageService.ShowError (ex.ToString ()); //TraceManager.AddAsync(ex.Message); //if (!failure && FallbackNeeded != null) // FallbackNeeded(false); //failure = true; //return ""; } } //MonoDevelop.Ide.MessageService.ShowError ("Falling back to standard completion"); Process process = new Process(); process.StartInfo.FileName = exe; process.StartInfo.Arguments = args; process.StartInfo.UseShellExecute = false; process.StartInfo.CreateNoWindow = true; process.StartInfo.RedirectStandardError = true; process.StartInfo.WorkingDirectory = project.BaseDirectory; process.Start(); string result = process.StandardError.ReadToEnd(); process.WaitForExit(); return(result); }