Пример #1
0
        protected override Task OnExecute(ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
        {
            return(Task.Factory.StartNew(async() => {
                ExternalConsole console = context.ExternalConsoleFactory.CreateConsole(false, monitor.CancellationToken);
                string targetName = "";
                foreach (var target in fileFormat.Targets.Values)
                {
                    if (target.Type == CMakeTarget.Types.Binary)
                    {
                        targetName = target.Name;
                        break;
                    }
                }

                if (string.IsNullOrEmpty(targetName))
                {
                    monitor.ReportError("Can't find an executable target.");
                    return;
                }

                FilePath f = BaseDirectory.Combine(outputDirectory);
                NativeExecutionCommand cmd;
                if (File.Exists(f.Combine(targetName)))
                {
                    cmd = new NativeExecutionCommand(f.Combine(targetName));
                }
                else if (File.Exists(f.Combine(string.Format("{0}.{1}", targetName, "exe"))))
                {
                    cmd = new NativeExecutionCommand(f.Combine(string.Format("{0}.{1}", targetName, "exe")));
                }
                else if (File.Exists(f.Combine("./Debug", targetName)))
                {
                    cmd = new NativeExecutionCommand(f.Combine("./Debug", targetName));
                }
                else if (File.Exists(f.Combine("./Debug", string.Format("{0}.{1}", targetName, "exe"))))
                {
                    cmd = new NativeExecutionCommand(f.Combine("./Debug", string.Format("{0}.{1}", targetName, "exe")));
                }
                else
                {
                    monitor.ReportError("Can't determine executable path.");
                    return;
                }

                try {
                    var handler = Runtime.ProcessService.GetDefaultExecutionHandler(cmd);
                    var op = handler.Execute(cmd, console);

                    using (var t = monitor.CancellationToken.Register(op.Cancel))
                        await op.Task;

                    monitor.Log.WriteLine("The operation exited with code: {0}", op.ExitCode);
                } catch (Exception ex) {
                    monitor.ReportError("Can't execute the target.", ex);
                } finally {
                    console.Dispose();
                }
            }));
        }
Пример #2
0
 private static void OnProcessExit(object sender, EventArgs e)
 {
     Logger.Log("Exiting...");
     Logger.Trace(config.ToJson());
     Config.Save(config);
     ExternalConsole.Dispose();
     Application.Exit();
     System.Diagnostics.Process.GetCurrentProcess().Kill();
 }
Пример #3
0
 static void OnProcessExit(object sender, EventArgs e)
 {
     Logger.Log("Exiting...");
     // LogReader.Dispose();
     // IPC.Launcher.Dispose();
     ExternalConsole.Dispose();
     Application.Exit();
     Process.GetCurrentProcess().Kill();
 }