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());
}
示例#2
0
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;
}