QueueCommand::QueueCommand(int kind) : m_projectOnly(false) , m_kind(kind) , m_cleanLog(true) , m_checkBuildSuccess(false) { // Fill with default values if ( clCxxWorkspaceST::Get()->IsOpen() ) { m_project = clCxxWorkspaceST::Get()->GetActiveProjectName(); BuildConfigPtr buildPtr = clCxxWorkspaceST::Get()->GetProjBuildConf(m_project, ""); wxASSERT_MSG( buildPtr, "No active project" ); // If a 'Build' or 'Clean' kinds where requested // and the project build configuration is Custom build // change the kind to CustomBuild and set the proper build // targets if ( m_kind == kBuild && buildPtr->IsCustomBuild() ) { // change the type to CustomBuild m_kind = kCustomBuild; SetCustomBuildTarget("Build"); } else if ( m_kind == kClean && buildPtr->IsCustomBuild() ) { // change the type to CustomBuild m_kind = kCustomBuild; SetCustomBuildTarget("Clean"); } else { m_configuration = buildPtr->GetName(); } } }
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 CMakePlugin::OnWorkspaceContextMenu(clContextMenuEvent& event) { event.Skip(); CHECK_COND_RET(clCxxWorkspaceST::Get()->IsOpen()); ProjectPtr p = clCxxWorkspaceST::Get()->GetActiveProject(); CHECK_COND_RET(p); BuildConfigPtr buildConf = p->GetBuildConfiguration(); CHECK_COND_RET(buildConf); CHECK_COND_RET(buildConf->GetBuilder()->GetName() == "CMake"); // The active project is using CMake builder // Add our context menu wxMenu* menu = event.GetMenu(); CHECK_PTR_RET(menu); wxFileName workspaceFile = clCxxWorkspaceST::Get()->GetFileName(); workspaceFile.SetFullName(CMAKELISTS_FILE); menu->InsertSeparator(0); if(workspaceFile.FileExists()) { wxMenuItem* item = new wxMenuItem(NULL, XRCID("cmake_open_active_project_cmake"), _("Open CMakeLists.txt")); item->SetBitmap(m_mgr->GetStdIcons()->LoadBitmap("cmake")); menu->Insert(0, item); } menu->Insert(0, XRCID("cmake_export_active_project"), _("Export CMakeLists.txt")); menu->Bind(wxEVT_MENU, &CMakePlugin::OnOpenCMakeLists, this, XRCID("cmake_open_active_project_cmake")); menu->Bind(wxEVT_MENU, &CMakePlugin::OnExportCMakeLists, this, XRCID("cmake_export_active_project")); }
void EditConfigurationDialog::RenameConfiguration(const wxString &oldName, const wxString &newName) { ProjectSettingsPtr settings = ManagerST::Get()->GetProjectSettings(m_projectName); if(settings){ BuildConfigPtr bldConf = settings->GetBuildConfiguration(oldName); if(bldConf){ settings->RemoveConfiguration(oldName); bldConf->SetName(newName); settings->SetBuildConfiguration(bldConf); //save changes ManagerST::Get()->SetProjectSettings(m_projectName, settings); //update the control m_configurationsList->Clear(); ProjectSettingsCookie cookie; BuildConfigPtr bldConf = settings->GetFirstBuildConfiguration(cookie); while(bldConf){ m_configurationsList->Append(bldConf->GetName()); bldConf = settings->GetNextBuildConfiguration(cookie); } if(m_configurationsList->GetCount()>0) m_configurationsList->SetSelection(0); } } }
void PSEnvironmentPage::Load(BuildConfigPtr buildConf) { /////////////////////////////////////////////////////////////////////////// // Set the environment page /////////////////////////////////////////////////////////////////////////// m_choiceEnv->Clear(); std::map<wxString, wxString> envSets = EnvironmentConfig::Instance()->GetSettings().GetEnvVarSets(); std::map<wxString, wxString>::const_iterator iterI = envSets.begin(); int useActiveSetIndex = m_choiceEnv->Append(wxGetTranslation(USE_WORKSPACE_ENV_VAR_SET)); for(; iterI != envSets.end(); iterI++) { m_choiceEnv->Append(iterI->first); } int selEnv = m_choiceEnv->FindString(buildConf->GetEnvVarSet()); m_choiceEnv->SetSelection(selEnv == wxNOT_FOUND ? useActiveSetIndex : selEnv); m_choiceDbgEnv->Clear(); useActiveSetIndex = m_choiceDbgEnv->Append(wxGetTranslation(USE_GLOBAL_SETTINGS)); DebuggerSettingsPreDefMap data; DebuggerConfigTool::Get()->ReadObject(wxT("DebuggerCommands"), &data); const std::map<wxString, DebuggerPreDefinedTypes>& preDefTypes = data.GePreDefinedTypesMap(); std::map<wxString, DebuggerPreDefinedTypes>::const_iterator iterB = preDefTypes.begin(); for(; iterB != preDefTypes.end(); iterB++) { m_choiceDbgEnv->Append(iterB->first); } int selDbg = m_choiceDbgEnv->FindString(buildConf->GetDbgEnvSet()); m_choiceDbgEnv->SetSelection(selEnv == wxNOT_FOUND ? useActiveSetIndex : selDbg); m_textCtrlEnvvars->SetValue(buildConf->GetEnvvars()); }
void BatchBuildDlg::DoInitialize() { // load the previously saved batch build file wxFileName fn(WorkspaceST::Get()->GetWorkspaceFileName()); fn.SetExt(wxT("batch_build")); wxString content; wxArrayString arr; if (ReadFileWithConversion(fn.GetFullPath(), content)) { arr = wxStringTokenize(content, wxT("\n"), wxTOKEN_STRTOK); for (size_t i=0; i<arr.GetCount(); i++) { int idx = m_checkListConfigurations->Append(arr.Item(i)); m_checkListConfigurations->Check((unsigned int)idx); } } // loop over all projects, for each project collect all available // build configurations and add them to the check list control wxArrayString projects; WorkspaceST::Get()->GetProjectList(projects); for (size_t i=0; i<projects.GetCount(); i++) { ProjectPtr p = ManagerST::Get()->GetProject(projects.Item(i)); if (p) { ProjectSettingsPtr settings = p->GetSettings(); if (settings) { ProjectSettingsCookie cookie; BuildConfigPtr bldConf = settings->GetFirstBuildConfiguration(cookie); while (bldConf) { wxString item(p->GetName() + wxT(" | ") + bldConf->GetName()); int where = arr.Index(item); if (where == wxNOT_FOUND) { // append this item m_checkListConfigurations->Append(item); } else { // this item already been added, // remove it from the arr and continue arr.RemoveAt((size_t)where); } bldConf = settings->GetNextBuildConfiguration(cookie); } } } } // check to see which configuration was left in 'arr' // and remove them from the checklistbox for (size_t i=0; i<arr.GetCount(); i++) { int where = m_checkListConfigurations->FindString(arr.Item(i)); if (where != wxNOT_FOUND) { m_checkListConfigurations->Delete((unsigned int)where); } } arr.clear(); if (m_checkListConfigurations->GetCount()>0) { m_checkListConfigurations->Select(0); } }
void ClangCodeCompletion::OnBuildStarting(clBuildEvent& e) { e.Skip(); CHECK_CLANG_ENABLED_RET(); // Determine the compilation database CompilationDatabase cdb; cdb.Open(); cdb.Close(); // Set the compilation database environment variable ::wxSetEnv(wxT("CL_COMPILATION_DB"), cdb.GetFileName().GetFullPath()); // If this is NOT a custom project, set the CXX and CC environment wxString project = e.GetProjectName(); wxString config = e.GetConfigurationName(); BuildConfigPtr bldConf = WorkspaceST::Get()->GetProjBuildConf(project, config); if( bldConf && !bldConf->IsCustomBuild()) { wxString cxx = bldConf->GetCompiler()->GetTool(wxT("CXX")); wxString cc = bldConf->GetCompiler()->GetTool(wxT("CC")); cxx.Prepend(wxT("codelitegcc ")); cc.Prepend(wxT("codelitegcc ")); ::wxSetEnv("CXX", cxx); ::wxSetEnv("CC" , cc); } }
wxString QMakePlugin::DoGetBuildCommand(const wxString &project, const wxString &config, bool projectOnly) { wxUnusedVar ( config ); wxString errMsg; ProjectPtr p = m_mgr->GetWorkspace()->FindProjectByName(project, errMsg); if ( !p ) { return wxEmptyString; } BuildConfigPtr bldConf = WorkspaceST::Get()->GetProjBuildConf(project, config); wxString cmd; if ( !projectOnly ) { cmd << wxT("@cd \"") << p->GetFileName().GetPath() << wxT("\" && "); } // fix: replace all Windows like slashes to POSIX wxString command = bldConf->GetCompiler()->GetTool("MAKE"); command.Replace(wxT("\\"), wxT("/")); cmd << command << wxT(" \"") << p->GetName() << wxT(".mk\""); return cmd; }
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++") ); } } }
wxString QMakePlugin::DoGetBuildCommand(const wxString& project, const wxString& config, bool projectOnly) { wxUnusedVar(config); wxString errMsg; ProjectPtr p = m_mgr->GetWorkspace()->FindProjectByName(project, errMsg); if(!p) { return wxEmptyString; } BuildConfigPtr bldConf = clCxxWorkspaceST::Get()->GetProjBuildConf(project, config); wxString cmd; wxString projectMakefile; projectMakefile << p->GetName() << ".mk"; ::WrapWithQuotes(projectMakefile); projectMakefile.Replace("\\", "/"); if(!projectOnly) { // part of a greater makefile, use $(MAKE) cmd << wxT("@cd \"") << p->GetFileName().GetPath() << wxT("\" && "); cmd << "$(MAKE) -f " << projectMakefile; } else { // project only cmd = bldConf->GetCompiler()->GetTool("MAKE"); if(!cmd.Contains("-f")) { cmd << " -f "; } cmd << " " << projectMakefile; } return cmd; }
void ShellCommand::DoSetWorkingDirectory(ProjectPtr proj, bool isCustom, bool isFileOnly) { //when using custom build, user can select different working directory if (proj) { if (isCustom) { //first set the path to the project working directory ::wxSetWorkingDirectory(proj->GetFileName().GetPath()); BuildConfigPtr buildConf = WorkspaceST::Get()->GetProjBuildConf(m_info.GetProject(), m_info.GetConfiguration()); if (buildConf) { wxString wd = buildConf->GetCustomBuildWorkingDir(); if (wd.IsEmpty()) { // use the project path wd = proj->GetFileName().GetPath(); } else { // expand macros from path wd = ExpandAllVariables(wd, WorkspaceST::Get(), proj->GetName(), buildConf->GetName(), wxEmptyString); } ::wxSetWorkingDirectory(wd); } } else { if(m_info.GetProjectOnly() || isFileOnly) { //first set the path to the project working directory ::wxSetWorkingDirectory(proj->GetFileName().GetPath()); } } } }
void PSCustomMakefileRulesPage::Save(BuildConfigPtr buildConf, ProjectSettingsPtr projSettingsPtr) { //set the pre-build step wxString rules = m_textPreBuildRule->GetValue(); wxString deps = m_textDeps->GetValue(); rules = rules.Trim(); rules = rules.Trim(false); deps = deps.Trim(); deps = deps.Trim(false); wxString prebuilstep; prebuilstep << deps << wxT("\n"); prebuilstep << rules; prebuilstep << wxT("\n"); // Set the content only if there is real content to add wxString tmpPreBuildStep(prebuilstep); tmpPreBuildStep.Trim().Trim(false); if(tmpPreBuildStep.IsEmpty() == false) { buildConf->SetPreBuildCustom(prebuilstep); } else { buildConf->SetPreBuildCustom(wxT("")); } }
wxString CMakePlugin::GetSelectedProjectConfig() const { BuildConfigPtr configPtr = GetSelectedBuildConfig(); if(configPtr) return configPtr->GetName(); return wxEmptyString; }
void PSLinkerPage::Save(BuildConfigPtr buildConf, ProjectSettingsPtr projSettingsPtr) { buildConf->SetLinkerRequired(!m_checkLinkerNeeded->IsChecked()); buildConf->SetLibPath( m_pgPropLibraryPaths->GetValueAsString() ); buildConf->SetLibraries( m_pgPropLibraries->GetValueAsString() ); buildConf->SetLinkOptions( m_pgPropOptions->GetValueAsString() ); buildConf->SetBuildLnkWithGlobalSettings(m_pgPropBehaviorWithGlobalSettings->GetValueAsString()); }
void PSLinkerPage::Load(BuildConfigPtr buildConf) { m_checkLinkerNeeded->SetValue( !buildConf->IsLinkerRequired() ); SelectChoiceWithGlobalSettings(m_pgPropBehaviorWithGlobalSettings, buildConf->GetBuildLnkWithGlobalSettings()); m_pgPropLibraries->SetValue( buildConf->GetLibraries() ); m_pgPropLibraryPaths->SetValue( buildConf->GetLibPath() ); m_pgPropOptions->SetValue( buildConf->GetLinkOptions() ); }
void QMakePlugin::OnExportMakefile(wxCommandEvent& event) { if(m_qmakeProcess) return; QmakePluginData::BuildConfPluginData bcpd; ProjectPtr pProj = m_mgr->GetSelectedProject(); CHECK_PTR_RET(pProj); BuildConfigPtr bldConf = pProj->GetBuildConfiguration(); CHECK_PTR_RET(bldConf); wxString project = pProj->GetName(); wxString config = bldConf->GetName(); if(!DoGetData(project, config, bcpd)) { event.Skip(); return; } if(bcpd.m_enabled) { // This project/configuration is qmake project QMakeProFileGenerator generator(m_mgr, project, config); // Regenerate the .pro file generator.Generate(); // run qmake wxString qmake_exe = m_conf->Read(wxString::Format(wxT("%s/qmake"), bcpd.m_qmakeConfig.c_str())); wxString qmakespec = m_conf->Read(wxString::Format(wxT("%s/qmakespec"), bcpd.m_qmakeConfig.c_str())); wxString qtdir = m_conf->Read(wxString::Format(wxT("%s/qtdir"), bcpd.m_qmakeConfig.c_str())); // Create qmake comand wxString qmake_exe_line; qmake_exe.Trim().Trim(false); qmakespec.Trim().Trim(false); // Set QTDIR DirSaver ds; { wxString errMsg; ProjectPtr p = m_mgr->GetWorkspace()->FindProjectByName(project, errMsg); if(!p) { return; } qmake_exe_line << wxT("\"") << qmake_exe << wxT("\" -spec ") << qmakespec << wxT(" ") << generator.GetProFileName(); wxStringMap_t om; om.insert(std::make_pair("QTDIR", qtdir)); EnvSetter envGuard(NULL, &om, project, config); m_mgr->ClearOutputTab(kOutputTab_Build); m_mgr->AppendOutputTabText(kOutputTab_Build, wxString() << "-- " << qmake_exe_line << "\n"); m_qmakeProcess = ::CreateAsyncProcess(this, qmake_exe_line, IProcessCreateDefault, p->GetFileName().GetPath()); } } event.Skip(); }
void CMakePlugin::DoRunCMake(ProjectPtr p) { CHECK_PTR_RET(p); BuildConfigPtr buildConf = p->GetBuildConfiguration(); CHECK_COND_RET(buildConf); // Apply the environment variables before we do anything here #ifdef __WXMSW__ // On Windows, we need to set the bin folder of the selected compiler wxFileName fnCxx(buildConf->GetCompiler()->GetTool("CXX")); wxStringMap_t om; wxString pathvar; pathvar << fnCxx.GetPath() << clPATH_SEPARATOR << "$PATH"; om["PATH"] = pathvar; EnvSetter es(NULL, &om, p->GetName(), buildConf->GetName()); #else EnvSetter es(p); #endif CMakeGenerator generator; if(generator.CanGenerate(p)) { generator.Generate(p); } const wxString& args = buildConf->GetBuildSystemArguments(); wxString cmakeExe = GetCMake()->GetPath().GetFullPath(); // Did the user provide a generator to use? bool hasGeneratorInArgs = (args.Find(" -G") != wxNOT_FOUND); // Build the working directory wxFileName fnWorkingDirectory(CMakeBuilder::GetWorkspaceBuildFolder(false), ""); wxString workingDirectory = fnWorkingDirectory.GetPath(); // Ensure that the build directory exists fnWorkingDirectory.Mkdir(wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL); ::WrapWithQuotes(cmakeExe); wxString command; command << cmakeExe << " .. " << args; if(!hasGeneratorInArgs) { #ifdef __WXMSW__ // On Windows, generate MinGW makefiles command << " -G\"MinGW Makefiles\""; #endif } // Execute it IProcess* proc = ::CreateAsyncProcess(this, command, IProcessCreateDefault, fnWorkingDirectory.GetPath()); if(!proc) { ::wxMessageBox(_("Failed to execute:\n") + command, "CodeLite", wxICON_ERROR | wxOK | wxCENTER, EventNotifier::Get()->TopFrame()); return; } m_mgr->ShowOutputPane(_("Build")); m_mgr->ClearOutputTab(kOutputTab_Build); m_mgr->AppendOutputTabText(kOutputTab_Build, command + "\n"); }
wxString MemCheckPlugin::PrepareCommand(const wxString& projectName, wxString& wd) { wd.clear(); if(!clCxxWorkspaceST::Get()->IsOpen()) { return ""; } ProjectPtr proj = clCxxWorkspaceST::Get()->GetProject(projectName); if(!proj) { clWARNING() << "MemCheckPlugin::PrepareCommand(): could not find project:" << projectName; return wxEmptyString; } BuildConfigPtr bldConf = clCxxWorkspaceST::Get()->GetProjBuildConf(projectName, wxEmptyString); if(!bldConf) { clWARNING() << "MemCheckPlugin::PrepareCommand(): failed to find project configuration for project:" << projectName; return wxEmptyString; } wxString projectPath = proj->GetFileName().GetPath(); // expand variables wxString cmd = bldConf->GetCommand(); cmd = MacroManager::Instance()->Expand(cmd, NULL, projectName); wxString cmdArgs = bldConf->GetCommandArguments(); cmdArgs = MacroManager::Instance()->Expand(cmdArgs, NULL, projectName); // Execute command & cmdArgs wd = bldConf->GetWorkingDirectory(); wd = MacroManager::Instance()->Expand(wd, NULL, projectName); wxFileName workingDir(wd, ""); if(workingDir.IsRelative()) { workingDir.MakeAbsolute(projectPath); } wxFileName fileExe(cmd); if(fileExe.IsRelative()) { fileExe.MakeAbsolute(workingDir.GetPath()); } fileExe.Normalize(); #ifdef __WXMSW__ if(!fileExe.Exists() && fileExe.GetExt().IsEmpty()) { // Try with .exe wxFileName withExe(fileExe); withExe.SetExt("exe"); if(withExe.Exists()) { fileExe = withExe; } } #endif wd = workingDir.GetPath(); cmd = fileExe.GetFullPath(); cmd = ::WrapWithQuotes(cmd); cmd << " " << cmdArgs; clDEBUG() << "Command to execute:" << cmd; clDEBUG() << "Working directory:" << wd; return cmd; }
void ProjectSettings::SetBuildConfiguration(const BuildConfigPtr bc) { if(!bc) return; // delete the old build configuration pointer if any std::map<wxString, BuildConfigPtr>::iterator iter = m_configs.find(bc->GetName()); if(iter != m_configs.end()) m_configs.erase(iter); // replace with the new one m_configs[bc->GetName()] = bc; }
wxArrayString Project::GetIncludePaths() { wxArrayString paths; BuildMatrixPtr matrix = WorkspaceST::Get()->GetBuildMatrix(); if(!matrix) { return paths; } wxString workspaceSelConf = matrix->GetSelectedConfigurationName(); wxString projectSelConf = matrix->GetProjectSelectedConf(workspaceSelConf, GetName()); BuildConfigPtr buildConf = WorkspaceST::Get()->GetProjBuildConf(this->GetName(), projectSelConf); // for non custom projects, take the settings from the build configuration if(buildConf && !buildConf->IsCustomBuild()) { // Get the include paths and add them wxString projectIncludePaths = buildConf->GetIncludePath(); wxArrayString projectIncludePathsArr = wxStringTokenize(projectIncludePaths, wxT(";"), wxTOKEN_STRTOK); for(size_t i=0; i<projectIncludePathsArr.GetCount(); i++) { wxFileName fn; if(projectIncludePathsArr.Item(i) == wxT("..")) { fn = wxFileName(GetFileName().GetPath(), wxT("")); fn.RemoveLastDir(); } else if(projectIncludePathsArr.Item(i) == wxT(".")) { fn = wxFileName(GetFileName().GetPath(), wxT("")); } else { fn = projectIncludePathsArr.Item(i); if(fn.IsRelative()) { fn.MakeAbsolute(GetFileName().GetPath()); } } paths.Add( fn.GetFullPath() ); } // get the compiler options and add them wxString projectCompileOptions = buildConf->GetCompileOptions(); wxArrayString projectCompileOptionsArr = wxStringTokenize(projectCompileOptions, wxT(";"), wxTOKEN_STRTOK); for(size_t i=0; i<projectCompileOptionsArr.GetCount(); i++) { wxString cmpOption (projectCompileOptionsArr.Item(i)); cmpOption.Trim().Trim(false); // expand backticks, if the option is not a backtick the value remains // unchanged wxArrayString includePaths = DoBacktickToIncludePath(cmpOption); if(includePaths.IsEmpty() == false) paths.insert(paths.end(), includePaths.begin(), includePaths.end()); } } return paths; }
void PSCompilerPage::Load(BuildConfigPtr buildConf) { m_checkCompilerNeeded->SetValue(!buildConf->IsCompilerRequired()); m_pgPropCppOpts->SetValueFromString(buildConf->GetCompileOptions()); m_pgPropIncludePaths->SetValueFromString( buildConf->GetIncludePath() ); m_pgPropPreProcessors->SetValueFromString( buildConf->GetPreprocessor() ); m_pgPropPreCmpHeaderFile->SetValue( buildConf->GetPrecompiledHeader() ); m_pgPropCOpts->SetValue(buildConf->GetCCompileOptions()); SelectChoiceWithGlobalSettings(m_pgPropBehaviorWithGlobalSettings, buildConf->GetBuildCmpWithGlobalSettings()); m_pgPropIncludePCH->SetValue( buildConf->GetPchInCommandLine() ); m_pgPropPCHCompileLine->SetValue( buildConf->GetPchCompileFlags() ); m_pgPropAssembler->SetValue(buildConf->GetAssmeblerOptions()); }
void CMakePlugin::OnProjectContextMenu(clContextMenuEvent& event) { event.Skip(); CHECK_COND_RET(clCxxWorkspaceST::Get()->IsOpen()); ProjectPtr p = GetSelectedProject(); CHECK_COND_RET(p); BuildConfigPtr buildConf = p->GetBuildConfiguration(); CHECK_COND_RET(buildConf); CHECK_COND_RET(buildConf->GetBuilder()->GetName() == "CMake"); // The selected project is using CMake builder // Add our context menu wxMenu* menu = event.GetMenu()->GetParent(); // We want to attach this action to the main menu, not the subclass CHECK_PTR_RET(menu); const wxMenuItemList& items = menu->GetMenuItems(); size_t buildPos = 0; size_t settingsPos = 0; size_t curpos = 0; wxMenuItemList::const_iterator iter = items.begin(); for(; iter != items.end(); ++iter) { if((*iter)->GetId() == XRCID("build_project")) { buildPos = curpos; } if((*iter)->GetId() == XRCID("project_properties")) { settingsPos = curpos; } ++curpos; } wxFileName projectFile = p->GetFileName(); projectFile.SetFullName(CMAKELISTS_FILE); if(projectFile.FileExists()) { wxMenuItem* item = new wxMenuItem(NULL, XRCID("cmake_open_cmake"), _("Open CMakeLists.txt")); item->SetBitmap(m_mgr->GetStdIcons()->LoadBitmap("cmake")); menu->Insert(settingsPos, item); } menu->Insert(buildPos, XRCID("cmake_run_cmake"), _("Run CMake")); menu->InsertSeparator(buildPos); menu->Insert(buildPos, XRCID("cmake_export_cmakelists"), _("Export CMakeLists.txt")); menu->Bind(wxEVT_MENU, &CMakePlugin::OnRunCMake, this, XRCID("cmake_run_cmake")); menu->Bind(wxEVT_MENU, &CMakePlugin::OnOpenCMakeLists, this, XRCID("cmake_open_cmake")); menu->Bind(wxEVT_MENU, &CMakePlugin::OnExportCMakeLists, this, XRCID("cmake_export_cmakelists")); }
void PSEnvironmentPage::Save(BuildConfigPtr buildConf, ProjectSettingsPtr projSettingsPtr) { wxString env = m_choiceDbgEnv->GetStringSelection(); if(env == wxGetTranslation(USE_GLOBAL_SETTINGS)) { // Save it untranslated env = USE_GLOBAL_SETTINGS; } buildConf->SetDbgEnvSet(env); env = m_choiceEnv->GetStringSelection(); if(env == wxGetTranslation(USE_WORKSPACE_ENV_VAR_SET)) { env = USE_WORKSPACE_ENV_VAR_SET; } buildConf->SetEnvVarSet(env); buildConf->SetEnvvars(m_textCtrlEnvvars->GetValue().Trim().Trim(false)); }
void clCxxWorkspace::CreateCompileCommandsJSON(JSONElement& compile_commands) const { BuildMatrixPtr matrix = clCxxWorkspaceST::Get()->GetBuildMatrix(); if(!matrix) return; wxString workspaceSelConf = matrix->GetSelectedConfigurationName(); clCxxWorkspace::ProjectMap_t::const_iterator iter = m_projects.begin(); for(; iter != m_projects.end(); ++iter) { BuildConfigPtr buildConf = iter->second->GetBuildConfiguration(); if(buildConf && buildConf->IsProjectEnabled() && !buildConf->IsCustomBuild() && buildConf->IsCompilerRequired()) { iter->second->CreateCompileCommandsJSON(compile_commands); } } }
EnvMap EvnVarList::GetVariables( const wxString& setName, bool includeWorkspaceEnvs, const wxString& projectName, const wxString& configName) { EnvMap variables; wxString actualSetName; wxString currentValueStr = DoGetSetVariablesStr(setName, actualSetName); if(includeWorkspaceEnvs && !clCxxWorkspaceST::Get()->GetName().IsEmpty()) { currentValueStr.Trim().Trim(false); currentValueStr << wxT("\n"); currentValueStr << clCxxWorkspaceST::Get()->GetEnvironmentVariabels(); if(projectName.IsEmpty() == false) { currentValueStr.Trim().Trim(false); BuildConfigPtr buildConf = clCxxWorkspaceST::Get()->GetProjBuildConf(projectName, configName); if(buildConf) { currentValueStr << wxT("\n"); currentValueStr << buildConf->GetEnvvars(); } } } wxArrayString currentValues = wxStringTokenize(currentValueStr, wxT("\r\n"), wxTOKEN_STRTOK); for(size_t i = 0; i < currentValues.GetCount(); i++) { wxString entry = currentValues.Item(i); // remove any comment from the line int where = entry.Find(wxT("#")); if(where != wxNOT_FOUND) { entry = entry.Left(where); } entry.Trim().Trim(false); if(entry.IsEmpty()) { continue; } wxString varname = entry.BeforeFirst(wxT('=')); wxString varvalue = entry.AfterFirst(wxT('=')); // Expand macros (which are not environment variables) varvalue = MacroManager::Instance()->ExpandNoEnv(varvalue, projectName, configName); variables.Put(varname, varvalue); } return variables; }
void CMakePlugin::OnFileRemoved(clCommandEvent& event) { event.Skip(); CHECK_COND_RET(clCxxWorkspaceST::Get()->IsOpen()); // The affected project is passed in the string member of the event ProjectPtr p = clCxxWorkspaceST::Get()->GetProject(event.GetString()); CHECK_PTR_RET(p); BuildConfigPtr buildConf = p->GetBuildConfiguration(); CHECK_COND_RET(buildConf); // Ensure we are a CMake project CHECK_COND_RET(buildConf->GetBuilder()->GetName() == "CMake"); DoRunCMake(p); }
wxString ProjectSettings::GetProjectType(const wxString &confName) { // try to return the project type per configuration name. If no property name 'configurationType' exists, // return the parent configuration type if (confName.IsEmpty() == false) { std::map<wxString, BuildConfigPtr>::iterator iter = m_configs.find(confName); if (iter != m_configs.end()) { BuildConfigPtr conf = iter->second; wxString type = conf->GetProjectType(); if (type.IsEmpty()) { type = m_projectType; } return type; } } return m_projectType; }
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 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() ); } } } }
void ConfigurationManagerDlg::LoadProjectConfiguration(const wxString &projectName) { std::map<int, ConfigEntry>::iterator iter = m_projSettingsMap.begin(); for (; iter != m_projSettingsMap.end(); iter++) { if (iter->second.project == projectName) { iter->second.choiceControl->Clear(); ProjectSettingsPtr proSet = ManagerST::Get()->GetProjectSettings(projectName); if (proSet) { ProjectSettingsCookie cookie; BuildConfigPtr bldConf = proSet->GetFirstBuildConfiguration(cookie); while (bldConf) { iter->second.choiceControl->Append(bldConf->GetName()); bldConf = proSet->GetNextBuildConfiguration(cookie); } //append the EDIT & NEW commands iter->second.choiceControl->Append(clCMD_EDIT); iter->second.choiceControl->Append(clCMD_NEW); //select the build configuration according to the build matrix BuildMatrixPtr matrix = ManagerST::Get()->GetWorkspaceBuildMatrix(); if (!matrix) { return; } wxString configName = matrix->GetProjectSelectedConf(m_choiceConfigurations->GetStringSelection(), projectName); int match = iter->second.choiceControl->FindString(configName); if (match != wxNOT_FOUND) { iter->second.choiceControl->SetStringSelection(configName); } else { iter->second.choiceControl->SetSelection(0); } return; } } } }