/*=== 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); }
void StartCompile(CompileMode mode) { // a compile is running already if (IsCompiling()) { //TODO: should halt compiling really return; //CurrentThread.Stop(); } if (mode.bIntercepted) { Options options = OptionsManager.GetGlobalOptions().GetGlobalConfiguration().Options; bool bExtendCommands = options.ExtendCommands.Value; if (!bExtendCommands) { return; } } if (IsVSCompiling()) { //cancel it App().ExecuteCommand("Build.Cancel", ""); } // activate the output pane... GetOutputPane().Clear(); ActivateOutputPane(); // ok, lets attempt to start compiling now. CurrentThread = null; PostEvent = ""; // no solution loaded DTE2 app = App(); Solution solution = app.Solution; if (solution == null) { return; } // first save all the open files - this is a global setting SaveOpenFiles(); List <Project> Projects; // find the selections we need (projects) if (mode.Selection == SelectionTypes.Solution) { Projects = ProjectUtility.GetSolutionProjects(); } else if (mode.Selection == SelectionTypes.Project) { Projects = ProjectUtility.GetActiveProjects(); } else // if (mode.Selection == SelectionTypes.ProjectOnly) { Projects = ProjectUtility.GetActiveProjectOnly(); } // // Mode Arguments // // clean : send it -clean // rebuild : send it -force // build : none... string ModeArguments = ""; if (mode.Action == CompileTypes.Rebuild) { ModeArguments += "-force"; } else if (mode.Action == CompileTypes.Clean) { ModeArguments += "-clean"; } //else if Debug || NoDebug || Build ... no additional needed //TODO: need the global options path string GlobalArguments = "-dependencies \"" + Paths.GetGlobalOptionsFilename() + "\""; //no projects to compile if (Projects.Count == 0) { return; } List <CommandSetting> CommandSettings = new List <CommandSetting>(); int numprojects = Projects.Count; for (int ip = 0; ip < numprojects; ip++) { Project project = Projects[ip]; string ActiveConfiguration = ProjectUtility.ProjectActiveConfiguration(project); List <VCFile> ohfiles = ProjectUtility.GetOhFiles(project); // does it contain active oh files? if not skip it. ProjectUtility.FilterActiveFiles(ref ohfiles, ActiveConfiguration); if (ohfiles.Count == 0) { continue; } // are the project settings set to enable opcpp? bool bProjectEnabled = true; if (!bProjectEnabled) { continue; } //3. do we have .doh files in the project? List <VCFile> dohfiles = ProjectUtility.GetDohFiles(project); ProjectUtility.FilterActiveFiles(ref dohfiles, ActiveConfiguration); // if (dohfiles.Count == 0) // continue; //fetch the project doh files from the global/project doh settings List <string> ProjectDohFiles = new List <string>(); // if(ProjectDohFiles.Count + dohfiles.Count == 0) // { // //print a message "Project has oh files but no dialect was found or specified" // continue; // } //now build the settings CommandSetting setting = new CommandSetting(); setting.Project = project; setting.WorkingDir = StringUtility.RLeft(project.FileName, "\\"); //build the oh files list from the arguments //build the doh files list from the arguments string ohfilestring = ""; for (int i = 0; i < ohfiles.Count; i++) { VCFile file = ohfiles[i]; ohfilestring += '"'; ohfilestring += file.FullPath; ohfilestring += '"'; if (i + 1 < ohfiles.Count) { ohfilestring += ','; } } string dohfilestring = ""; for (int i = 0; i < dohfiles.Count; i++) { VCFile file = dohfiles[i]; dohfilestring += '"'; dohfilestring += file.FullPath; dohfilestring += '"'; if (i + 1 < dohfiles.Count) { dohfilestring += ','; } } for (int i = 0; i < ProjectDohFiles.Count; i++) { dohfilestring += '"'; dohfilestring += ProjectDohFiles[i]; dohfilestring += '"'; if (i + 1 < ProjectDohFiles.Count) { dohfilestring += ','; } } string FileArguments = ""; if (ohfilestring.Length > 0) { FileArguments += " -oh " + ohfilestring; } if (dohfilestring.Length > 0) { FileArguments += " -doh " + dohfilestring; } // fetch the global + overloaded project arguments CommandLineInfo info = OptionsManager.GetCommandLineInfo(project); setting.ExePath = info.ExecutablePath; FileArguments += " -dependencies \"" + Paths.GetProjectOptionsFilename(project) + "\""; if (setting.ExePath == "") { LogCompile("Error: opCpp exe path is undefined, please define in global and/or project settings"); return; } string ProjectArguments = info.Arguments; string MacroArguments = FileArguments + " " + ProjectArguments + " " + ModeArguments + " " + GlobalArguments; if (opBeta.IsBeta) { MacroArguments += " -beta"; } setting.Arguments = Paths.ResolveVisualStudioMacros(project, MacroArguments); //verify the macros worked... Regex findmacros = new Regex("$\\(*.\\)"); Match result = findmacros.Match(setting.Arguments); if (result.Success) { string foundstring = setting.Arguments.Substring(result.Index, result.Length); LogCompile("Error: bad macro found in settings - " + foundstring); return; } CommandSettings.Add(setting); } //no commands to execute if (CommandSettings.Count == 0) { // CurrentMode = null; // FinishedCompile(false); return; } //execute commands CurrentMode = mode; CurrentThread = new opCppThread(CommandSettings); CurrentThread.OnReadLine = LogCompile; CurrentThread.OnEnd = FinishedCompile; CurrentThread.Start(); }