本文整理汇总了C++中Compiler::GetCompilerTool方法的典型用法代码示例。如果您正苦于以下问题:C++ Compiler::GetCompilerTool方法的具体用法?C++ Compiler::GetCompilerTool怎么用?C++ Compiler::GetCompilerTool使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Compiler
的用法示例。
在下文中一共展示了Compiler::GetCompilerTool方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetCompileFileCommand
wxArrayString DirectCommands::GetCompileFileCommand(ProjectBuildTarget* target, ProjectFile* pf)
{
wxArrayString ret;
wxArrayString retGenerated;
// is it compilable?
if (!pf->compile || pf->compilerVar.IsEmpty())
return ret;
const pfDetails& pfd = pf->GetFileDetails(target);
Compiler* compiler = target ? CompilerFactory::GetCompiler(target->GetCompilerID()) : m_pCompiler;
// wxString Object = (compiler->GetSwitches().UseFlatObjects)?pfd.object_file_flat:pfd.object_file;
wxString Object = (target->GetUseFlatObjects())?pfd.object_file_flat:pfd.object_file;
// lookup file's type
FileType ft = FileTypeOf(pf->relativeFilename);
// create output dir
if (!pfd.object_dir_native.IsEmpty() && !CreateDirRecursively(pfd.object_dir_native, 0755))
{
cbMessageBox(_("Can't create object output directory ") + pfd.object_dir_native);
}
bool isResource = ft == ftResource;
bool isHeader = ft == ftHeader;
// allowed resources under all platforms: makes sense when cross-compiling for
// windows under linux.
// and anyway, if the user is dumb enough to try to compile resources without
// having a resource compiler, (s)he deserves the upcoming build error ;)
//#ifndef __WXMSW__
// // not supported under non-win32 platforms
// if (isResource)
// return ret;
//#endif
wxString compilerCmd,source_file,tempCompilerCmd(wxEmptyString);
if (!isHeader || compiler->GetSwitches().supportsPCH)
{
const CompilerTool& tool = compiler->GetCompilerTool(isResource ? ctCompileResourceCmd : ctCompileObjectCmd, pf->file.GetExt());
// does it generate other files to compile?
for (size_t i = 0; i < pf->generatedFiles.size(); ++i)
{
AppendArray(GetCompileFileCommand(target, pf->generatedFiles[i]), retGenerated); // recurse
}
pfCustomBuild& pcfb = pf->customBuild[compiler->GetID()];
compilerCmd = pcfb.useCustomBuildCommand
? pcfb.buildCommand
: tool.command;
if (target->GetUseFullSourcePaths())
{
source_file = UnixFilename(pfd.source_file_absolute_native);
// for resource files, use short from if path because if windres bug with spaces-in-paths
if (isResource)
source_file = pf->file.GetShortPath();
}
else
source_file = pfd.source_file;
QuoteStringIfNeeded(source_file);
compiler->GenerateCommandLine(compilerCmd,
target,
pf,
source_file,
Object,
pfd.object_file_flat,
pfd.dep_file);
}
if (!compilerCmd.IsEmpty()) // my lcy 1
{
switch (compiler->GetSwitches().logging)
{
case clogFull:
ret.Add(wxString(COMPILER_SIMPLE_LOG) + compilerCmd);
break;
case clogSimple:
if (isHeader)
ret.Add(wxString(COMPILER_SIMPLE_LOG) + _("Precompiling header: ") + pfd.source_file_native);
else
ret.Add(wxString(COMPILER_SIMPLE_LOG) + _("Compiling: ") + pfd.source_file_native);
break;
default:
break;
}
AddCommandsToArray(compilerCmd, ret);
if(m_pCurrTarget->GetGenerateEachLit())
AddCommandsToArray(GenerateLitForEachObj(Object,compiler->GetPrograms().OBJDUMP),ret);
//.........这里部分代码省略.........
示例2: GetCompileFileCommand
wxArrayString DirectCommands::GetCompileFileCommand(ProjectBuildTarget* target, ProjectFile* pf) const
{
wxArrayString ret;
wxArrayString ret_generated;
// is it compilable?
if (!pf || !pf->compile)
return ret;
if (pf->compilerVar.IsEmpty())
{
Manager::Get()->GetLogManager()->DebugLog(_("Cannot resolve compiler var for project file."));
return ret;
}
Compiler* compiler = target
? CompilerFactory::GetCompiler(target->GetCompilerID())
: m_pCompiler;
if (!compiler)
{
Manager::Get()->GetLogManager()->DebugLog(_("Can't access compiler for file."));
return ret;
}
const pfDetails& pfd = pf->GetFileDetails(target);
wxString object = (compiler->GetSwitches().UseFlatObjects)
? pfd.object_file_flat : pfd.object_file;
wxString object_dir = (compiler->GetSwitches().UseFlatObjects)
? pfd.object_dir_flat_native : pfd.object_dir_native;
// create output dir
if (!object_dir.IsEmpty() && !CreateDirRecursively(object_dir, 0755))
Manager::Get()->GetLogManager()->DebugLog(_("Can't create object output directory:\n") + object_dir);
// lookup file's type
const FileType ft = FileTypeOf(pf->relativeFilename);
bool is_resource = ft == ftResource;
bool is_header = ft == ftHeader;
// allowed resources under all platforms: makes sense when cross-compiling for
// windows under linux.
// and anyway, if the user is dumb enough to try to compile resources without
// having a resource compiler, (s)he deserves the upcoming build error ;)
wxString compiler_cmd;
if (!is_header || compiler->GetSwitches().supportsPCH)
{
const CompilerTool* tool = compiler->GetCompilerTool(is_resource ? ctCompileResourceCmd : ctCompileObjectCmd, pf->file.GetExt());
// does it generate other files to compile?
for (size_t i = 0; i < pf->generatedFiles.size(); ++i)
AppendArray(GetCompileFileCommand(target, pf->generatedFiles[i]), ret_generated); // recurse
pfCustomBuild& pcfb = pf->customBuild[compiler->GetID()];
if (pcfb.useCustomBuildCommand)
compiler_cmd = pcfb.buildCommand;
else if (tool)
compiler_cmd = tool->command;
else
compiler_cmd = wxEmptyString;
wxString source_file;
if (compiler->GetSwitches().UseFullSourcePaths)
source_file = UnixFilename(pfd.source_file_absolute_native);
else
source_file = pfd.source_file;
#ifdef command_line_generation
Manager::Get()->GetLogManager()->DebugLog(F(_T("GetCompileFileCommand[1]: compiler_cmd='%s', source_file='%s', object='%s', object_dir='%s'."),
compiler_cmd.wx_str(), source_file.wx_str(), object.wx_str(), object_dir.wx_str()));
#endif
// for resource files, use short from if path because if windres bug with spaces-in-paths
if (is_resource && compiler->GetSwitches().UseFullSourcePaths)
source_file = pf->file.GetShortPath();
QuoteStringIfNeeded(source_file);
#ifdef command_line_generation
Manager::Get()->GetLogManager()->DebugLog(F(_T("GetCompileFileCommand[2]: source_file='%s'."),
source_file.wx_str()));
#endif
m_pGenerator->GenerateCommandLine(compiler_cmd,
target,
pf,
source_file,
object,
pfd.object_file_flat,
pfd.dep_file);
}
if (!is_header && compiler_cmd.IsEmpty())
{
ret.Add(COMPILER_SIMPLE_LOG + _("Skipping file (no compiler program set): ") + pfd.source_file_native );
return ret;
}
switch (compiler->GetSwitches().logging)
{
//.........这里部分代码省略.........