void CompilerMainPage::LoadCompilers() { // Populate the compilers list m_listBoxCompilers->Clear(); wxString cmpType; if(clCxxWorkspaceST::Get()->IsOpen() && clCxxWorkspaceST::Get()->GetActiveProject()) { BuildConfigPtr bldConf = clCxxWorkspaceST::Get()->GetActiveProject()->GetBuildConfiguration(); if(bldConf) { cmpType = bldConf->GetCompilerType(); } } BuildSettingsConfigCookie cookie; CompilerPtr cmp = BuildSettingsConfigST::Get()->GetFirstCompiler(cookie); int sel(0); while(cmp) { int curidx = m_listBoxCompilers->Append(cmp->GetName()); if(!cmpType.IsEmpty() && (cmp->GetName() == cmpType)) { sel = curidx; } cmp = BuildSettingsConfigST::Get()->GetNextCompiler(cookie); } if(!m_listBoxCompilers->IsEmpty()) { m_listBoxCompilers->SetSelection(sel); LoadCompiler(m_listBoxCompilers->GetStringSelection()); } }
void NewBuildTab::DoUpdateCurrentCompiler(const wxString& line) { wxString projectName, configuration; if ( line.Contains ( wxGetTranslation(BUILD_PROJECT_PREFIX) ) ) { // now building the next project wxString prj = line.AfterFirst ( wxT ( '[' ) ).BeforeFirst ( wxT ( ']' ) ); projectName = prj.BeforeFirst ( wxT ( '-' ) ).Trim ( false ).Trim(); configuration = prj.AfterFirst ( wxT ( '-' ) ).Trim ( false ).Trim(); m_cmp.Reset ( NULL ); // need to know the compiler in use for this project to extract // file/line and error/warning status from the text BuildConfigPtr bldConf = WorkspaceST::Get()->GetProjBuildConf(projectName, configuration); if ( bldConf ) { m_cmp = BuildSettingsConfigST::Get()->GetCompiler ( bldConf->GetCompilerType() ); } else { // probably custom build with project names incorret // assign the default compiler for this purpose if ( BuildSettingsConfigST::Get()->IsCompilerExist(wxT("gnu g++")) ) { m_cmp = BuildSettingsConfigST::Get()->GetCompiler( wxT("gnu g++") ); } } } if( !m_cmp ) { if ( BuildSettingsConfigST::Get()->IsCompilerExist(wxT("gnu g++")) ) { m_cmp = BuildSettingsConfigST::Get()->GetCompiler( wxT("gnu g++") ); } } }
void NewProjectWizard::UpdateProjectPage() { // update the description if(m_projectData.m_srcProject) { wxString desc = m_projectData.m_srcProject->GetDescription(); desc = desc.Trim().Trim(false); desc.Replace(wxT("\t"), wxT(" ")); // select the correct compiler ProjectSettingsPtr settings = m_projectData.m_srcProject->GetSettings(); if(settings) { ProjectSettingsCookie ck; BuildConfigPtr buildConf = settings->GetFirstBuildConfiguration(ck); if(buildConf) { m_choiceCompiler->SetStringSelection(buildConf->GetCompilerType()); m_choiceDebugger->SetStringSelection(buildConf->GetDebuggerType()); } } } // Restore previous selections wxString lastCompiler = clConfig::Get().Read("CxxWizard/Compiler", wxString()); wxString lastDebugger = clConfig::Get().Read("CxxWizard/Debugger", wxString()); wxString lastBuilder = clConfig::Get().Read("CxxWizard/BuildSystem", wxString("Default")); if(!lastDebugger.IsEmpty()) { int where = m_choiceDebugger->FindString(lastDebugger); if(where != wxNOT_FOUND) { m_choiceDebugger->SetSelection(where); } } if(!lastCompiler.IsEmpty()) { int where = m_choiceCompiler->FindString(lastCompiler); if(where != wxNOT_FOUND) { m_choiceCompiler->SetSelection(where); } } { int where = m_choiceBuildSystem->FindString(lastBuilder); if(where != wxNOT_FOUND) { m_choiceBuildSystem->SetSelection(where); } } }
void PSGeneralPage::Load(BuildConfigPtr buildConf) { Clear(); m_configName = buildConf->GetName(); m_checkBoxEnabled->SetValue( buildConf->IsProjectEnabled() ); m_pgPropArgs->SetValue( buildConf->GetCommandArguments() ); m_pgPropDebugArgs->SetValueFromString( buildConf->GetDebugArgs() ); m_pgPropIntermediateFolder->SetValueFromString( buildConf->GetIntermediateDirectory() ); m_pgPropGUIApp->SetValue( buildConf->IsGUIProgram() ); m_pgPropOutputFile->SetValueFromString( buildConf->GetOutputFileName() ); m_pgPropPause->SetValue( buildConf->GetPauseWhenExecEnds() ); m_pgPropProgram->SetValueFromString( buildConf->GetCommand() ); m_pgPropWorkingDirectory->SetValue( buildConf->GetWorkingDirectory() ); // Project type wxPGChoices choices; choices.Add(Project::STATIC_LIBRARY); choices.Add(Project::DYNAMIC_LIBRARY); choices.Add(Project::EXECUTABLE); m_pgPropProjectType->SetChoices( choices ); m_pgPropProjectType->SetChoiceSelection( choices.Index(buildConf->GetProjectType() ) ); // Compilers choices.Clear(); wxString cmpType = buildConf->GetCompilerType(); BuildSettingsConfigCookie cookie; CompilerPtr cmp = BuildSettingsConfigST::Get()->GetFirstCompiler(cookie); while (cmp) { choices.Add(cmp->GetName()); cmp = BuildSettingsConfigST::Get()->GetNextCompiler(cookie); } m_pgPropCompiler->SetChoices( choices ); m_pgPropCompiler->SetChoiceSelection( choices.Index( buildConf->GetCompiler()->GetName() ) ); // Debuggers choices.Clear(); wxString dbgType = buildConf->GetDebuggerType(); wxArrayString dbgs = DebuggerMgr::Get().GetAvailableDebuggers(); choices.Add(dbgs); m_pgPropDebugger->SetChoices( choices ); m_pgPropDebugger->SetChoiceSelection( choices.Index(buildConf->GetDebuggerType()) ); m_pgPropUseSeparateDebuggerArgs->SetValue( buildConf->GetUseSeparateDebugArgs() ); m_dlg->SetIsProjectEnabled( buildConf->IsProjectEnabled() ); }
void NewProjectWizard::UpdateProjectPage() { //update the description if ( m_projectData.m_srcProject ) { wxString desc = m_projectData.m_srcProject->GetDescription(); desc = desc.Trim().Trim(false); desc.Replace(wxT("\t"), wxT(" ")); // m_txtDescription->SetValue( desc ); // select the correct compiler ProjectSettingsPtr settings = m_projectData.m_srcProject->GetSettings(); if (settings) { ProjectSettingsCookie ck; BuildConfigPtr buildConf = settings->GetFirstBuildConfiguration(ck); if (buildConf) { m_choiceCompiler->SetStringSelection( buildConf->GetCompilerType() ); m_choiceCompiler->SetStringSelection( buildConf->GetDebuggerType() ); } } } }
// do the actual cleanup void CompileRequest::Process(IManager* manager) { wxString cmd; wxString errMsg; wxStringMap_t om; BuildSettingsConfig* bsc(manager ? manager->GetBuildSettingsConfigManager() : BuildSettingsConfigST::Get()); BuildManager* bm(manager ? manager->GetBuildManager() : BuildManagerST::Get()); clCxxWorkspace* w(manager ? manager->GetWorkspace() : clCxxWorkspaceST::Get()); EnvironmentConfig* env(manager ? manager->GetEnv() : EnvironmentConfig::Instance()); ProjectPtr proj = w->FindProjectByName(m_info.GetProject(), errMsg); if(!proj) { AppendLine(_("Cant find project: ") + m_info.GetProject()); return; } wxString pname(proj->GetName()); // BuilderPtr builder = bm->GetBuilder(wxT("GNU makefile for g++/gcc")); BuilderPtr builder = bm->GetSelectedBuilder(); if(m_fileName.IsEmpty() == false) { // we got a complie request of a single file cmd = m_preprocessOnly ? builder->GetPreprocessFileCmd(m_info.GetProject(), m_info.GetConfiguration(), m_fileName, errMsg) : builder->GetSingleFileCmd(m_info.GetProject(), m_info.GetConfiguration(), m_fileName); } else if(m_info.GetProjectOnly()) { switch(m_info.GetKind()) { case QueueCommand::kRebuild: cmd = builder->GetPORebuildCommand(m_info.GetProject(), m_info.GetConfiguration()); break; default: case QueueCommand::kBuild: cmd = builder->GetPOBuildCommand(m_info.GetProject(), m_info.GetConfiguration()); break; } } else { cmd = builder->GetBuildCommand(m_info.GetProject(), m_info.GetConfiguration()); } // Notify plugins that a compile process is going to start clBuildEvent event(wxEVT_BUILD_STARTING); event.SetProjectName(pname); event.SetConfigurationName(m_info.GetConfiguration()); if(EventNotifier::Get()->ProcessEvent(event)) { // the build is being handled by some plugin, no need to build it // using the standard way return; } // Send the EVENT_STARTED : even if this event is sent, next event will // be post, so no way to be sure the the build process has not started SendStartMsg(); // if we require to run the makefile generation command only, replace the 'cmd' with the // generation command line BuildConfigPtr bldConf = w->GetProjBuildConf(m_info.GetProject(), m_info.GetConfiguration()); if(m_premakeOnly && bldConf) { BuildConfigPtr bldConf = w->GetProjBuildConf(m_info.GetProject(), m_info.GetConfiguration()); if(bldConf) { cmd = bldConf->GetMakeGenerationCommand(); } } if(bldConf) { wxString cmpType = bldConf->GetCompilerType(); CompilerPtr cmp = bsc->GetCompiler(cmpType); if(cmp) { // Add the 'bin' folder of the compiler to the PATH environment variable wxString scxx = cmp->GetTool("CXX"); scxx.Trim().Trim(false); scxx.StartsWith("\"", &scxx); scxx.EndsWith("\"", &scxx); // Strip the double quotes wxFileName cxx(scxx); wxString pathvar; pathvar << cxx.GetPath() << clPATH_SEPARATOR; // If we have an additional path, add it as well if(!cmp->GetPathVariable().IsEmpty()) { pathvar << cmp->GetPathVariable() << clPATH_SEPARATOR; } pathvar << "$PATH"; om["PATH"] = pathvar; } } if(cmd.IsEmpty()) { // if we got an error string, use it if(errMsg.IsEmpty() == false) { AppendLine(errMsg); } else { AppendLine(_("Command line is empty. Build aborted.")); } return; } WrapInShell(cmd); DirSaver ds; DoSetWorkingDirectory(proj, false, m_fileName.IsEmpty() == false); // expand the variables of the command cmd = ExpandAllVariables(cmd, w, m_info.GetProject(), m_info.GetConfiguration(), m_fileName); // print the build command AppendLine(cmd + wxT("\n")); if(m_info.GetProjectOnly() || m_fileName.IsEmpty() == false) { // set working directory DoSetWorkingDirectory(proj, false, m_fileName.IsEmpty() == false); } // print the prefix message of the build start. This is important since the parser relies // on this message if(m_info.GetProjectOnly() || m_fileName.IsEmpty() == false) { wxString configName(m_info.GetConfiguration()); // also, send another message to the main frame, indicating which project is being built // and what configuration wxString text; text << wxGetTranslation(BUILD_PROJECT_PREFIX) << m_info.GetProject() << wxT(" - ") << configName << wxT(" ]"); if(m_fileName.IsEmpty()) { text << wxT("----------\n"); } else if(m_preprocessOnly) { text << wxT(" (Preprocess Single File)----------\n"); } else { text << wxT(" (Single File Build)----------\n"); } AppendLine(text); } EnvSetter envir(env, &om, proj->GetName()); m_proc = CreateAsyncProcess(this, cmd); if(!m_proc) { wxString message; message << _("Failed to start build process, command: ") << cmd << _(", process terminated with exit code: 0"); AppendLine(message); return; } }
void OutputPane::OnBuildWindowDClick(const wxString &line, int lineno) { wxString fileName, strLineNumber; bool match = false; //get the selected compiler for the current line that was DClicked if(lineno >= (int)m_buildLineInfo.GetCount()){ return; } //find the project selected build configuration for the workspace selected //configuration wxString projectName = m_buildLineInfo.Item(lineno); if(projectName.IsEmpty()) return; BuildMatrixPtr matrix = ManagerST::Get()->GetWorkspaceBuildMatrix(); wxString projecBuildConf = matrix->GetProjectSelectedConf(matrix->GetSelectedConfigurationName(), projectName ); ProjectSettingsPtr settings = ManagerST::Get()->GetProject(projectName)->GetSettings(); if(!settings) { return; } BuildConfigPtr bldConf = settings->GetBuildConfiguration(projecBuildConf); if( !bldConf ) { return; } wxString cmpType = bldConf->GetCompilerType(); CompilerPtr cmp = BuildSettingsConfigST::Get()->GetCompiler(cmpType); if( !cmp ) { return; } long idx; //try to match an error pattern to the line RegexProcessor re(cmp->GetErrPattern()); cmp->GetErrFileNameIndex().ToLong(&idx); if(re.GetGroup(line, idx, fileName)) { //we found the file name, get the line number cmp->GetErrLineNumberIndex().ToLong(&idx); re.GetGroup(line, idx, strLineNumber); match = true; } //try to match warning pattern if(!match) { RegexProcessor re(cmp->GetWarnPattern()); cmp->GetWarnFileNameIndex().ToLong(&idx); if(re.GetGroup(line, idx, fileName)) { //we found the file name, get the line number cmp->GetWarnLineNumberIndex().ToLong(&idx); re.GetGroup(line, idx, strLineNumber); match = true; } } if(match) { long lineNumber = -1; strLineNumber.ToLong(&lineNumber); // open the file in the editor // get the project name that is currently being built wxString projName(wxEmptyString); if(lineno < (int)m_buildLineInfo.GetCount()) { projName = m_buildLineInfo.Item(lineno); } // if no project found, dont do anything if(projName.IsEmpty()) { return; } DirSaver ds; ProjectPtr pro = ManagerST::Get()->GetProject(projName); ::wxSetWorkingDirectory(pro->GetFileName().GetPath()); wxFileName fn(fileName); fn.MakeAbsolute(pro->GetFileName().GetPath()); ManagerST::Get()->OpenFile(fn.GetFullPath(), projName, lineNumber - 1 ); } }
//do the actual cleanup void CleanRequest::Process(IManager *manager) { wxString cmd; wxString errMsg; wxStringMap_t om; BuildSettingsConfig *bsc(manager ? manager->GetBuildSettingsConfigManager() : BuildSettingsConfigST::Get()); BuildManager * bm(manager ? manager->GetBuildManager() : BuildManagerST::Get()); Workspace * w(manager ? manager->GetWorkspace() : WorkspaceST::Get()); ProjectPtr proj = w->FindProjectByName(m_info.GetProject(), errMsg); if (!proj) { AppendLine(_("Cant find project: ") + m_info.GetProject()); return; } wxString pname (proj->GetName()); //BuilderPtr builder = bm->GetBuilder(wxT("GNU makefile for g++/gcc")); BuilderPtr builder = bm->GetSelectedBuilder(); if (m_info.GetProjectOnly()) { cmd = builder->GetPOCleanCommand(m_info.GetProject(), m_info.GetConfiguration()); } else { cmd = builder->GetCleanCommand(m_info.GetProject(), m_info.GetConfiguration()); } if ( cmd.IsEmpty() ) { AppendLine(_("Sorry, there is no 'Clean' command available\n")); return; } BuildConfigPtr bldConf = w->GetProjBuildConf(m_info.GetProject(), m_info.GetConfiguration()); if(bldConf) { wxString cmpType = bldConf->GetCompilerType(); CompilerPtr cmp = bsc->GetCompiler(cmpType); if(cmp) { wxString value( cmp->GetPathVariable() ); if(value.Trim().Trim(false).IsEmpty() == false) { wxLogMessage(wxString::Format(wxT("Setting PATH to '%s'"), value.c_str())); om[wxT("PATH")] = value.Trim().Trim(false); } } } else { AppendLine(_("Sorry, couldn't find the Build configuration\n")); return; } // Notify plugins that a compile process is going to start clBuildEvent event(wxEVT_BUILD_STARTING); event.SetProjectName( pname ); event.SetConfigurationName( m_info.GetConfiguration() ); if (EventNotifier::Get()->ProcessEvent(event)) { // the build is being handled by some plugin, no need to build it // using the standard way return; } SendStartMsg(); // Expand the variables of the command cmd = ExpandAllVariables(cmd, w, m_info.GetProject(), m_info.GetConfiguration(), wxEmptyString); WrapInShell(cmd); DirSaver ds; DoSetWorkingDirectory(proj, false, false); if (m_info.GetProjectOnly() ) { //need to change directory to project dir wxSetWorkingDirectory(proj->GetFileName().GetPath()); } //print the build command AppendLine(cmd + wxT("\n")); // print the prefix message of the build start. This is important since the parser relies // on this message if(m_info.GetProjectOnly()) { wxString configName(m_info.GetConfiguration()); //also, send another message to the main frame, indicating which project is being built //and what configuration wxString text; text << wxGetTranslation(CLEAN_PROJECT_PREFIX) << m_info.GetProject() << wxT(" - ") << configName << wxT(" ]"); text << wxT("----------\n"); AppendLine(text); } //apply environment settings EnvSetter env(NULL, &om, proj->GetName()); m_proc = CreateAsyncProcess(this, cmd); if ( !m_proc ) { //remove environment settings applied wxString message; message << _("Failed to start clean process, command: ") << cmd << _(", process terminated with exit code: 0"); AppendLine(message); return; } }