简体   繁体   English

Eclipse CDT自定义编译器错误解析插件

[英]Eclipse CDT Custom Compiler Error Parsing Plugin

I'm using an uncommon C compiler with Eclipse CDT. 我在Eclipse CDT中使用了一个不常见的C编译器。 I have a make file setup which is nice, but I'd like IDE integration with the error / warning output of my compiler. 我有一个make文件设置很好,但我想IDE与我的编译器的错误/警告输出集成。

Does anybody know what steps I can take to write a plugin for parsing / supporting my compilers output? 有没有人知道我可以采取哪些步骤来编写解析/支持我的编译器输出的插件? I think it should be easy but there is a barrier of entry of figuring out where to start. 我认为它应该很容易,但是要确定从哪里开始有进入的障碍。 Would be nice if Eclipse would let me do New -> Compiler Error Parser Plugin, or something like that. 如果Eclipse会让我做New - > Compiler Error Parser Plugin,或类似的东西会很好。

Thanks 谢谢

It's not quite that simple... 它不是那么简单......

First of all make sure you have the Eclipse PDE (Plug-in Development Environment) and CDT SDK installed. 首先确保安装了Eclipse PDE(插件开发环境)和CDT SDK。 If not then you'll need to tell Eclipse to download them (Help -> Install New Software). 如果没有,那么你需要告诉Eclipse下载它们(帮助 - >安装新软件)。

Then, create a new Plug-In project. 然后,创建一个新的Plug-In项目。 In its Extensions tab, add a new extension against point org.eclipse.cdt.core.ErrorParser. 在其Extensions选项卡中,针对point org.eclipse.cdt.core.ErrorParser添加新扩展。 You will then have to write some java code to actually implement it. 然后,您必须编写一些Java代码来实际实现它。 Fortunately the PDE makes the meta-work relatively straightforward; 幸运的是,PDE使元工作相对简单; you put the name of your class in the appropriate box and click on the "class*" hyperlink and it will offer to create a skeleton class for you. 您将类的名称放在相应的框中,然后单击“class *”超链接,它将为您创建一个框架类。

I suggest you grab the source code to the CDT and have a look at GCCErrorParser.java as an illustration of the sorts of things yours will have to do. 我建议你抓住CDT的源代码,看看GCCErrorParser.java,看看你需要做的各种事情。

Finally, when you're ready to test it, set up a debug configuration of type Eclipse Application. 最后,当您准备测试它时,请设置Eclipse Application类型的调试配置。 (This will spawn a second instance of Eclipse; it has to use a different workbench.) Go into the properties of your C project, Settings panel, Error Parsers tab and switch on your shiny new error parser. (这将生成Eclipse的第二个实例;它必须使用不同的工作台。)进入C项目的属性,Settings面板,Error Parsers选项卡,然后打开闪亮的新错误解析器。

In Eclipse CDT 7.0.1 it's pretty simple. 在Eclipse CDT 7.0.1中,它非常简单。 Just add a new error parser under Window -> Preferences -> C/C++ Build -> Settings and add regular expression with 3 groups: filename, linenumber and error description. 只需在Window - > Preferences - > C / C ++ Build - > Settings下添加一个新的错误解析器,并添加包含3组的正则表达式:filename,linenumber和error description。

For example, for Visual Studio compiler regexp will be: 例如,对于Visual Studio编译器,regexp将是:

(.*?)\((\d*)\)\s:\s(.*error.*)

$1 - filename
$2 - line number
$3 - error description

IBM has published a step-by-step guide to how you can write your own CDT parser, its available here IBM已经发布了有关如何编写自己的CDT解析器的分步指南,可在此处获得

Relevant google search for future proofing should be: https://www.google.com/search?q=ibm+eclipse+write+cdt+parser&oq=ibm+eclipse+write+cdt+error+parser 针对未来打样的相关谷歌搜索应该是: https//www.google.com/search?q = ibm + eclipse + write+cdt + parser &oq = ibm + eclipse + write+cdt + error + parser

In CDT 7 there is going to be a regular expression error parser included which should make this sort of thing much simpler. 在CDT 7中,将包含一个正则表达式错误解析器,它应该使这种事情变得更加简单。 There are some details on the faq . 关于常见问题的一些细节。

CDT 7.0 won't be released until the end of June, but you could try milestone builds to see if it does what you want. CDT 7.0将在6月底之前发布,但您可以尝试使用里程碑版本来查看它是否符合您的要求。 These can be downloaded here . 这些可以在这里下载。 You'll need to have a matching milestone version of the eclipse platform too. 您还需要有一个匹配的里程碑版本的eclipse平台。

is this working ? 这管用吗 ?

(.*)\((\d+)\)\s:\sError(.*)

file: $1 line: $2 desc: $3 文件:$ 1行:$ 2 desc:$ 3

. srkos srkos

In CDT 8 this functionality does not require a plugin. 在CDT 8中,此功能不需要插件。 I have support for several compilers and build systems using simple regular expressions. 我支持几个编译器并使用简单的正则表达式构建系统。 See screenshot here . 在此处查看截图。 You can test the regexes directly in the console output before copying them to this dialog. 您可以直接在控制台输出中测试正则表达式,然后再将它们复制到此对话框中。 If you need to move them between machines, the resulting parsers are stored in your workspace under .metadata/.plugins/org.eclipse.cdt.core 如果需要在机器之间移动它们,生成的解析器将存储在.metadata / .plugins / org.eclipse.cdt.core下的工作空间中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM