shebang launcher for D programs

Andrei Alexandrescu (See Website For Email) SeeWebsiteForEmail at erdani.org
Sun Mar 25 10:49:48 PDT 2007


Anders F Björklund wrote:
> Andrei Alexandrescu (See Website For Email) skrev:
> 
>>> I'm not sure what you mean. If I import foo and bar, then rebuild
>>> will include foo.o and bar.o when compiling the main D program...
>>>
>>> Had I used gdmd, then I *would* have needed to include foo.o/bar.o
>>> (or a library containing those), but rebuild picks dependencies up:
>>>
>>> run.d:
>>> ======
>>> #!/usr/bin/env rdmd -v --verbose --compiler=rebuild
>>
>> Great. For some reason, it didn't work in my initial tests; I guess I've
>> been sloppy somewhere.
>>
>> Any chance you make the --compiler=rebuild a default? Or is rebuild a
>> separate product? (If so, that's not an attractive option.)
> 
> Let's see now...
> 
> rdmd as it stands at the moment is intended for dmd/gdmd, which means
> that it won't work with multi-module programs (implicitly, that is...)
> And Build/Bud or alternatively Rebuild are separate products as you say,
> so it probably shouldn't be made the default option (even if it works)
> 
> Bud: http://dsource.org/projects/build/
> Rebuild: http://dsource.org/projects/dsss/
> 
> But this is the same for all D programs, not just the "script" variant,
> with the regular D compilers you need to give it all the object files
> like you do with C/C++ compilers but with these alternative "build"
> compilers you only give it the first program like you do with javac.
> 
> i.e. even if you do use your own modules, you *could* compile those into
> a library and then link that with all your scripts using a -l option...
> It's just that the "build" tools do this for you, and can also be taught
> to pick up external libraries using: "version(build) pragma(link, baz);"
> 
> So I think it's fair to have the rdmd program default to using dmd/gdmd,
> even if bud/rebuild do exist as an optional (and recommended) D add-on ?

Well fair of course it is, it's IMHO just not enough. I strongly believe 
that an rdmd that automatically figures out dependencies must be part of 
the standard D distribution.

>> Essentially what you want is to make rdmd do the deed flag-free:
>>
>> $ rdmd prog args
>>
>> does whatever it takes to build prog.d (if necessary) and then runs it
>> passing args. Each extra needed flag cuts your cult following in half. 
>> :o)
> 
> Currently this can be done by recompiling rdmd... (assuming here that
> the rdmd source code eventually gets included in the DMD distribution)
> 
> This is the section to modify:
>     char[] exepath, dfilepath, compiler = "dmd", tmpdir = "/tmp";
>     version (GNU)
>     {
>         compiler = "gdmd";
>     }
>     version (Windows)
>     {
>         tmpdir = toString(getenv("TEMP"));
>     }
> 
> Maybe it could even use a configuration file for those two options.
> (i.e. a simple INI file for overriding --compiler and --tmpdir ?)

If you make the code open source, I'd be glad to hack into it to make it 
do the deed without relying on any other tool.


Andrei



More information about the Digitalmars-d mailing list