Esempio n. 1
0
        internal static void LaunchVCC(string arguments)
        {
            var vccPath = VccPath;

            arguments += " ";
            arguments += VSIntegration.CurrentCompilerSettings.ToVccOptions();
            var clPath = GetCLPath(VSIntegration.CurrentPlatform);

            if (clPath != null)
            {
                arguments += String.Format(" /clpath:\"{0}\"", clPath);
            }

            VSIntegration.ClearErrorsAndMarkers();
            VSIntegration.UpdateStatus("Verifying...", true);

            //// Prepare VCC-Process, execute it and read its Output
            ProcessStartInfo psi = new ProcessStartInfo(string.Format("\"{0}\"", vccPath), arguments)
            {
                UseShellExecute        = false,
                RedirectStandardOutput = true,
                RedirectStandardError  = true,
                CreateNoWindow         = true
            };

            vccProcess = new Process {
                StartInfo = psi
            };

            //// Clear Verification Outputpane
            VSIntegration.ClearAndShowPane();
            VSIntegration.WriteToPane("=== VCC started. ===");
            //// Write Commandline-Command to Verification Outputpane
            VSIntegration.WriteToPane(string.Format("Command Line: \"{0}\" {1}\n", vccPath, arguments));
            //// Get notified when VCC sends Output or Error Data
            vccProcess.OutputDataReceived += vccProcess_OutputDataReceived;
            vccProcess.ErrorDataReceived  += vccProcess_OutputDataReceived;
            //// Get notified when VCC-Process finishes.
            vccProcess.EnableRaisingEvents = true;
            vccProcess.Exited += vccProcess_Exited;

            //// Finally start the process
            try
            {
                vccProcess.Start();
                vccProcess.BeginOutputReadLine();
                vccProcess.BeginErrorReadLine();
                //// When the process was started, remember the cmdlinearguments
                VSPackagePackage.LastAction = arguments;
            }
            catch (Exception)
            {
                vccProcess = null;
                VSIntegration.WriteToPane("Executing\n" + vccPath + "\nfailed.\n"
                                          + "You can specify the folder in which the VCC executable is located in Tools/Options/Vcc.");
                VSIntegration.WriteToPane("=== Verification failed. ===");
                VSIntegration.UpdateStatus("Verification failed.", false);
            }
        }
Esempio n. 2
0
        private static void vccProcess_Exited(object sender, EventArgs e)
        {
            if (vccProcess != null)
            {
                if (VSPackagePackage.Instance.OptionPage.ShowNotifications &&
                    new IntPtr(VSIntegration.DTE.MainWindow.HWnd) != GetForegroundWindow())
                {
                    if (vccProcess.ExitCode == 0)
                    {
                        notifyIcon.Value.ShowBalloonTip(4000, "Verification succeeded!", "Verification run completed successfully.", ToolTipIcon.Info);
                    }
                    else
                    {
                        notifyIcon.Value.ShowBalloonTip(4000, "Verification failed!", "Verification run completed with errors.", ToolTipIcon.Error);
                    }
                }

                switch (vccProcess.ExitCode)
                {
                case -1:
                    vccProcess.CancelOutputRead();
                    vccProcess.CancelErrorRead();
                    vccProcess = null;
                    VSIntegration.WriteToPane("\n=== VCC was canceled. ===");
                    VSIntegration.UpdateStatus("Verification canceled.", false);
                    break;

                case 0:
                    Thread.Sleep(1000);
                    VSIntegration.WriteToPane("\n=== Verification succeeded. ===");
                    VSIntegration.UpdateStatus("Verification succeeded.", false);
                    break;

                case 2:
                    Thread.Sleep(1000);
                    VSIntegration.WriteToPane("Incorrect commandline arguments were used.");
                    VSIntegration.WriteToPane("\n=== Verification failed. ===\n");
                    VSIntegration.UpdateStatus("Verification failed.", false);
                    break;

                case 1:
                case 3:
                    Thread.Sleep(1000);
                    VSIntegration.WriteToPane("\n=== Verification failed. ===");
                    VSIntegration.UpdateStatus("Verification failed.", false);
                    break;

                default:
                    Thread.Sleep(1000);
                    VSIntegration.WriteToPane("\n=== VCC finished with unknown exitcode. ===");
                    VSIntegration.WriteToPane(vccProcess.ExitCode.ToString());
                    break;
                }
            }
        }