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

发布于 2024-08-22 14:15:16 字数 209 浏览 3 评论 0原文

我正在使用一个不常见的 C 编译器和 Eclipse CDT。我有一个很好的 make 文件设置,但我希望 IDE 与编译器的错误/警告输出集成。

有谁知道我可以采取哪些步骤来编写一个插件来解析/支持我的编译器输出?我认为这应该很容易,但在弄清楚从哪里开始方面存在进入障碍。如果 Eclipse 能让我做 New -> 就好了编译器错误解析器插件或类似的东西。

谢谢

I'm using an uncommon C compiler with Eclipse CDT. I have a make file setup which is nice, but I'd like IDE integration with the error / warning output of my compiler.

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.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

不必了 2024-08-29 14:15:16

事情没那么简单...

首先确保您安装了 Eclipse PDE(插件开发环境)和 CDT SDK。如果没有,那么您需要告诉 Eclipse 下载它们(帮助 -> 安装新软件)。

然后,创建一个新的插件项目。在其“扩展”选项卡中,针对点 org.eclipse.cdt.core.ErrorParser 添加新扩展。然后您将必须编写一些 java 代码来实际实现它。幸运的是,偏微分方程使得元工作相对简单。您将类的名称放入相应的框中,然后单击“类*”超链接,它将为您创建一个骨架类。

我建议您获取 CDT 的源代码并查看 GCCErrorParser.java,作为您必须执行的各种操作的说明。

最后,当您准备好测试它时,设置 Eclipse 应用程序类型的调试配置。 (这将生成 Eclipse 的第二个实例;它必须使用不同的工作台。)进入 C 项目的属性、设置面板、错误解析器选项卡并打开闪亮的新错误解析器。

It's not quite that simple...

First of all make sure you have the Eclipse PDE (Plug-in Development Environment) and CDT SDK installed. If not then you'll need to tell Eclipse to download them (Help -> Install New Software).

Then, create a new Plug-In project. In its Extensions tab, add a new extension against point org.eclipse.cdt.core.ErrorParser. You will then have to write some java code to actually implement it. Fortunately the PDE makes the meta-work relatively straightforward; 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.

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.

Finally, when you're ready to test it, set up a debug configuration of type 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.

爱的那么颓废 2024-08-29 14:15:16

在 Eclipse CDT 7.0.1 中,这非常简单。只需添加一个新的错误解析器
窗口 -> 下首选项-> C/C++ 构建 ->设置
并添加包含 3 组的正则表达式:文件名、行号和错误描述。

例如,对于 Visual Studio 编译器,正则表达式将为:

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

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

In Eclipse CDT 7.0.1 it's pretty simple. 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.

For example, for Visual Studio compiler regexp will be:

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

$1 - filename
$2 - line number
$3 - error description
不…忘初心 2024-08-29 14:15:16

IBM 发布了有关如何编写自己的 CDT 解析器的分步指南,可使用 此处

用于未来校对的相关谷歌搜索应该是:
https://www.google.com/search?q=ibm+eclipse+write+cdt+parser&oq=ibm+eclipse+write+cdt+error+parser

IBM has published a step-by-step guide to how you can write your own CDT parser, its available here

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

Smile简单爱 2024-08-29 14:15:16

在 CDT 7 中,将包含一个正则表达式错误解析器,这将使此类事情变得更加简单。 有一些详细信息常见问题解答

CDT 7.0 直到 6 月底才会发布,但您可以尝试里程碑构建,看看它是否符合您的要求。这些可以在此处下载。您还需要有一个匹配的 Eclipse 平台里程碑版本。

In CDT 7 there is going to be a regular expression error parser included which should make this sort of thing much simpler. 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. These can be downloaded here. You'll need to have a matching milestone version of the eclipse platform too.

是你 2024-08-29 14:15:16

这有效吗?

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

文件:$1
行:$2
描述: 3 美元


斯科斯

is this working ?

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

file: $1
line: $2
desc: $3

.
srkos

水晶透心 2024-08-29 14:15:16

在 CDT 8 中,此功能不需要插件。我支持多个编译器并使用简单的正则表达式构建系统。请参阅此处的屏幕截图。您可以在将正则表达式复制到此对话框之前直接在控制台输出中测试它们。如果您需要在计算机之间移动它们,生成的解析器将存储在您的工作区中的 .metadata/.plugins/org.eclipse.cdt.core 下

In CDT 8 this functionality does not require a plugin. 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文