That one last frontend feature to obsolete rebuild

Simen Kjaeraas simen.kjaras at gmail.com
Thu Mar 13 10:26:25 PDT 2008


On Wed, 12 Mar 2008 20:51:39 +0100, Gregor Richards <Richards at codu.org>  
wrote:

> Believe it or not, I'd really like to obsolete rebuild. I'd love to have  
> a tiny little script that just reads the output of [g]dmd -v and gets  
> the list of files (and everything else) from that. At this point, I'm  
> very close to being able to accomplish this feat, as the recent(ish)  
> addition of outputting every file that's imported got my 90% of the way  
> there, but there's one problem. rebuild supports nonstandard pragmas,  
> and the compiler chokes on them.
>
> I would like to see a flag (-print-unsupported-pragmas or something else  
> obscure, doesn't need to be short or simple) that changed the frontend's  
> default behavior from choking on unrecognized pragmas to printing them  
> out with the verbose output, e.g.:
> pragma	link	"(argument to the pragma)"
>
> Clearly this wouldn't work for pragmas which wrap declarations, but for  
> simple pragmas it would - and simple pragmas are all I need, and  
> probably all that most frontend-extending tools would need. With this  
> one, comparably simple change, I could scrap rebuild and write a simple  
> script that would be incapable of becoming outdated. Heck, if you'd  
> like, I could even write it and submit a patch :)
>
>   - Gregor Richards


While I agree it's not quite as elegant, couldn't

   pragma(msg, "rebuild    link\t\"argument\"");

do what you want?

To make it prettier (and ensure that things are formatted correctly) you  
could even create a function like this:

   string rebuildPragma(string type, string argument)
   {
     return "rebuild   " ~ type ~ "\t\"" ~ argument ~ "\"";
   }

and used like this:

   pragma(msg, rebuildPragma("link", "argument"));

Such a function would require another import, of course. Are there any  
other problems with such an approach?

--Simen



More information about the Digitalmars-d mailing list