BuildConfigPtr ProjectSettings::GetBuildConfiguration(const wxString& configName, bool merge) const { wxString confName = configName; if(confName.IsEmpty()) { confName = wxT("Debug"); } std::map<wxString, BuildConfigPtr>::const_iterator iter = m_configs.find(confName); if(iter == m_configs.end()) { return NULL; } BuildConfigPtr buildConf = iter->second; if(!merge) { return buildConf; } // Need to merge configuration and global settings BuildConfigPtr buildConfMerged(buildConf->Clone()); if(buildConfMerged->GetBuildCmpWithGlobalSettings() == BuildConfig::PREPEND_GLOBAL_SETTINGS) { buildConfMerged->SetCompileOptions(buildConf->GetCompileOptions() + wxT(";") + m_globalSettings->GetCompileOptions()); buildConfMerged->SetCCompileOptions(buildConf->GetCCompileOptions() + wxT(";") + m_globalSettings->GetCCompileOptions()); buildConfMerged->SetPreprocessor(buildConf->GetPreprocessor() + wxT(";") + m_globalSettings->GetPreprocessor()); buildConfMerged->SetIncludePath(buildConf->GetIncludePath() + wxT(";") + m_globalSettings->GetIncludePath()); } else if(buildConfMerged->GetBuildCmpWithGlobalSettings() == BuildConfig::APPEND_TO_GLOBAL_SETTINGS) { buildConfMerged->SetCompileOptions(m_globalSettings->GetCompileOptions() + wxT(";") + buildConf->GetCompileOptions()); buildConfMerged->SetCCompileOptions(m_globalSettings->GetCCompileOptions() + wxT(";") + buildConf->GetCCompileOptions()); buildConfMerged->SetPreprocessor(m_globalSettings->GetPreprocessor() + wxT(";") + buildConf->GetPreprocessor()); buildConfMerged->SetIncludePath(m_globalSettings->GetIncludePath() + wxT(";") + buildConf->GetIncludePath()); } if(buildConfMerged->GetBuildLnkWithGlobalSettings() == BuildConfig::PREPEND_GLOBAL_SETTINGS) { buildConfMerged->SetLinkOptions(buildConf->GetLinkOptions() + wxT(";") + m_globalSettings->GetLinkOptions()); buildConfMerged->SetLibraries(buildConf->GetLibraries() + wxT(";") + m_globalSettings->GetLibraries()); buildConfMerged->SetLibPath(buildConf->GetLibPath() + wxT(";") + m_globalSettings->GetLibPath()); } else if(buildConfMerged->GetBuildLnkWithGlobalSettings() == BuildConfig::APPEND_TO_GLOBAL_SETTINGS) { buildConfMerged->SetLinkOptions(m_globalSettings->GetLinkOptions() + wxT(";") + buildConf->GetLinkOptions()); buildConfMerged->SetLibraries(m_globalSettings->GetLibraries() + wxT(";") + buildConf->GetLibraries()); buildConfMerged->SetLibPath(m_globalSettings->GetLibPath() + wxT(";") + buildConf->GetLibPath()); } if(buildConfMerged->GetBuildResWithGlobalSettings() == BuildConfig::PREPEND_GLOBAL_SETTINGS) { buildConfMerged->SetResCmpOptions(buildConf->GetResCompileOptions() + wxT(";") + m_globalSettings->GetResCompileOptions()); buildConfMerged->SetResCmpIncludePath(buildConf->GetResCmpIncludePath() + wxT(";") + m_globalSettings->GetResCmpIncludePath()); } else if(buildConfMerged->GetBuildResWithGlobalSettings() == BuildConfig::APPEND_TO_GLOBAL_SETTINGS) { buildConfMerged->SetResCmpOptions(m_globalSettings->GetResCompileOptions() + wxT(";") + buildConf->GetResCompileOptions()); buildConfMerged->SetResCmpIncludePath(m_globalSettings->GetResCmpIncludePath() + wxT(";") + buildConf->GetResCmpIncludePath()); } return buildConfMerged; }
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()); }
wxArrayString PluginManager::GetProjectCompileFlags(const wxString& projectName, bool isCppFile) { if(IsWorkspaceOpen() == false) return wxArrayString(); wxArrayString args; // Next apppend the user include paths wxString errMsg; // First, we need to find the currently active workspace configuration BuildMatrixPtr matrix = GetWorkspace()->GetBuildMatrix(); if(!matrix) { return wxArrayString(); } wxString workspaceSelConf = matrix->GetSelectedConfigurationName(); // Now that we got the selected workspace configuration, extract the related project configuration ProjectPtr proj = GetWorkspace()->FindProjectByName(projectName, errMsg); if(!proj) { return args; } wxString projectSelConf = matrix->GetProjectSelectedConf(workspaceSelConf, proj->GetName()); BuildConfigPtr dependProjbldConf = GetWorkspace()->GetProjBuildConf(proj->GetName(), projectSelConf); if(dependProjbldConf && dependProjbldConf->IsCustomBuild() == false) { // Get the include paths and add them wxString projectIncludePaths = dependProjbldConf->GetIncludePath(); wxArrayString projectIncludePathsArr = wxStringTokenize(projectIncludePaths, wxT(";"), wxTOKEN_STRTOK); for(size_t i = 0; i < projectIncludePathsArr.GetCount(); i++) { args.Add(wxString::Format(wxT("-I%s"), projectIncludePathsArr[i].c_str())); } // get the compiler options and add them wxString projectCompileOptions = dependProjbldConf->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); wxString tmp; // Expand backticks / $(shell ...) syntax supported by codelite if(cmpOption.StartsWith(wxT("$(shell "), &tmp) || cmpOption.StartsWith(wxT("`"), &tmp)) { cmpOption = tmp; tmp.Clear(); if(cmpOption.EndsWith(wxT(")"), &tmp) || cmpOption.EndsWith(wxT("`"), &tmp)) { cmpOption = tmp; } if(m_backticks.find(cmpOption) == m_backticks.end()) { // Expand the backticks into their value wxArrayString outArr; // Apply the environment before executing the command EnvSetter setter(EnvironmentConfig::Instance(), NULL, projectName); ProcUtils::SafeExecuteCommand(cmpOption, outArr); wxString expandedValue; for(size_t j = 0; j < outArr.size(); j++) { expandedValue << outArr.Item(j) << wxT(" "); } m_backticks[cmpOption] = expandedValue; cmpOption = expandedValue; } else { cmpOption = m_backticks.find(cmpOption)->second; } } args.Add(cmpOption); } // get the compiler preprocessor and add them as well wxString projectPreps = dependProjbldConf->GetPreprocessor(); wxArrayString projectPrepsArr = wxStringTokenize(projectPreps, wxT(";"), wxTOKEN_STRTOK); for(size_t i = 0; i < projectPrepsArr.GetCount(); i++) { args.Add(wxString::Format(wxT("-D%s"), projectPrepsArr[i].c_str())); } } return args; }