Exemplo n.º 1
0
        // Returns the active configuration.
        public OptionsElement GetActiveConfiguration()
        {
            string activeConfiguration = ProjectUtility.GetActiveConfiguration(project);
            string activePlatform      = ProjectUtility.GetActivePlatform(project);

            return(GetNewConfiguration(activeConfiguration, activePlatform));
        }
Exemplo n.º 2
0
        /*=== construction ===*/

        public ProjectOptionsForm()
        {
            InitializeComponent();

            /*=== Grab the current project. ===*/

            List <Project> projects = ProjectUtility.GetActiveProjectOnly();
            Project        project  = projects[0];

            this.Text = project.Name + " : " + this.Text;

            /*=== Populate the combo boxes. ===*/

            List <string> configurations = ProjectUtility.GetConfigurations(project);
            List <string> platforms      = ProjectUtility.GetPlatforms(project);

            foreach (string s in configurations)
            {
                comboConfigurations.Items.Add(s);
            }

            foreach (string s in platforms)
            {
                comboPlatforms.Items.Add(s);
            }

            comboConfigurations.SelectedItem = ProjectUtility.GetActiveConfiguration(project);
            comboPlatforms.SelectedItem      = ProjectUtility.GetActivePlatform(project);

            /*=== Setup the property grid. ===*/

            this.propertyGrid.Initialize(project);
            this.propertyGrid.RefreshGrid((string)comboConfigurations.SelectedItem, (string)comboPlatforms.SelectedItem);
        }
Exemplo n.º 3
0
        /*=== overrides ===*/

        // Reload this project's options file.
        public override void Load()
        {
            if (project == null)
            {
                return;
            }

            string            file = Paths.GetProjectOptionsFilename(project);
            ProjectOptionsSet os   = null;

            // Load the project options.
            XmlUtility.LoadXml(file, ref os);

            if (os == null)
            {
                this.Options = new List <OptionsElement>();
            }
            else
            {
                this.Options = os.Options;
            }

            string activeConfiguration = ProjectUtility.GetActiveConfiguration(project);
            string activePlatform      = ProjectUtility.GetActivePlatform(project);

            if (GetConfiguration(activeConfiguration, activePlatform) == null)
            {
                OptionsElement oe = new OptionsElement();

                oe.Configuration = activeConfiguration;
                oe.Platform      = activePlatform;
                oe.Options.SetDefaults();

                AddConfiguration(oe);

                // Save the new project options.
                Save();
            }
        }
Exemplo n.º 4
0
        // Resolves a path with visual studio macros in it.
        public static string ResolveVisualStudioMacros(Project project, string path)
        {
            // Replace $(PlatformName) with the platform name.
            path = path.Replace("$(PlatformName)", ProjectUtility.GetActivePlatform(project));

            // Replace $(ConfigurationName) with the configuration name.
            path = path.Replace("$(ConfigurationName)", ProjectUtility.GetActiveConfiguration(project));

            // Replace $(ProjectName) with the project name.
            path = path.Replace("$(ProjectName)", ProjectUtility.GetProjectName(project));

            // Replace $(SolutionName) with the solution name.
            path = path.Replace("$(SolutionName)", ProjectUtility.GetSolutionName());

            // Replace $(ProjectDir) with the project directory.
            path = path.Replace("$(ProjectDir)", ProjectUtility.GetFullProjectPath(project));

            // Replace $(SolutionDir) with the solution directory.
            path = path.Replace("$(SolutionDir)", ProjectUtility.GetFullSolutionPath());

            //if we still have $() it should error really!

            return(path);
        }
Exemplo n.º 5
0
        /*=== utility ===*/

        public override void Running()
        {
            bool bErrored = false;

            foreach (opCpp2005.CommandSetting command in Commands)
            {
                try
                {
                    Options options = OptionsManager.GetGlobalOptions().GetGlobalConfiguration().Options;

                    // Print out the project that's currently compiling.
                    if (!command.Arguments.Contains("-clean"))
                    {
                        string configuration = ProjectUtility.GetActiveConfiguration(command.Project);
                        string platform      = ProjectUtility.GetActivePlatform(command.Project);
                        string message       = "------ opC++ Build started: Project: " + command.Project.Name + ", Configuration: " + configuration + " " + platform + " ------";

                        OnReadLine(message);
                    }

                    if (options.OutputCommandline.Value)                    //TODO: hook into global options
                    {
                        string argstring = command.Arguments.Replace("-beta", "");

                        OnReadLine("---------------------------------------------");
                        OnReadLine("Working Directory = " + command.WorkingDir);
                        OnReadLine("Path = " + command.ExePath);
                        OnReadLine("Arguments = " + argstring);
                        OnReadLine("::::::::::::::::::::::::::::::::::::::::::::;");
                    }

                    //create a new process
                    process = new System.Diagnostics.Process();

                    process.StartInfo.WorkingDirectory = command.WorkingDir;

                    //this path is from the registry
                    //NOTE: this should be integrated with the installer
                    process.StartInfo.FileName  = command.ExePath;
                    process.StartInfo.Arguments = command.Arguments;
                    process.StartInfo.RedirectStandardOutput = true;
                    process.StartInfo.UseShellExecute        = false;
                    process.StartInfo.CreateNoWindow         = true;
                    process.StartInfo.ErrorDialog            = false;
                    //process.EnableRaisingEvents = true;

                    //process.
                    process.OutputDataReceived += new DataReceivedEventHandler(a_OutputDataReceived);

                    process.Start();

                    //begin async output reading
                    process.BeginOutputReadLine();

//                  while(!process.HasExited)
//                  {
//                      string value;
//                      while( (value = process.StandardOutput.ReadLine()) != null )
//                          OnReadLine(value);
//                  }

                    //while (!process.HasExited) ;

                    //wait only 10 seconds (temporary?)
                    process.WaitForExit(1000 * 10);

                    //the second call makes sure the async output is all finished before proceeding.
                    process.WaitForExit();

                    if (process.HasExited)
                    {
                        //success
                    }
                    else
                    {
                        bErrored = true;

                        //check status...this should be temporary!
                        OnReadLine("Error: opC++ may not have finished in 10 seconds.");
                        break;
                    }

                    if (process.ExitCode != 0)
                    {
                        bErrored = true;
                        break;
                    }
                }
                catch (Exception e)
                {
                    OnReadLine("exception: " + e.Message + "\nStack Trace: " + e.StackTrace);
                    bErrored = true;
                    break;
                }
            }

            OnEnd(bErrored);
        }