Jump to page: 1 24  
Page
Thread overview
March 21, 2007
I used the shebang feature like this:

#!/usr/bin/env rdmd
... D code ...

Unfortunately, rdmd only works on single-file code. As soon as you try to import another file of yours, rdmd won't handle that.

So I wrote a Perl script rundmd that parses the D source looking for import directives, then does the same for all imported files, transitively (using a worklist approach). The script caches the results so it only does that minimally, after modifications. Then the script launches the proper compile command (if needed), and finally runs the produced executable.

In short, rundmd does what rdmd does but works on multi-module programs.

I suspect other people have written similar scripts, but just in case, I thought I'd ask. If people are interested, I'll be glad to comb the script a little and post it here.


Andrei
March 21, 2007
Andrei Alexandrescu (See Website For Email) wrote:

> In short, rundmd does what rdmd does but works on multi-module programs.
> 
> I suspect other people have written similar scripts, but just in case, I thought I'd ask. If people are interested, I'll be glad to comb the script a little and post it here.

Rebuild has a similar feature (-exec), but it's a program not a script.
I think build/bud also did, but I had problems with it and GDC/Tango...

Not sure how you pass runtime / program arguments over to it, though ?
But it does parse and compile all the imported modules for the program.

--anders
March 21, 2007
Anders F Björklund wrote:
> Andrei Alexandrescu (See Website For Email) wrote:
> 
>> In short, rundmd does what rdmd does but works on multi-module programs.
>>
>> I suspect other people have written similar scripts, but just in case, I thought I'd ask. If people are interested, I'll be glad to comb the script a little and post it here.
> 
> Rebuild has a similar feature (-exec), but it's a program not a script.
> I think build/bud also did, but I had problems with it and GDC/Tango...

Sounds great. Where is rebuild? (Bud aka build is easy to find on dsource.org).

> Not sure how you pass runtime / program arguments over to it, though ?
> But it does parse and compile all the imported modules for the program.

(The way I do it is simple but ambiguous - any flags that come before the program name are passed to dmd, and any stuff that comes after the program name is considered that program's arguments. The program name is the first thing without a leading "-".)

I think such a tool should be part of the standard distribution - it's very, very useful.


Andrei
March 21, 2007
Andrei Alexandrescu (See Website For Email) wrote:

>> Rebuild has a similar feature (-exec), but it's a program not a script.
>> I think build/bud also did, but I had problems with it and GDC/Tango...
> 
> Sounds great. Where is rebuild? (Bud aka build is easy to find on dsource.org).

It's part of the DSSS project: (the "D Shared Software System")
http://www.dsource.org/projects/dsss/wiki/Rebuild

I did a RPM package and manpage for it, will post them* on gdcgnu
as part of the requirements for using Tango instead of Phobos...

--anders

* See http://www.algonet.se/~afb/d/rebuild.spec for a preview
March 21, 2007
Andrei Alexandrescu (See Website For Email) wrote:

> I used the shebang feature like this:
> 
> #!/usr/bin/env rdmd
> ... D code ...
> 
> Unfortunately, rdmd only works on single-file code. As soon as you try to import another file of yours, rdmd won't handle that.

Where can I find the source code for the rdmd program, by the way ?
I seem to only find binaries for Windows and Linux, not for Mac :-)

Is it part of the back-end, or is it open source like the front-end ?

--anders
March 21, 2007
Anders F Björklund wrote:

> Andrei Alexandrescu (See Website For Email) wrote:
> 
>>> Rebuild has a similar feature (-exec), but it's a program not a script. I think build/bud also did, but I had problems with it and GDC/Tango...
>> 
>> Sounds great. Where is rebuild? (Bud aka build is easy to find on
>> dsource.org).
> 
> It's part of the DSSS project: (the "D Shared Software System") http://www.dsource.org/projects/dsss/wiki/Rebuild
> 
> I did a RPM package and manpage for it, will post them* on gdcgnu as part of the requirements for using Tango instead of Phobos...

Well, rebuild is not a requirement anymore, at least not for Windows and Linux DMD, and x86 Linux GDC as we're in the process of providing prebuilt libraries. Still a very useful tool though.

-- 
Lars Ivar Igesund
blog at http://larsivi.net
DSource, #d.tango & #D: larsivi
Dancing the Tango
March 21, 2007
Anders F Björklund wrote:
> Andrei Alexandrescu (See Website For Email) wrote:
> 
>> I used the shebang feature like this:
>>
>> #!/usr/bin/env rdmd
>> ... D code ...
>>
>> Unfortunately, rdmd only works on single-file code. As soon as you try to import another file of yours, rdmd won't handle that.
> 
> Where can I find the source code for the rdmd program, by the way ?
> I seem to only find binaries for Windows and Linux, not for Mac :-)
> 
> Is it part of the back-end, or is it open source like the front-end ?

Walter knows.

Andrei
March 21, 2007
> Where can I find the source code for the rdmd program, by the way ?
> I seem to only find binaries for Windows and Linux, not for Mac :-)
> 
> Is it part of the back-end, or is it open source like the front-end ?

Never mind, found Dave Fladebo's and Roberto Mariottini's versions
attached in the digitalmars.D.announce newsgroup... (and it was under
the free-for-all Public Domain license, so definitely "open source")

Are these the same versions that are used in the DMD distribution ?
If so, is there any chance of including the rdmd.d file used, in it.
And it looks straightforward to port over from DMD/linux to GDC/Unix.

--anders
March 21, 2007
Andrei Alexandrescu (See Website For Email) wrote:
> 
> So I wrote a Perl script rundmd...

My first reaction to this was: what does this have to do with old-school rap?


-- 
- EricAnderton at yahoo
March 21, 2007
Anders F Björklund wrote:
> Andrei Alexandrescu (See Website For Email) wrote:
> 
>>> Rebuild has a similar feature (-exec), but it's a program not a script.
>>> I think build/bud also did, but I had problems with it and GDC/Tango...
>>
>> Sounds great. Where is rebuild? (Bud aka build is easy to find on dsource.org).
> 
> It's part of the DSSS project: (the "D Shared Software System")
> http://www.dsource.org/projects/dsss/wiki/Rebuild
> 
> I did a RPM package and manpage for it, will post them* on gdcgnu
> as part of the requirements for using Tango instead of Phobos...
> 
> --anders
> 
> * See http://www.algonet.se/~afb/d/rebuild.spec for a preview

I gave rebuild's dox a quick read, and it looks like it's almost there. Just in case you don't have enough work on your plate, here are two suggestions:

1. I'm not sure whether rebuild caches dependency information (it should, and the dox should emphatically reflect that).

2. rebuild should come with a companion program "launch" or something, which does not need any flags to compile a program - just takes the main program in argv[1], builds it, and launches it pasing to it argv[2 .. $]. This is necessary for the shebang syntax:

#!/usr/bin/env launch
... D code ...

On some platforms, env can't handle multiple words, e.g. this will not work:

#!/usr/bin/env launch -someflag
... D code ...

So launch needs to make-do flag-free. More about shebang at http://en.wikipedia.org/wiki/Shebang_(Unix).

Bottom line: rebuild is very close to the above, and implementing that will add much value for little effort.


Andrei
« First   ‹ Prev
1 2 3 4