本文整理汇总了C++中ProjectBuildTarget::GetCompilerID方法的典型用法代码示例。如果您正苦于以下问题:C++ ProjectBuildTarget::GetCompilerID方法的具体用法?C++ ProjectBuildTarget::GetCompilerID怎么用?C++ ProjectBuildTarget::GetCompilerID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProjectBuildTarget
的用法示例。
在下文中一共展示了ProjectBuildTarget::GetCompilerID方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnProjectTypeChanged
void ProjectOptionsDlg::OnProjectTypeChanged(wxCommandEvent& /*event*/)
{
ProjectBuildTarget* target = m_Project->GetBuildTarget(m_Current_Sel);
if (!target)
return;
wxComboBox* cmb = XRCCTRL(*this, "cmbProjectType", wxComboBox);
wxCheckBox* chkCH = XRCCTRL(*this, "chkCreateHex", wxCheckBox);
wxTextCtrl* txt = XRCCTRL(*this, "txtOutputFilename", wxTextCtrl);
if (!cmb || !txt || !chkCH)
return;
// Default no hex file
target->SetCreateHex(false);
chkCH->SetValue(false);
switch((TargetType)cmb->GetSelection()) {
case ttExecutable :
chkCH->Enable(true);
break;
case ttLibrary :
chkCH->Enable(false);
break;
}
Compiler* compiler = CompilerFactory::GetCompiler(target->GetCompilerID());
wxFileName fname = target->GetOutputFilename();
wxString name = fname.GetName();
wxString ext = fname.GetExt();
wxString extI = fname.GetExt();
wxString extD = fname.GetExt();
wxString libext = compiler ? compiler->GetSwitches().libExtension : FileFilters::LIBRARY_EXT; // TODO: add specialized compiler option for this
wxString execext = compiler ? compiler->GetSwitches().execExtension : FileFilters::EXECUTABLE_EXT;
switch ((TargetType)cmb->GetSelection())
{
case ttExecutable:
fname.SetExt(execext);
txt->SetValue(fname.GetFullPath());
break;
case ttLibrary:
fname.SetExt(libext);
txt->SetValue(fname.GetFullPath());
break;
}
}
示例2: UpdateCompileCommand
// Don't call this function from within the scope of:
// ClangPlugin::OnEditorHook
// ClangPlugin::OnTimer
int ClangPlugin::UpdateCompileCommand(cbEditor* ed)
{
wxString compileCommand;
ProjectFile* pf = ed->GetProjectFile();
m_UpdateCompileCommand++;
if ( m_UpdateCompileCommand > 1 )
{
// Re-entry is not allowed
m_UpdateCompileCommand--;
return 0;
}
ProjectBuildTarget* target = nullptr;
Compiler* comp = nullptr;
if (pf && pf->GetParentProject() && !pf->GetBuildTargets().IsEmpty())
{
target = pf->GetParentProject()->GetBuildTarget(pf->GetBuildTargets()[0]);
comp = CompilerFactory::GetCompiler(target->GetCompilerID());
}
cbProject* proj = (pf ? pf->GetParentProject() : nullptr);
if ( (!comp) && proj)
comp = CompilerFactory::GetCompiler(proj->GetCompilerID());
if (!comp)
{
cbProject* tmpPrj = Manager::Get()->GetProjectManager()->GetActiveProject();
if (tmpPrj)
comp = CompilerFactory::GetCompiler(tmpPrj->GetCompilerID());
}
if (!comp)
comp = CompilerFactory::GetDefaultCompiler();
if (pf && (!pf->GetBuildTargets().IsEmpty()) )
{
target = pf->GetParentProject()->GetBuildTarget(pf->GetBuildTargets()[0]);
if (pf->GetUseCustomBuildCommand(target->GetCompilerID() ))
compileCommand = pf->GetCustomBuildCommand(target->GetCompilerID()).AfterFirst(wxT(' '));
}
if (compileCommand.IsEmpty())
compileCommand = wxT("$options $includes");
CompilerCommandGenerator* gen = comp->GetCommandGenerator(proj);
if (gen)
gen->GenerateCommandLine(compileCommand, target, pf, ed->GetFilename(),
g_InvalidStr, g_InvalidStr, g_InvalidStr );
delete gen;
wxStringTokenizer tokenizer(compileCommand);
compileCommand.Empty();
wxString pathStr;
while (tokenizer.HasMoreTokens())
{
wxString flag = tokenizer.GetNextToken();
// make all include paths absolute, so clang does not choke if Code::Blocks switches directories
if (flag.StartsWith(wxT("-I"), &pathStr))
{
wxFileName path(pathStr);
if (path.Normalize(wxPATH_NORM_ALL & ~wxPATH_NORM_CASE))
flag = wxT("-I") + path.GetFullPath();
}
compileCommand += flag + wxT(" ");
}
compileCommand += GetCompilerInclDirs(comp->GetID());
m_UpdateCompileCommand--;
if (compileCommand != m_CompileCommand)
{
m_CompileCommand = compileCommand;
return 1;
}
return 0;
}
示例3: FindTargetsDebugger
void DebuggerManager::FindTargetsDebugger()
{
if (Manager::Get()->GetProjectManager()->IsLoadingOrClosing())
return;
m_activeDebugger = nullptr;
m_menuHandler->SetActiveDebugger(nullptr);
if (m_registered.empty())
{
m_menuHandler->MarkActiveTargetAsValid(false);
return;
}
ProjectManager* projectMgr = Manager::Get()->GetProjectManager();
LogManager* log = Manager::Get()->GetLogManager();
cbProject* project = projectMgr->GetActiveProject();
ProjectBuildTarget *target = nullptr;
if (project)
{
const wxString &targetName = project->GetActiveBuildTarget();
if (project->BuildTargetValid(targetName))
target = project->GetBuildTarget(targetName);
}
Compiler *compiler = nullptr;
if (!target)
{
if (project)
compiler = CompilerFactory::GetCompiler(project->GetCompilerID());
if (!compiler)
compiler = CompilerFactory::GetDefaultCompiler();
if (!compiler)
{
log->LogError(_("Can't get the compiler for the active target, nor the project, nor the default one!"));
m_menuHandler->MarkActiveTargetAsValid(false);
return;
}
}
else
{
compiler = CompilerFactory::GetCompiler(target->GetCompilerID());
if (!compiler)
{
log->LogError(wxString::Format(_("Current target '%s' doesn't have valid compiler!"),
target->GetTitle().c_str()));
m_menuHandler->MarkActiveTargetAsValid(false);
return;
}
}
wxString dbgString = compiler->GetPrograms().DBGconfig;
wxString::size_type pos = dbgString.find(wxT(':'));
wxString name, config;
if (pos != wxString::npos)
{
name = dbgString.substr(0, pos);
config = dbgString.substr(pos + 1, dbgString.length() - pos - 1);
}
if (name.empty() || config.empty())
{
log->LogError(wxString::Format(_("Current compiler '%s' doesn't have correctly defined debugger!"),
compiler->GetName().c_str()));
m_menuHandler->MarkActiveTargetAsValid(false);
return;
}
for (RegisteredPlugins::iterator it = m_registered.begin(); it != m_registered.end(); ++it)
{
PluginData &data = it->second;
if (it->first->GetSettingsName() == name)
{
ConfigurationVector &configs = data.GetConfigurations();
int index = 0;
for (ConfigurationVector::iterator itConf = configs.begin(); itConf != configs.end(); ++itConf, ++index)
{
if ((*itConf)->GetName() == config)
{
m_activeDebugger = it->first;
m_activeDebugger->SetActiveConfig(index);
m_useTargetsDefault = true;
WriteActiveDebuggerConfig(wxEmptyString, -1);
RefreshUI();
m_menuHandler->MarkActiveTargetAsValid(true);
return;
}
}
}
}
wxString targetTitle(target ? target->GetTitle() : wxT("<nullptr>"));
log->LogError(wxString::Format(_("Can't find the debugger config: '%s:%s' for the current target '%s'!"),
name.c_str(), config.c_str(),
targetTitle.c_str()));
m_menuHandler->MarkActiveTargetAsValid(false);
}
示例4: Launch
/*!
\brief Launch the OpenOCD program, and redirects standard output to the log window.
Also starts the telnet / TCL command interface.
\return 0 if success, -1 it stream output cannot be redirected. -2 if OpenOCD cannot be started.
-3 if command interface cannot be started.
*/
int OpenOCDDriver::Launch(void)
{
if (m_bStarted == true)
return -2; // Already running
cbProject *project;
project = Manager::Get()->GetProjectManager()->GetActiveProject();
wxString tgt = project->GetActiveBuildTarget();
ProjectBuildTarget *target = project->GetBuildTarget(tgt);
Compiler *actualCompiler = CompilerFactory::GetCompiler(target ? target->GetCompilerID() : project->GetCompilerID());
// Launch remote debug target (i.e OpenOCD)
wxString masterPath = actualCompiler->GetMasterPath();
while (masterPath.Last() == '\\' || masterPath.Last() == '/')
masterPath.RemoveLast();
wxString wdir;
wxString cmdline;
wdir = project ? project->GetBasePath() : _T(".");
wxString args = wdir + m_ConfigFile; //_T("openocd.cfg");
//cmdline = masterPath + wxFILE_SEP_PATH + _T("openocd") +
// wxFILE_SEP_PATH + _T("openocd.exe ") + args;
cmdline = m_ProgramPath + _T(" -f ") + args;
//TargetDebugLog(_T("Command-line: ") + cmdline);
//TargetDebugLog(_T("Working dir : ") + wdir);
m_pProcess = new PipedProcess(&m_pProcess, this, idProcess, true, wdir);
Log(_("Starting OpenOCD: "));
m_Pid = wxExecute(cmdline, wxEXEC_ASYNC, m_pProcess);
if (!m_Pid)
{
delete m_pProcess;
m_pProcess = 0;
Log(_("failed"));
return -1;
}
else if (!m_pProcess->GetOutputStream())
{
delete m_pProcess;
m_pProcess = 0;
Log(_("failed (to get GDB remote's stdin)"));
return -1;
}
else if (!m_pProcess->GetInputStream())
{
delete m_pProcess;
m_pProcess = 0;
Log(_("failed (to get GDB remote's stdout)"));
return -1;
}
else if (!m_pProcess->GetErrorStream())
{
delete m_pProcess;
m_pProcess = 0;
Log(_("failed (to get GDB remote's stderr)"));
return -1;
}
Log(_("done"));
if (m_Pid == 0)
return -1; // Failed to run program
m_bStarted = true;
// although I don't really like these do-nothing loops, we must wait a small amount of time
// for gdb to see if it really started: it may fail to load shared libs or whatever
// the reason this is added is because I had a case where gdb would error and bail out
// *while* the driver->Prepare() call was running below and hell broke loose...
volatile int i = 50;
while (i)
{
wxMilliSleep(1);
Manager::Yield();
--i;
}
if (m_bStarted == false)
return -2; // OpenOCD error
// Start telnet/TCL command interface
m_ocdint = new OpenOCDCmdInt();
bool bRet = m_ocdint->OpenConn(_T("127.0.0.1"), m_TelnetPort);
if (bRet == false)
return -3; // Could not start command interface
m_TimerPollDebugger.Start(100);
return 0;
//.........这里部分代码省略.........
示例5: OnTimer
void ClangPlugin::OnTimer(wxTimerEvent& event)
{
if (!IsAttached())
return;
const int evId = event.GetId();
if (evId == idEdOpenTimer)
{
cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
if (!ed || !IsProviderFor(ed))
return;
else if (m_Proxy.GetTranslationUnitId(ed->GetFilename()) != wxNOT_FOUND)
{
m_DiagnosticTimer.Start(DIAGNOSTIC_DELAY, wxTIMER_ONE_SHOT);
return;
}
wxString compileCommand;
ProjectFile* pf = ed->GetProjectFile();
ProjectBuildTarget* target = nullptr;
Compiler* comp = nullptr;
if (pf && pf->GetParentProject() && !pf->GetBuildTargets().IsEmpty() )
{
target = pf->GetParentProject()->GetBuildTarget(pf->GetBuildTargets()[0]);
comp = CompilerFactory::GetCompiler(target->GetCompilerID());
if (pf->GetUseCustomBuildCommand(target->GetCompilerID()))
{
compileCommand = pf->GetCustomBuildCommand(target->GetCompilerID()).AfterFirst(wxT(' '));
}
}
if (compileCommand.IsEmpty())
compileCommand = wxT("$options $includes");
cbProject* proj = (pf ? pf->GetParentProject() : nullptr);
if (!comp && proj)
comp = CompilerFactory::GetCompiler(proj->GetCompilerID());
if (!comp)
{
cbProject* tmpPrj = Manager::Get()->GetProjectManager()->GetActiveProject();
if (tmpPrj)
comp = CompilerFactory::GetCompiler(tmpPrj->GetCompilerID());
}
if (!comp)
comp = CompilerFactory::GetDefaultCompiler();
comp->GetCommandGenerator(proj)->GenerateCommandLine(compileCommand, target, pf, ed->GetFilename(),
g_InvalidStr, g_InvalidStr, g_InvalidStr );
wxStringTokenizer tokenizer(compileCommand);
compileCommand.Empty();
wxString pathStr;
while (tokenizer.HasMoreTokens())
{
wxString flag = tokenizer.GetNextToken();
// make all include paths absolute, so clang does not choke if Code::Blocks switches directories
if (flag.StartsWith(wxT("-I"), &pathStr))
{
wxFileName path(pathStr);
if (path.Normalize(wxPATH_NORM_ALL & ~wxPATH_NORM_CASE))
flag = wxT("-I") + path.GetFullPath();
}
compileCommand += flag + wxT(" ");
}
compileCommand += GetCompilerInclDirs(comp->GetID());
if (FileTypeOf(ed->GetFilename()) == ftHeader) // try to find the associated source
{
const wxString& source = GetSourceOf(ed);
if (!source.IsEmpty())
{
m_Proxy.CreateTranslationUnit(source, compileCommand);
if (m_Proxy.GetTranslationUnitId(ed->GetFilename()) != wxNOT_FOUND)
return; // got it
}
}
m_Proxy.CreateTranslationUnit(ed->GetFilename(), compileCommand);
m_DiagnosticTimer.Start(DIAGNOSTIC_DELAY, wxTIMER_ONE_SHOT);
}
else if (evId == idReparseTimer)
{
EditorManager* edMgr = Manager::Get()->GetEditorManager();
cbEditor* ed = edMgr->GetBuiltinActiveEditor();
if (!ed)
return;
if (ed != m_pLastEditor)
{
m_TranslUnitId = m_Proxy.GetTranslationUnitId(ed->GetFilename());
m_pLastEditor = ed;
}
if (m_TranslUnitId == wxNOT_FOUND)
return;
std::map<wxString, wxString> unsavedFiles;
for (int i = 0; i < edMgr->GetEditorsCount(); ++i)
{
ed = edMgr->GetBuiltinEditor(i);
if (ed && ed->GetModified())
unsavedFiles.insert(std::make_pair(ed->GetFilename(), ed->GetControl()->GetText()));
}
m_Proxy.Reparse(m_TranslUnitId, unsavedFiles);
DiagnoseEd(m_pLastEditor, dlMinimal);
}
else if (evId == idDiagnosticTimer)
{
cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
if (!ed)
return;
//.........这里部分代码省略.........
示例6: NewProjectFromUserTemplate
//.........这里部分代码省略.........
wxDir dir(path);
if (dir.HasFiles() || dir.HasSubDirs())
{
if (cbMessageBox(path + _(" already contains other files.\n"
"If you continue, files with the same names WILL BE OVERWRITTEN.\n"
"Are you sure you want to continue?"),
_("Files exist in directory"), wxICON_EXCLAMATION | wxYES_NO | wxNO_DEFAULT) != wxID_YES)
{
return 0;
}
}
wxBusyCursor busy;
wxString templ = ConfigManager::GetConfigFolder() + wxFILE_SEP_PATH + _T("UserTemplates");
templ << sep << dlg.GetSelectedUserTemplate();
if (!wxDirExists(templ))
{
#if wxCHECK_VERSION(2, 9, 0)
Manager::Get()->GetLogManager()->DebugLog(F(_T("Cannot open user-template source path '%s'!"), templ.wx_str()));
#else
Manager::Get()->GetLogManager()->DebugLog(F(_T("Cannot open user-template source path '%s'!"), templ.c_str()));
#endif
return NULL;
}
// copy files
wxString project_filename;
wxArrayString files;
wxDir::GetAllFiles(templ, &files);
int count = 0;
int total_count = files.GetCount();
for (size_t i = 0; i < files.GetCount(); ++i)
{
wxFileName dstname(files[i]);
dstname.MakeRelativeTo(templ + sep);
wxString src = files[i];
wxString dst = path + sep + dstname.GetFullPath();
// Manager::Get()->GetLogManager()->DebugLog("dst=%s, dstname=%s", dst.c_str(), dstname.GetFullPath().c_str());
if (!CreateDirRecursively(dst))
Manager::Get()->GetLogManager()->DebugLog(_T("Failed creating directory for ") + dst);
if (wxCopyFile(src, dst, true))
{
if (FileTypeOf(dst) == ftCodeBlocksProject)
project_filename = dst;
++count;
}
else
#if wxCHECK_VERSION(2, 9, 0)
Manager::Get()->GetLogManager()->DebugLog(F(_T("Failed copying %s to %s"), src.wx_str(), dst.wx_str()));
#else
Manager::Get()->GetLogManager()->DebugLog(F(_T("Failed copying %s to %s"), src.c_str(), dst.c_str()));
#endif
}
if (count != total_count)
cbMessageBox(_("Some files could not be loaded with the template..."), _("Error"), wxICON_ERROR);
else
{
// open new project
if (project_filename.IsEmpty())
cbMessageBox(_("User-template saved successfully but no project file exists in it!"));
else
{
// ask to rename the project file, if need be
wxFileName fname(project_filename);
wxString newname = wxGetTextFromUser(_("If you want, you can change the project's filename here (without extension):"), _("Change project's filename"), fname.GetName());
if (!newname.IsEmpty() && newname != fname.GetName())
{
fname.SetName(newname);
wxRenameFile(project_filename, fname.GetFullPath());
project_filename = fname.GetFullPath();
}
prj = Manager::Get()->GetProjectManager()->LoadProject(project_filename);
if(prj && !newname.IsEmpty())
{
prj->SetTitle(newname);
for (int i = 0; i < prj->GetBuildTargetsCount(); ++i)
{
ProjectBuildTarget* bt = prj->GetBuildTarget(i);
wxString outputFileName = bt->GetOutputFilename();
wxFileName outFname(outputFileName);
if (bt->GetTargetType() == ttLibrary)
{
Compiler* projectCompiler = CompilerFactory::GetCompiler(bt->GetCompilerID());
if (projectCompiler)
newname.Prepend(projectCompiler->GetSwitches().libPrefix);
}
outFname.SetName(newname);
bt->SetOutputFilename(outFname.GetFullPath());
}
Manager::Get()->GetProjectManager()->RebuildTree(); // so the tree shows the new name
CodeBlocksEvent evt(cbEVT_PROJECT_OPEN, 0, prj);
Manager::Get()->ProcessEvent(evt);
}
}
}
if (prj && pFilename)
*pFilename = prj->GetFilename();
return prj;
}