本文整理汇总了C++中Compiler::GetCommandGenerator方法的典型用法代码示例。如果您正苦于以下问题:C++ Compiler::GetCommandGenerator方法的具体用法?C++ Compiler::GetCommandGenerator怎么用?C++ Compiler::GetCommandGenerator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Compiler
的用法示例。
在下文中一共展示了Compiler::GetCommandGenerator方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
//.........这里部分代码省略.........