getting __DIR__ and __TIME__ of compilation?

Ravn ravndust at gmail.com
Fri Dec 27 10:20:33 PST 2013


On Friday, 27 December 2013 at 15:15:31 UTC, Jacob Carlborg wrote:
> You can use this ugly hack:
>
> Create a shell script with the following content.
>
> #!/bin/bash
> echo `pwd` > dir.txt
> dmd main.d -J.
>
> And the D source code:
>
> module main;
>
> enum compilePath = import("dir.txt");
> pragma(msg, compilePath);
>
> Run the shell script to compile the D code.

I end up using something similar to your 'hack',
made a tiny wrapper in D that accepts the parameters that is 
supposed to go to dmd, get the absolute path of the compiled 
sourcecode using std.path.absolutePath(), save it inside a new 
<stuffs>.d file, the wrapper then calls the dmd compiler with 
<stuffs>.d added to the list of compiled files.

Bit of a stretch, but it'll do for now.
-Ravn-


More information about the Digitalmars-d-learn mailing list