Example #1
0
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());
    }
}
Example #2
0
void NewBuildTab::DoCacheRegexes()
{
    m_cmpPatterns.clear();

    // Loop over all known compilers and cache the regular expressions
    BuildSettingsConfigCookie cookie;
    CompilerPtr cmp = BuildSettingsConfigST::Get()->GetFirstCompiler(cookie);
    while( cmp ) {
        CmpPatterns cmpPatterns;
        const Compiler::CmpListInfoPattern& errPatterns  = cmp->GetErrPatterns();
        const Compiler::CmpListInfoPattern& warnPatterns = cmp->GetWarnPatterns();
        Compiler::CmpListInfoPattern::const_iterator iter;
        for (iter = errPatterns.begin(); iter != errPatterns.end(); iter++) {

            CmpPatternPtr compiledPatternPtr(new CmpPattern(new wxRegEx(iter->pattern), iter->fileNameIndex, iter->lineNumberIndex, SV_ERROR));
            if(compiledPatternPtr->GetRegex()->IsValid()) {
                cmpPatterns.errorsPatterns.push_back( compiledPatternPtr );
            }
        }

        for (iter = warnPatterns.begin(); iter != warnPatterns.end(); iter++) {

            CmpPatternPtr compiledPatternPtr(new CmpPattern(new wxRegEx(iter->pattern), iter->fileNameIndex, iter->lineNumberIndex, SV_WARNING));
            if(compiledPatternPtr->GetRegex()->IsValid()) {
                cmpPatterns.warningPatterns.push_back( compiledPatternPtr );
            }
        }

        m_cmpPatterns.insert(std::make_pair(cmp->GetName(), cmpPatterns));
        cmp =  BuildSettingsConfigST::Get()->GetNextCompiler(cookie);
    }

}
void CompilerLocatorCrossGCC::AddTools(CompilerPtr compiler,
                                       const wxString& binFolder,
                                       const wxString& prefix,
                                       const wxString& suffix)
{
    compiler->SetName("Cross GCC ( " + prefix + " )");
    compiler->SetInstallationPath(binFolder);

    CL_DEBUG("Found CrossGCC compiler under: %s. \"%s\"", binFolder, compiler->GetName());
    wxFileName toolFile(binFolder, "");

    toolFile.SetFullName(prefix + "-g++");
    toolFile.SetExt(suffix);
    AddTool(compiler, "CXX", toolFile.GetFullPath(), suffix);
    AddTool(compiler, "LinkerName", toolFile.GetFullPath());
    AddTool(compiler, "SharedObjectLinkerName", toolFile.GetFullPath(), "-shared -fPIC");

    toolFile.SetFullName(prefix + "-gcc");
    toolFile.SetExt(suffix);
    AddTool(compiler, "CC", toolFile.GetFullPath());

    toolFile.SetFullName(prefix + "-ar");
    toolFile.SetExt(suffix);
    AddTool(compiler, "AR", toolFile.GetFullPath(), "rcu");

    toolFile.SetFullName(prefix + "-windres");
    toolFile.SetExt(suffix);
    if(toolFile.FileExists()) AddTool(compiler, "ResourceCompiler", toolFile.GetFullPath());

    toolFile.SetFullName(prefix + "-as");
    toolFile.SetExt(suffix);
    AddTool(compiler, "AS", toolFile.GetFullPath());

    toolFile.SetFullName(prefix + "-gdb");
    toolFile.SetExt(suffix);
    AddTool(compiler, "Debugger", toolFile.GetFullPath());

    toolFile.SetFullName("make");
    toolFile.SetExt(suffix);
    wxString makeExtraArgs;
    if(wxThread::GetCPUCount() > 1) {
        makeExtraArgs << "-j" << wxThread::GetCPUCount();
    }

    // XXX Need this on Windows?
    // makeExtraArgs <<  " SHELL=cmd.exe ";

    // What to do if there's no make here? (on Windows)
    if(toolFile.FileExists()) AddTool(compiler, "MAKE", toolFile.GetFullPath(), makeExtraArgs);
}
Example #4
0
NewCompilerDlg::NewCompilerDlg(wxWindow* parent)
    : NewCompilerDlgBase(parent)
{
    BuildSettingsConfigCookie cookie;
    m_choiceCompilers->Append("<None>");
    CompilerPtr cmp = BuildSettingsConfigST::Get()->GetFirstCompiler(cookie);
    while ( cmp ) {
        m_choiceCompilers->Append(cmp->GetName());
        cmp = BuildSettingsConfigST::Get()->GetNextCompiler(cookie);
    }

    m_choiceCompilers->SetStringSelection("<None>");
    WindowAttrManager::Load(this, "NewCompilerDlg");
}
void CompilerLocatorGCC::AddTools(CompilerPtr compiler,
                                  const wxString& binFolder,
                                  const wxString& suffix)
{
    wxFileName masterPath(binFolder, "");
    wxString defaultBinFolder = "/usr/bin";
    compiler->SetCompilerFamily(COMPILER_FAMILY_GCC);
    compiler->SetInstallationPath( binFolder );

    CL_DEBUG("Found GNU GCC compiler under: %s. \"%s\"", masterPath.GetPath(), compiler->GetName());
    wxFileName toolFile(binFolder, "");

    // ++++-----------------------------------------------------------------
    // With XCode installation, only
    // g++, gcc, and make are installed under the Xcode installation folder
    // the rest (mainly ar and as) are taken from /usr/bin
    // ++++-----------------------------------------------------------------

    toolFile.SetFullName("g++");
    AddTool(compiler, "CXX", toolFile.GetFullPath(), suffix);
    AddTool(compiler, "LinkerName", toolFile.GetFullPath(), suffix);
#ifndef __WXMAC__
    AddTool(compiler, "SharedObjectLinkerName", toolFile.GetFullPath(), suffix, "-shared -fPIC");
#else
    AddTool(compiler, "SharedObjectLinkerName", toolFile.GetFullPath(), suffix, "-dynamiclib -fPIC");
#endif
    toolFile.SetFullName("gcc");
    AddTool(compiler, "CC", toolFile.GetFullPath(), suffix);
    toolFile.SetFullName("make");
    wxString makeExtraArgs;
    if ( wxThread::GetCPUCount() > 1 ) {
        makeExtraArgs << "-j" << wxThread::GetCPUCount();
    }
    AddTool(compiler, "MAKE", toolFile.GetFullPath(), "", makeExtraArgs);

    // ++++-----------------------------------------------------------------
    // From this point on, we use /usr/bin only
    // ++++-----------------------------------------------------------------

    toolFile.AssignDir( defaultBinFolder );
    toolFile.SetFullName("ar");
    AddTool(compiler, "AR", toolFile.GetFullPath(), "", "rcu");

    toolFile.SetFullName("windres");
    AddTool(compiler, "ResourceCompiler", "", "");

    toolFile.SetFullName("as");
    AddTool(compiler, "AS", toolFile.GetFullPath(), "");
}
void CompilerLocatorMinGW::AddTools(CompilerPtr compiler, const wxString& binFolder, const wxString& name)
{
    wxFileName masterPath(binFolder, "");
    masterPath.RemoveLastDir();
    if ( m_locatedFolders.count(masterPath.GetPath()) ) {
        return;
    }
    m_locatedFolders.insert( masterPath.GetPath() );
    
    if ( name.IsEmpty() ) {
        compiler->SetName("MinGW ( " + masterPath.GetDirs().Last() + " )");

    } else {
        compiler->SetName("MinGW ( " + name + " )");
    }
    
    CL_DEBUG("Found MinGW compiler under: %s. \"%s\"", masterPath.GetPath(), compiler->GetName());
    wxFileName toolFile(binFolder, "");
    
    toolFile.SetFullName("g++.exe");
    AddTool(compiler, "CXX", toolFile.GetFullPath());
    AddTool(compiler, "LinkerName", toolFile.GetFullPath());
    AddTool(compiler, "SharedObjectLinkerName", toolFile.GetFullPath(), "-shared -fPIC");
    
    toolFile.SetFullName("gcc.exe");
    AddTool(compiler, "CC", toolFile.GetFullPath());

    toolFile.SetFullName("ar.exe");
    AddTool(compiler, "AR", toolFile.GetFullPath(), "rcu");

    toolFile.SetFullName("windres.exe");
    AddTool(compiler, "ResourceCompiler", toolFile.GetFullPath());
    
    toolFile.SetFullName("as.exe");
    AddTool(compiler, "AS", toolFile.GetFullPath());
    
    toolFile.SetFullName("make.exe");
    if ( toolFile.FileExists() ) {
        AddTool(compiler, "MAKE", toolFile.GetFullPath());
        
    } else {
        toolFile.SetFullName("mingw32-make.exe");
        if ( toolFile.FileExists() ) {
            AddTool(compiler, "MAKE", toolFile.GetFullPath());
        }
    }
}
Example #7
0
CompilersFoundDlg::CompilersFoundDlg(wxWindow* parent, const ICompilerLocator::CompilerVec_t& compilers)
    : CompilersFoundDlgBase(parent)
{
    m_allCompilers = compilers;

    // Replace the model with a custom one
    unsigned int colCount = m_dataviewModel->GetColCount();
    m_dataviewModel = new MyCompilersFoundModel(this);
    m_dataviewModel->SetColCount(colCount);
    m_dataview->AssociateModel(m_dataviewModel.get());

    // Add the categories
    std::map<wxString, wxDataViewItem> categories;
    for(size_t i = 0; i < compilers.size(); ++i) {
        if(categories.count(compilers.at(i)->GetCompilerFamily()) == 0) {
            wxVector<wxVariant> cols;
            cols.push_back(compilers.at(i)->GetCompilerFamily());
            wxDataViewItem item = m_dataviewModel->AppendItem(wxDataViewItem(0), cols);
            categories.insert(std::make_pair(compilers.at(i)->GetCompilerFamily(), item));
        }
    }

    for(size_t i = 0; i < compilers.size(); ++i) {
        CompilerPtr compiler = compilers.at(i);
        wxDataViewItem parent = categories.find(compiler->GetCompilerFamily())->second;
        wxVector<wxVariant> cols;
        cols.push_back(compiler->GetName());
        cols.push_back(compiler->GetInstallationPath());
        m_dataviewModel->AppendItem(parent, cols, new CompilersFoundDlgItemData(compiler));
        if(m_defaultCompilers.count(compiler->GetCompilerFamily()) == 0) {
            compiler->SetIsDefault(true); // Per family
            m_defaultCompilers.insert(std::make_pair(compiler->GetCompilerFamily(), compiler));
            MSWUpdateToolchain(compiler);
        }
    }

    std::map<wxString, wxDataViewItem>::iterator iter = categories.begin();
    for(; iter != categories.end(); ++iter) {
        m_dataview->Expand(iter->second);
    }
    SetName("CompilersFoundDlg");
    WindowAttrManager::Load(this);
}
Example #8
0
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() );
}
Example #9
0
void CompilerMainPage::OnRenameCompiler(wxCommandEvent& event)
{
    int selection = m_listBoxCompilers->GetSelection();
    if(selection == wxNOT_FOUND) return;

    wxString newName =
        ::wxGetTextFromUser(_("New Compiler Name"), _("Rename Compiler"), m_listBoxCompilers->GetStringSelection());
    if(newName.IsEmpty()) return;

    CompilerPtr compiler = BuildSettingsConfigST::Get()->GetCompiler(m_listBoxCompilers->GetStringSelection());
    if(!compiler) return;

    // Delete the old compiler
    BuildSettingsConfigST::Get()->DeleteCompiler(compiler->GetName());

    // Create new one with differet name
    compiler->SetName(newName);
    BuildSettingsConfigST::Get()->SetCompiler(compiler);

    // Reload the content
    LoadCompilers();
}
Example #10
0
bool CompilersFoundDlg::IsDefaultCompiler(CompilerPtr compiler) const
{
    if(m_defaultCompilers.count(compiler->GetCompilerFamily()) == 0) return false;
    CompilerPtr defaultCompiler = m_defaultCompilers.find(compiler->GetCompilerFamily())->second;
    return defaultCompiler->GetName() == compiler->GetName();
}
Example #11
0
NewProjectWizard::NewProjectWizard(wxWindow* parent, const clNewProjectEvent::Template::Vec_t& additionalTemplates)
    : NewProjectWizardBase(parent)
{
    m_additionalTemplates = additionalTemplates;
    NewProjectDlgData info;
    EditorConfigST::Get()->ReadObject(wxT("NewProjectDlgData"), &info);

    NewProjImgList images;
    // Get list of project templates
    wxImageList *lstImages (NULL);
    GetProjectTemplateList(PluginManager::Get(), m_list, &m_mapImages, &lstImages);
    wxDELETE(lstImages);

    // Populate the dataview model
    m_dataviewTemplatesModel->Clear();
    std::map<wxString, wxDataViewItem> categoryMap;
    
    // list of compilers
    wxArrayString compilerChoices;
    
    // list of debuggers
    wxArrayString debuggerChoices;
    
    // Place the plugins on top
    for ( size_t i=0; i<m_additionalTemplates.size(); ++i ) {
        
        // Add the category if not exists
        const clNewProjectEvent::Template& newTemplate = m_additionalTemplates.at(i);
        if ( !newTemplate.m_toolchain.IsEmpty() ) {
            compilerChoices.Add( newTemplate.m_toolchain );
        }
        
        if ( !newTemplate.m_debugger.IsEmpty() ) {
            debuggerChoices.Add( newTemplate.m_debugger );
        }
        
        wxString category = newTemplate.m_category;
        if ( categoryMap.count( category ) == 0 ) {
            wxVector<wxVariant> cols;
            wxBitmap bmp = wxXmlResource::Get()->LoadBitmap( newTemplate.m_categoryPng );
            if ( !bmp.IsOk() ) {
                bmp = images.Bitmap("gear16");
            }
            cols.push_back( DVTemplatesModel::CreateIconTextVariant(category, bmp) );
            categoryMap[category] = m_dataviewTemplatesModel->AppendItem(wxDataViewItem(0), cols);
        }
        
        {
            wxVector<wxVariant> cols;
            wxBitmap bmp = wxXmlResource::Get()->LoadBitmap( newTemplate.m_templatePng );
            if ( !bmp.IsOk() ) {
                bmp = images.Bitmap("gear16");
            }
            cols.push_back( DVTemplatesModel::CreateIconTextVariant(newTemplate.m_template, bmp) );
            m_dataviewTemplatesModel->AppendItem(categoryMap[category], cols, new NewProjectClientData(NULL, newTemplate.m_template));
        }
    }

    wxDataViewItem selection;
    std::list<ProjectPtr>::iterator iter = m_list.begin();
    for (; iter != m_list.end(); ++iter) {
        wxVector<wxVariant> cols;
        wxString internalType = (*iter)->GetProjectInternalType();
        if (internalType.IsEmpty()) internalType = _("Others");

        if ( categoryMap.count( internalType ) == 0 ) {
            cols.clear();
            wxIcon icn;
            icn.CopyFromBitmap( images.Bitmap("gear16") );
            wxDataViewIconText ict(internalType, icn);
            wxVariant v;
            v << ict;
            cols.push_back( v );
            categoryMap[internalType] = m_dataviewTemplatesModel->AppendItem(wxDataViewItem(0), cols);
        }

        wxString imgId = (*iter)->GetProjectIconName();

        cols.clear();
        wxIcon icn;
        icn.CopyFromBitmap( images.Bitmap(imgId) );
        wxDataViewIconText ict((*iter)->GetName(), icn);
        wxVariant v;
        v << ict;

        cols.push_back( v );
        wxDataViewItem item = m_dataviewTemplatesModel->AppendItem(categoryMap[internalType], cols, new NewProjectClientData( *iter ) );
        if ( (*iter)->GetName() == info.GetLastSelection() ) {
            selection = item;
        }
    }
    
    // Aet list of compilers from configuration file
    BuildSettingsConfigCookie cookie;
    CompilerPtr cmp = BuildSettingsConfigST::Get()->GetFirstCompiler(cookie);
    while (cmp) {
        compilerChoices.Add(cmp->GetName());
        cmp = BuildSettingsConfigST::Get()->GetNextCompiler(cookie);
    }
    
    m_choiceCompiler->Append( compilerChoices );
    if (compilerChoices.IsEmpty() == false) {
        m_choiceCompiler->SetSelection(0);
    }

    m_textCtrlProjectPath->SetValue( WorkspaceST::Get()->GetWorkspaceFileName().GetPath());

    // Get list of debuggers
    wxArrayString knownDebuggers = DebuggerMgr::Get().GetAvailableDebuggers();
    debuggerChoices.insert( debuggerChoices.end(), knownDebuggers.begin(), knownDebuggers.end());
    m_choiceDebugger->Append( debuggerChoices );
    if ( !m_choiceDebugger->IsEmpty() ) {
        m_choiceDebugger->SetSelection( 0 );
    }

    m_cbSeparateDir->SetValue( info.GetFlags() & NewProjectDlgData::NpSeparateDirectory );

    // Make sure the old selection is restored
    if ( selection.IsOk() ) {
        m_dataviewTemplates->Select(selection);
        m_dataviewTemplates->EnsureVisible(selection);
        NewProjectClientData* cd = dynamic_cast<NewProjectClientData*>( m_dataviewTemplatesModel->GetClientObject(selection) );
        if ( cd ) {
            m_projectData.m_srcProject = cd->getProject();
        }
    }

    UpdateProjectPage();
}
Example #12
0
NewProjectWizard::NewProjectWizard(wxWindow* parent, const clNewProjectEvent::Template::Vec_t& additionalTemplates)
    : NewProjectWizardBase(parent)
    , m_selectionMade(false)
{
    m_additionalTemplates = additionalTemplates;
    NewProjectDlgData info;
    EditorConfigST::Get()->ReadObject(wxT("NewProjectDlgData"), &info);

    NewProjImgList images;

    // Get list of project templates (bot the installed ones + user)
    GetProjectTemplateList(m_list);

    // Populate the dataview model
    m_dataviewTemplatesModel->Clear();
    std::map<wxString, wxDataViewItem> categoryMap;
    std::map<wxString, wxStringSet_t> projectsPerCategory;

    // list of compilers
    wxArrayString compilerChoices;

    // list of debuggers
    wxArrayString debuggerChoices;

    // Place the plugins on top
    for(size_t i = 0; i < m_additionalTemplates.size(); ++i) {

        // Add the category if not exists
        const clNewProjectEvent::Template& newTemplate = m_additionalTemplates.at(i);
        if(!newTemplate.m_toolchain.IsEmpty()) {
            compilerChoices.Add(newTemplate.m_toolchain);
        }

        if(!newTemplate.m_debugger.IsEmpty()) {
            debuggerChoices.Add(newTemplate.m_debugger);
        }

        wxString category = newTemplate.m_category;
        if(categoryMap.count(category) == 0) {
            wxVector<wxVariant> cols;
            wxBitmap bmp = wxXmlResource::Get()->LoadBitmap(newTemplate.m_categoryPng);
            if(!bmp.IsOk()) {
                bmp = images.Bitmap("gear16");
            }
            cols.push_back(DVTemplatesModel::CreateIconTextVariant(category, bmp));
            categoryMap[category] = m_dataviewTemplatesModel->AppendItem(wxDataViewItem(0), cols);
            projectsPerCategory.insert(std::make_pair(category, wxStringSet_t()));
        }

        {
            wxString name = newTemplate.m_template;
            if(projectsPerCategory[category].count(name)) {
                // already exists
                continue;
            }
            projectsPerCategory[category].insert(name); // add it to the unique list

            wxVector<wxVariant> cols;
            wxBitmap bmp = wxXmlResource::Get()->LoadBitmap(newTemplate.m_templatePng);
            if(!bmp.IsOk()) {
                bmp = images.Bitmap("gear16");
            }
            cols.push_back(DVTemplatesModel::CreateIconTextVariant(newTemplate.m_template, bmp));
            m_dataviewTemplatesModel->AppendItem(categoryMap[category], cols,
                new NewProjectClientData(NULL, newTemplate.m_template, true, newTemplate.m_allowSeparateFolder));
        }
    }

    wxDataViewItem selection;
    std::list<ProjectPtr>::iterator iter = m_list.begin();
    for(; iter != m_list.end(); ++iter) {
        wxVector<wxVariant> cols;
        wxString internalType = (*iter)->GetProjectInternalType();
        if(internalType.IsEmpty()) internalType = "Others";

        // Add the category node if needed
        if(categoryMap.count(internalType) == 0) {
            cols.clear();
            wxIcon icn;
            icn.CopyFromBitmap(images.Bitmap("gear16"));
            wxDataViewIconText ict(internalType, icn);
            wxVariant v;
            v << ict;
            cols.push_back(v);
            categoryMap[internalType] = m_dataviewTemplatesModel->AppendItem(wxDataViewItem(0), cols);
            projectsPerCategory.insert(std::make_pair(internalType, wxStringSet_t()));
        }

        wxString imgId = (*iter)->GetProjectIconName();
        wxBitmap bmp = images.Bitmap(imgId);
        // Allow the user to override it

        // Remove the entry
        if(projectsPerCategory[internalType].count((*iter)->GetName())) {
            // already exists
            continue;
        }
        projectsPerCategory[internalType].insert((*iter)->GetName()); // add it to the unique list

        cols.clear();
        wxIcon icn;
        icn.CopyFromBitmap(bmp);
        wxDataViewIconText ict((*iter)->GetName(), icn);
        wxVariant v;
        v << ict;

        cols.push_back(v);
        wxDataViewItem item =
            m_dataviewTemplatesModel->AppendItem(categoryMap[internalType], cols, new NewProjectClientData(*iter));
        if((*iter)->GetName() == info.GetLastSelection()) {
            selection = item;
        }
    }

    // Get list of compilers from configuration file
    BuildSettingsConfigCookie cookie;
    CompilerPtr cmp = BuildSettingsConfigST::Get()->GetFirstCompiler(cookie);
    while(cmp) {
        compilerChoices.Add(cmp->GetName());
        cmp = BuildSettingsConfigST::Get()->GetNextCompiler(cookie);
    }

    m_choiceCompiler->Append(compilerChoices);
    if(compilerChoices.IsEmpty() == false) {
        m_choiceCompiler->SetSelection(0);
    }

    m_textCtrlProjectPath->SetValue(clCxxWorkspaceST::Get()->GetWorkspaceFileName().GetPath());

    // Get list of debuggers
    wxArrayString knownDebuggers = DebuggerMgr::Get().GetAvailableDebuggers();
    debuggerChoices.insert(debuggerChoices.end(), knownDebuggers.begin(), knownDebuggers.end());
    m_choiceDebugger->Append(debuggerChoices);
    if(!m_choiceDebugger->IsEmpty()) {
        m_choiceDebugger->SetSelection(0);
    }

    {
        // build system
        std::list<wxString> builders;
        wxArrayString knownBuilders;
        BuildManagerST::Get()->GetBuilders(builders);
        std::for_each(
            builders.begin(), builders.end(), [&](const wxString& builderName) { knownBuilders.Add(builderName); });
        m_choiceBuildSystem->Append(knownBuilders);
        if(!m_choiceBuildSystem->IsEmpty()) {
            m_choiceBuildSystem->SetSelection(0);
        }
    }

    m_cbSeparateDir->SetValue(info.GetFlags() & NewProjectDlgData::NpSeparateDirectory);

    // Make sure the old selection is restored
    if(selection.IsOk()) {
        m_dataviewTemplates->Select(selection);
        m_dataviewTemplates->EnsureVisible(selection);
        NewProjectClientData* cd =
            dynamic_cast<NewProjectClientData*>(m_dataviewTemplatesModel->GetClientObject(selection));
        if(cd) {
            m_projectData.m_srcProject = cd->getProject();
        }
    }

    UpdateProjectPage();
}
void BuildSettingsConfig::SetCompiler(CompilerPtr cmp)
{
    wxXmlNode *node = XmlUtils::FindFirstByTagName(m_doc->GetRoot(), wxT("Compilers"));
    if(node) {
        wxXmlNode *oldCmp = NULL;
        wxXmlNode *child = node->GetChildren();
        while(child) {
            if(child->GetName() == wxT("Compiler") && XmlUtils::ReadString(child, wxT("Name")) == cmp->GetName()) {
                oldCmp = child;
                break;
            }
            child = child->GetNext();
        }
        if(oldCmp) {
            node->RemoveChild(oldCmp);
            delete oldCmp;
        }
        node->AddChild(cmp->ToXml());

    } else {
        wxXmlNode *node = new wxXmlNode(NULL, wxXML_ELEMENT_NODE, wxT("Compilers"));
        m_doc->GetRoot()->AddChild(node);
        node->AddChild(cmp->ToXml());
    }

    m_doc->Save(m_fileName.GetFullPath());
}
void AdvancedDlg::OnAddExistingCompiler()
{
    wxString folder = ::wxDirSelector(_("Select the compiler folder"));
    if(folder.IsEmpty()) {
        return;
    }

    CompilerPtr cmp = m_compilersDetector.Locate(folder);
    if(cmp) {
        // We found new compiler
        // Prompt the user to give it a name
        while(true) {
            wxString name =
                ::wxGetTextFromUser(_("Set a name to the compiler"), _("New compiler found!"), cmp->GetName());
            if(name.IsEmpty()) {
                return;
            }
            // Add the compiler
            if(BuildSettingsConfigST::Get()->IsCompilerExist(name)) {
                continue;
            }
            cmp->SetName(name);
            break;
        }

        // Save the new compiler
        BuildSettingsConfigST::Get()->SetCompiler(cmp);

        // Reload the dialog
        LoadCompilers();
    }
}
Example #15
0
BuildConfig::BuildConfig(wxXmlNode* node)
    : m_commonConfig(node)
    , m_useSeparateDebugArgs(false)
    , m_pchInCommandLine(false)
    , m_clangC11(false)
    , m_clangC14(false)
    , m_isGUIProgram(false)
    , m_isProjectEnabled(true)
    , m_pchPolicy(BuildConfig::kPCHPolicyReplace)
{
    if(node) {
        m_name = XmlUtils::ReadString(node, wxT("Name"));
        m_compilerType = XmlUtils::ReadString(node, wxT("CompilerType"));
        m_debuggerType = XmlUtils::ReadString(node, wxT("DebuggerType"));
        m_projectType = XmlUtils::ReadString(node, wxT("Type"));
        m_buildCmpWithGlobalSettings =
            XmlUtils::ReadString(node, wxT("BuildCmpWithGlobalSettings"), APPEND_TO_GLOBAL_SETTINGS);
        m_buildLnkWithGlobalSettings =
            XmlUtils::ReadString(node, wxT("BuildLnkWithGlobalSettings"), APPEND_TO_GLOBAL_SETTINGS);
        m_buildResWithGlobalSettings =
            XmlUtils::ReadString(node, wxT("BuildResWithGlobalSettings"), APPEND_TO_GLOBAL_SETTINGS);

        wxXmlNode* completion = XmlUtils::FindFirstByTagName(node, wxT("Completion"));
        if(completion) {
            wxXmlNode* search_paths = XmlUtils::FindFirstByTagName(completion, wxT("SearchPaths"));
            if(search_paths) {
                m_ccSearchPaths = search_paths->GetNodeContent();
                m_ccSearchPaths.Trim().Trim(false);
            }

            wxXmlNode* clang_pp = XmlUtils::FindFirstByTagName(completion, wxT("ClangPP"));
            if(clang_pp) {
                m_clangPPFlags = clang_pp->GetNodeContent();
                m_clangPPFlags.Trim().Trim(false);
            }

            wxXmlNode* clang_cmp_flags = XmlUtils::FindFirstByTagName(completion, wxT("ClangCmpFlags"));
            if(clang_cmp_flags) {
                m_clangCmpFlags = clang_cmp_flags->GetNodeContent();
                m_clangCmpFlags.Trim().Trim(false);
            }

            wxXmlNode* clang_c_cmp_flags = XmlUtils::FindFirstByTagName(completion, wxT("ClangCmpFlagsC"));
            if(clang_c_cmp_flags) {
                m_clangCmpFlagsC = clang_c_cmp_flags->GetNodeContent();
                m_clangCmpFlagsC.Trim().Trim(false);
            }

            wxXmlNode* clang_pch = XmlUtils::FindFirstByTagName(completion, wxT("ClangPCH"));
            if(clang_pch) {
                m_ccPCH = clang_pch->GetNodeContent();
                m_ccPCH.Trim().Trim(false);
            }

            m_clangC11 = XmlUtils::ReadBool(completion, wxT("EnableCpp11"));
            m_clangC14 = XmlUtils::ReadBool(completion, wxT("EnableCpp14"));
        }

        wxXmlNode* compile = XmlUtils::FindFirstByTagName(node, wxT("Compiler"));
        if(compile) {
            m_compilerRequired = XmlUtils::ReadBool(compile, wxT("Required"), true);
            m_precompiledHeader = XmlUtils::ReadString(compile, wxT("PreCompiledHeader"));
            m_pchInCommandLine = XmlUtils::ReadBool(compile, wxT("PCHInCommandLine"), false);
            m_pchCompileFlags = XmlUtils::ReadString(compile, wxT("PCHFlags"));
            m_pchPolicy = (ePCHPolicy)XmlUtils::ReadLong(compile, "PCHFlagsPolicy", m_pchPolicy);
        }

        wxXmlNode* linker = XmlUtils::FindFirstByTagName(node, wxT("Linker"));
        if(linker) {
            m_linkerRequired = XmlUtils::ReadBool(linker, wxT("Required"), true);
        }

        wxXmlNode* resCmp = XmlUtils::FindFirstByTagName(node, wxT("ResourceCompiler"));
        if(resCmp) {
            m_isResCmpNeeded = XmlUtils::ReadBool(resCmp, wxT("Required"), true);
        }

        // read the postbuild commands
        wxXmlNode* debugger = XmlUtils::FindFirstByTagName(node, wxT("Debugger"));
        m_isDbgRemoteTarget = false;

        if(debugger) {
            m_isDbgRemoteTarget = XmlUtils::ReadBool(debugger, wxT("IsRemote"));
            m_dbgHostName = XmlUtils::ReadString(debugger, wxT("RemoteHostName"));
            m_dbgHostPort = XmlUtils::ReadString(debugger, wxT("RemoteHostPort"));
            m_debuggerPath = XmlUtils::ReadString(debugger, wxT("DebuggerPath"));
            m_isDbgRemoteExtended = XmlUtils::ReadBool(debugger, wxT("IsExtended"));

            wxXmlNode* child = debugger->GetChildren();
            while(child) {
                if(child->GetName() == wxT("StartupCommands")) {
                    m_debuggerStartupCmds = child->GetNodeContent();

                } else if(child->GetName() == wxT("PostConnectCommands")) {
                    m_debuggerPostRemoteConnectCmds = child->GetNodeContent();

                } else if(child->GetName() == "DebuggerSearchPaths") {
                    wxArrayString searchPaths = ::wxStringTokenize(child->GetNodeContent(), "\r\n", wxTOKEN_STRTOK);
                    m_debuggerSearchPaths.swap(searchPaths);
                }

                child = child->GetNext();
            }
        }

        // read the prebuild commands
        wxXmlNode* preBuild = XmlUtils::FindFirstByTagName(node, wxT("PreBuild"));
        if(preBuild) {
            wxXmlNode* child = preBuild->GetChildren();
            while(child) {
                if(child->GetName() == wxT("Command")) {
                    bool enabled = XmlUtils::ReadBool(child, wxT("Enabled"));

                    BuildCommand cmd(child->GetNodeContent(), enabled);
                    m_preBuildCommands.push_back(cmd);
                }
                child = child->GetNext();
            }
        }
        // read the postbuild commands
        wxXmlNode* postBuild = XmlUtils::FindFirstByTagName(node, wxT("PostBuild"));
        if(postBuild) {
            wxXmlNode* child = postBuild->GetChildren();
            while(child) {
                if(child->GetName() == wxT("Command")) {
                    bool enabled = XmlUtils::ReadBool(child, wxT("Enabled"));
                    BuildCommand cmd(child->GetNodeContent(), enabled);
                    m_postBuildCommands.push_back(cmd);
                }
                child = child->GetNext();
            }
        }

        SetEnvVarSet(USE_WORKSPACE_ENV_VAR_SET);
        SetDbgEnvSet(USE_GLOBAL_SETTINGS);

        // read the environment page
        wxXmlNode* envNode = XmlUtils::FindFirstByTagName(node, wxT("Environment"));
        if(envNode) {
            SetEnvVarSet(XmlUtils::ReadString(envNode, wxT("EnvVarSetName")));
            SetDbgEnvSet(XmlUtils::ReadString(envNode, wxT("DbgSetName")));
            m_envvars = envNode->GetNodeContent();
        }

        wxXmlNode* customBuild = XmlUtils::FindFirstByTagName(node, wxT("CustomBuild"));
        if(customBuild) {
            m_enableCustomBuild = XmlUtils::ReadBool(customBuild, wxT("Enabled"), false);
            wxXmlNode* child = customBuild->GetChildren();
            while(child) {
                if(child->GetName() == wxT("BuildCommand")) {
                    m_customBuildCmd = child->GetNodeContent();
                } else if(child->GetName() == wxT("CleanCommand")) {
                    m_customCleanCmd = child->GetNodeContent();
                } else if(child->GetName() == wxT("RebuildCommand")) {
                    m_customRebuildCmd = child->GetNodeContent();
                } else if(child->GetName() == wxT("SingleFileCommand")) {
                    m_singleFileBuildCommand = child->GetNodeContent();
                } else if(child->GetName() == wxT("PreprocessFileCommand")) {
                    m_preprocessFileCommand = child->GetNodeContent();
                } else if(child->GetName() == wxT("WorkingDirectory")) {
                    m_customBuildWorkingDir = child->GetNodeContent();
                } else if(child->GetName() == wxT("ThirdPartyToolName")) {
                    m_toolName = child->GetNodeContent();
                } else if(child->GetName() == wxT("MakefileGenerationCommand")) {
                    m_makeGenerationCommand = child->GetNodeContent();
                } else if(child->GetName() == wxT("Target")) {
                    wxString target_name = child->GetPropVal(wxT("Name"), wxT(""));
                    wxString target_cmd = child->GetNodeContent();
                    if(target_name.IsEmpty() == false) {
                        m_customTargets[target_name] = target_cmd;
                    }
                }
                child = child->GetNext();
            }
        } else {
            m_enableCustomBuild = false;
        }

        wxXmlNode* customPreBuild = XmlUtils::FindFirstByTagName(node, wxT("AdditionalRules"));
        if(customPreBuild) {
            wxXmlNode* child = customPreBuild->GetChildren();
            while(child) {
                if(child->GetName() == wxT("CustomPreBuild")) {
                    m_customPreBuildRule = child->GetNodeContent();
                    m_customPreBuildRule.Trim().Trim(false);

                } else if(child->GetName() == wxT("CustomPostBuild")) {
                    m_customPostBuildRule = child->GetNodeContent();
                    m_customPostBuildRule.Trim().Trim(false);
                }
                child = child->GetNext();
            }
        }

        wxXmlNode* general = XmlUtils::FindFirstByTagName(node, wxT("General"));
        if(general) {
            m_outputFile = XmlUtils::ReadString(general, wxT("OutputFile"));
            m_intermediateDirectory = XmlUtils::ReadString(general, wxT("IntermediateDirectory"), wxT("."));
            m_command = XmlUtils::ReadString(general, wxT("Command"));
            m_commandArguments = XmlUtils::ReadString(general, wxT("CommandArguments"));
            m_workingDirectory = XmlUtils::ReadString(general, wxT("WorkingDirectory"), wxT("."));
            m_pauseWhenExecEnds = XmlUtils::ReadBool(general, wxT("PauseExecWhenProcTerminates"), true);
            m_useSeparateDebugArgs = XmlUtils::ReadBool(general, wxT("UseSeparateDebugArgs"), false);
            m_debugArgs = XmlUtils::ReadString(general, wxT("DebugArguments"));
            m_isGUIProgram = XmlUtils::ReadBool(general, "IsGUIProgram", false);
            m_isProjectEnabled = XmlUtils::ReadBool(general, "IsEnabled", true);
        }

    } else {

        // create default project settings
        m_commonConfig.SetCompileOptions(wxT("-g -Wall"));
        m_commonConfig.SetLinkOptions(wxT("-O0"));
        m_commonConfig.SetLibPath(wxT(".;Debug"));

        m_name = wxT("Debug");
        m_compilerRequired = true;
        m_linkerRequired = true;
        m_intermediateDirectory = wxT("./Debug");
        m_workingDirectory = wxT("./Debug");
        m_projectType = Project::EXECUTABLE;
        m_enableCustomBuild = false;
        m_customBuildCmd = wxEmptyString;
        m_customCleanCmd = wxEmptyString;
        m_isResCmpNeeded = false;
        m_customPostBuildRule = wxEmptyString;
        m_customPreBuildRule = wxEmptyString;
        m_makeGenerationCommand = wxEmptyString;
        m_toolName = wxEmptyString;
        m_singleFileBuildCommand = wxEmptyString;
        m_preprocessFileCommand = wxEmptyString;
        m_debuggerStartupCmds = wxEmptyString;
        m_debuggerPostRemoteConnectCmds = wxEmptyString;
        m_isDbgRemoteExtended = false;
        m_isDbgRemoteTarget = false;
        m_useSeparateDebugArgs = false;
        m_debugArgs = wxEmptyString;

        SetEnvVarSet(wxT("<Use Workspace Settings>"));
        SetDbgEnvSet(wxT("<Use Global Settings>"));

        BuildSettingsConfigCookie cookie;
        CompilerPtr cmp = BuildSettingsConfigST::Get()->GetFirstCompiler(cookie);
        if(cmp) {
            m_compilerType = cmp->GetName();
        }
        wxArrayString dbgs = DebuggerMgr::Get().GetAvailableDebuggers();
        if(dbgs.GetCount() > 0) {
            m_debuggerType = dbgs.Item(0);
        }
        m_buildCmpWithGlobalSettings = APPEND_TO_GLOBAL_SETTINGS;
        m_buildLnkWithGlobalSettings = APPEND_TO_GLOBAL_SETTINGS;
        m_buildResWithGlobalSettings = APPEND_TO_GLOBAL_SETTINGS;
    }
}