Eclipse 托管项目中的自定义资源构建步骤
我知道这可以使用 makefile 来完成,可惜我没有使用 makefile,而是使用 Eclipse 的“托管”C++ 项目。 :( 无论如何,这就是我想要完成的任务:
我在 Eclipse 中有一个 C++ 项目。该项目中有许多 XML 文件,它们指定有关自动生成的源文件的信息。当 XML 文件更改时,我希望执行一个自定义工具来转换它们。挑战是:
- 这些资源需要在编译项目之前构建,因为它们指定了编译中使用的源文件和头文件
- 。修改(生成头文件,因此这是为了避免不必要的重新编译,因为文件时间戳发生了更改)。
- 我希望将其包含在该项目的构建过程中,而不是
我认为将来会迁移到 CMake 的 项目。 ,但目前我正在努力凑合。
I know this can be done using a makefile, alas I am not using a makefile, but rather Eclipse's "managed" C++ project. :( In any case, this is what I'm trying to accomplish:
I have a C++ project in Eclipse. I have a number of XML files in this project that specify information about source files that are auto-generated. When the XML files change, I would like a custom tool executed to convert them. The challenges are:
- These resources need to be built prior to compiling the project since they specify source and header files used in the compilation.
- They should be built only when the XML file is modified (header files are generated, so this is to avoid needless recompilation because a file timestamp changed).
- I'd like it included as part of the build process of this project, not a separate project.
I see moving to CMake in the future, but for the time being I am trying to make do.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可以在项目属性->添加预构建命令C/C++ 构建 ->设置->构建步骤。该命令将在每次构建之前执行。
我不知道有一种内置方法可以让命令仅在修改 XML 文件时运行。如果您想要这样做,那么您可以将其设为带有 makefile 的“make”命令,该 makefile 具有单个规则,其先决条件是 XML 文件,并且调用 XML 转换命令,而不是使预构建命令本身成为 XML 转换命令。命令。
You can add a pre-build command in Project Properties -> C/C++ Build -> Settings -> Build Steps. This command will be executed before each build.
I'm not aware of a built-in way to get the command to run only when the XML file is modified. If you want that, then instead of making the pre-build command the XML-converting command itself, you can make it a "make" command with a makefile with a single rule whose prerequisite is the XML file and which calls the XML-converting command.