在 Eclipse 和 Eclipse 中使用 m4 宏爪哇
在 Java for Eclipse 中开发时,有没有办法使用 m4 宏,即。确保在 Eclipse 编译之前自动调用预处理器?
或者有人在 Eclipse 中成功使用过另一个预处理器吗?
Is there a way to use m4 macros when developing in Java for Eclipse, ie. making sure the preprocessor is automatically invoked before Eclipse compiles?
Or has anyone used another preprocessor successfully with Eclipse?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想我有办法。
我刚刚在 Windows 上的 Eclipse 中使用 C 预处理器来工作。我确信它可以适应 M4,但我确实使用 gnu CPP 的能力来创建表达文件依赖关系的 make 文件。 m4 的做法取决于您。它有一些问题。如果在预处理过程中出现错误,Eclipse 会忽略它并继续运行。此外,如果您使用“运行”构建,则一旦程序启动,预处理器的控制台输出就会消失。
由于我不懂ant,也没有时间学习,所以我的版本是基于使用Ruby作为粘合的。我用 Ruby 编写了一个小 automake,它获取上次 make 之前已触及的文件列表,过滤掉预处理文件和预处理器包含的文件,扫描未触及的预处理器文件以查看它们是否依赖于任何已更改,然后全部处理。
这些都依赖于使用 Eclipse 的“构建器”,而它似乎只在 Juno 中工作。
就我而言,该项目的设置是:
为在 java 构建器之前运行的项目设置创建一个构建器
将位置设置为:C:\Ruby192\bin\ruby.exe
将工作目录设置为 C:\Ruby192\bin\
将参数设置为:C:\preprocessors\mymake.rb ${build_project} ${build_files:acf}
这传递了项目的目录,后跟已触及的文件
将“刷新”设置为“包含所选资源的项目”和“递归包含子文件夹”
将构建选项设置为:分配控制台
运行构建器:清理后、手动构建期间和自动构建期间
请注意,根据我的简单 make,“.jpp”文件将被处理为“.java”文件
和“.jpp”文件可以#include“.jph”文件(并且仅.jph文件)
“.jph”文件也可以#include“.jph”文件并且仅包含“.jph”文件
所有这些文件都必须位于 /src/ 目录下(递归地位于 /src/ 下的目录中,这就是 eclipse 组织 java 代码和包)。
这是 Ruby 代码:
I think I have a way.
I just now got it working with the c preprocessor in eclipse on windows. I'm sure it could be adapted to M4, but I DO use gnu CPP's ability to create make files expressing the dependencies of a file. Doing that for m4 would be up to you. It has a few problems. If there's an error during preprocessing eclipse ignores it and keeps going. Also if you built with "run" the preprocessor's console output disappears as soon as the program starts.
Since I don't understand ant, and I don't have time to learn, my version is based on using Ruby for glue. I wrote a little automake in Ruby that takes a list of files that have been touched before the last make, filters out the ones that are preprocessed files, and those that are preprocessor includes, scans untouched preprocessor files to see if they depend on anything that has been changed, then processes them all.
These all depend on using Eclipse's "builders" which only seem to work in Juno.
In my case the setting for the project are:
create a builder for the project settings that runs before the java builder
set the location to: C:\Ruby192\bin\ruby.exe
set the working directory to C:\Ruby192\bin\
set the arguments to: C:\preprocessors\mymake.rb ${build_project} ${build_files:acf}
this passes the directory of the project followed by the file that have been touched
set "refresh" to "project containing the selected resource" and "recursively include subfolder"
set build options to: Allocate console
Run the builder: after clean,during manual builds, and during autobuilds
Note that according to my simple make ".jpp" files will be processed into ".java" files
and ".jpp" files can #include ".jph" files (and only .jph files)
".jph" files can also #include ".jph" files and only ".jph" files
All of these files have to be under the /src/ directory (recursively in directories under /src/ which is how eclipse organizes java code and packages).
Here's the Ruby code:
您可以在 Eclipse 项目上指定任意构建器,并对构建器进行排序,以便它在 Java 构建器运行之前执行。
要定义新的构建器,请打开项目属性(右键单击 -> 属性或 alt-enter),选择 Builders,然后选择 新...。选择程序,然后在对话框中配置构建器(希望您知道此处需要做什么)并选择“确定”。返回Builders页面,然后您可以选择新的构建器并选择向上,直到它位于Java Builder之前
You can specify an arbitrary builder on an Eclipse project, and order the builder so that it is executed before the Java builder is run.
To define the new builder, open the project properties (right click->Properties or alt-enter), select Builders then New.... Select Program, then in the dialog configure the builder (hopefully you know what needs to be done here) and select OK. Back in the Builders page you can then select your new builder and select Up until it is before the Java Builder