Author Topic: Code generation steps per file? (e.g. Qt's MOC invokation)  (Read 25462 times)

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Hi guys. Now that we're having a compiler redesign, I was thinking of this:

The Qt framework is gaining popularity, but the need to invoke MOC on each file or set of files is horribly consuming. I managed to make a workaround by creating ".moc_trigger" files and assigning them a custom compilation command. But these files are somewhat redundant since their only purpose is to make an .h file which will then be included by my .cpp files. Also, they are generated on each run, and there's no dependency management to say "Oh, the moc file is more recent than the .cpp so there's no need to create it again".

So my suggestion is to have an option for files in the project which tells the compiler that such file depends on auto-generated code, like:

Code

dialog1.cpp

[ ] Compiling this file requires one or more code generation steps.
[ Step 1] [ Add another step]
-----------------------------------------
     Dependencies:
     | dialog1.h            |  [ Add    ]
     |                      |  [ Remove ]
     |                      |
     |                      |

     Generated file(s):
     | dialog1.moc.h        |  [ Add    ]  <-  dialog1.moc.h doesn't exist yet,
     |                      |  [ Remove ]      one would have to type it in.
     |                      |
     |                      |

     (*) Use compiler:
          [ Qt4-moc  ]
     ( ) Use custom compilation command:
          [                                        ]

Generation frequency:
( ) Generate on each run
(*) Only when the dependencies are changed


It would really solve headaches regarding Qt and perhaps other projects that involve code generation (perhaps from XML or JSON? Who knows?). I know C::B can be scripted, but IMHO this would be a more robust solution.

Opinions?