views:

321

answers:

2

Hi

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 --> X.h and X/*.h

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

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 !

How can i make things right ?

1) Launch custom build tool

2) Compute build process based on dependencies

+1  A: 

Don't use the custom build tool options but instead set it up as a pre-build event for the solution (this can take a general command line, just like the custom build tool). This way MSVS will not examine the generated files. As long as they are #included or listed in the solution explorer they should be compiled fine as the generation of the .h files will happen before any other compilation.

I find the custom build tool is not so useful as the pre- and post- build events in general, because of the way it expects files to be generated or modified. You might find this tool useful for other things in the future (e.g. to compress the .exe after build, to generate other dependencies correctly, to ensure files are in place etc...)

There is a nice diagram showing where to find these options in the solution properties here

jheriko
Thanks, i'll look into that. But i can't help but wonder... If i don't use rules files, will i have to modify the pre-build event every time i add or rename a .own file ?
Benoît
Not necessarily. It depends on how you write the pre-build event and the tool itself. Afaik, this is no different to the custom build tool where you have to change the filenames as well. If the tool just takes all .own and makes them into .h it should be a non-issue.
jheriko
A: 

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

  • choose to always compile files with some precise extension
  • manually skip custom build for a particular file in a particular project configuration (and visualize this decision)

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.

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

Benoît