在C ++项目中使用特定于域的语言文件 [英] Use domain-specific-language files inside C++ project

查看:53
本文介绍了在C ++项目中使用特定于域的语言文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用自己的图形编辑器来开发DSL。此类文件的扩展名为.own。我还有一个小的工具,可以将.own文件编译成.h文件。

I am developping a DSL with its own graphical editor. Such files have a .own extension. I also have a small tool that compiles .own files into .h files.

X.own-> Xh和X / *。h

X.own --> X.h and X/*.h

我已经编写了一个简单的.rules文件来启动这一代。

I have written a simple .rules file to launch the generation.

我的问题是以下
我的大多数源文件都包含Xh,但是X.own中的更改并不意味着生成的Xh(或任何其他生成的文件)会有所不同。生成器通过使用临时文件和文件比较来解决此问题。但是Visual Studio似乎并不知道如何处理所有这些问题。如果我将输出文件属性设置为正确的文件,则始终假定它们将被更改。如果我不这样做,它会假设它们不会成为生成它的构建过程!

My problem is the following : Most of my source files include X.h, but a change in X.own does not mean the generated X.h (or any other generated file) will be different. This is dealt with by the generator through the use of temporary files and file comparison. But Visual Studio does not seem to know how to deal with all this. If i set the "output file(s)" property to the right file(s), it always assumes they will be changed. If i don't, it generates its build process assuming they won't be !

我该如何正确处理?

1)启动自定义构建工具

1) Launch custom build tool

2)根据依赖关系计算构建过程

2) Compute build process based on dependencies

推荐答案

jheriko的答案很有趣,因为它提供了一种启动自定义工具然后生成生成依赖项的方法。但这不是很有用,因为您将失去使用自定义构建工具工具包的所有可能性,在该工具包中,您可以

jheriko's answer is interesting, because it provides a way to launch custom tool, then generate build dependencies. But it's not very usable, because you then lose all possibilities to use "custom build tools" toolkit, in which you can


  • 选择始终编译具有精确扩展名的文件

  • 手动跳过针对特定项目配置中特定文件的自定义构建(并可视化此决定)

没有办法(或者至少我没有找到)拥有全部。我发现的唯一方法是让自定义构建工具在文件更新后返回一个非零数字,并向用户显示一条消息,说明这不是错误,并邀请他启动再次建立。下次,自定义构建工具再次启动(不是最佳选择,但是我使用的工具相当快),但是没有修改任何新文件,并且使用有效的依赖项继续进行构建过程。

There is no way (or at least i have found none) to "have it all". The only way i have found is to have the custom build tool return a non-zero number when files have been updated, with a message to the user explaining that it is not an error and inviting him to launch build again. The next time, custom build tool is launched again (not optimal, but the tool i use is pretty fast) but modifies no new file, and build process goes on, using valid dependencies.

注意:上述方法不适用于Incredibuild,后者似乎忽略了项目的构建顺序。

Note : the approach described above does not work with Incredibuild, which seems to ignore project build order.

这篇关于在C ++项目中使用特定于域的语言文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆