www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - That one last frontend feature to obsolete rebuild

reply Gregor Richards <Richards codu.org> writes:
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
Mar 12 2008
next sibling parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
Gregor Richards 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 :)

Sounds great to me. I was pondering just the other day why Rebuild hasn't switched to using the -v output rather than embedding the entire DMD front end. So pragmas are the only thing, huh? One little thing -- I'd say just enhance -v output all pragmas. No new switch. Tools that don't need them will just ignore them, tools which do can grep for the ones they care about. --bb
Mar 12 2008
parent reply Gregor Richards <Richards codu.org> writes:
Bill Baxter wrote:
 Gregor Richards 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 :)

Sounds great to me. I was pondering just the other day why Rebuild hasn't switched to using the -v output rather than embedding the entire DMD front end. So pragmas are the only thing, huh? One little thing -- I'd say just enhance -v output all pragmas. No new switch. Tools that don't need them will just ignore them, tools which do can grep for the ones they care about. --bb

I don't quite agree, because IMHO dying on unrecognized pragmas is a good thing. e.g. I use some GCC property, then compile with DMD, and maybe I have to do something special since that pragma is unsupported. I'd rather have it tell me so I can go "d'oh! Needs version (GNU)" than just silently ignore it. - Gregor Richards
Mar 12 2008
parent reply Bill Baxter <dnewsgroup billbaxter.com> writes:
Gregor Richards wrote:
 Bill Baxter wrote:
 Gregor Richards 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 :)

Sounds great to me. I was pondering just the other day why Rebuild hasn't switched to using the -v output rather than embedding the entire DMD front end. So pragmas are the only thing, huh? One little thing -- I'd say just enhance -v output all pragmas. No new switch. Tools that don't need them will just ignore them, tools which do can grep for the ones they care about. --bb

I don't quite agree, because IMHO dying on unrecognized pragmas is a good thing. e.g. I use some GCC property, then compile with DMD, and maybe I have to do something special since that pragma is unsupported. I'd rather have it tell me so I can go "d'oh! Needs version (GNU)" than just silently ignore it.

I see. I thought they were just ignored currently. Now I understand why you require the version(build) around it. --bb
Mar 12 2008
parent BCS <BCS pathlink.com> writes:
Bill Baxter wrote:
 Gregor Richards wrote:
 
 I don't quite agree, because IMHO dying on unrecognized pragmas is a 
 good thing. e.g. I use some GCC property, then compile with DMD, and 
 maybe I have to do something special since that pragma is unsupported. 
 I'd rather have it tell me so I can go "d'oh! Needs version (GNU)" 
 than just silently ignore it.

I see. I thought they were just ignored currently. Now I understand why you require the version(build) around it. --bb

how about a -pragma-print-ignore=foobar that would print out but otherwise ignore pragma(foobar, ...)
Mar 13 2008
prev sibling parent reply "Simen Kjaeraas" <simen.kjaras gmail.com> writes:
On Wed, 12 Mar 2008 20:51:39 +0100, Gregor Richards <Richards 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
Mar 13 2008
parent Gregor Richards <Richards codu.org> writes:
Simen Kjaeraas wrote:
 On Wed, 12 Mar 2008 20:51:39 +0100, Gregor Richards <Richards 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

This is how I would have done it in the first place if I didn't have the legacy of bud compatibility. However, to maintain backwards compatibility, I can't use this method. - Gregor Richards
Mar 13 2008