rdmd
Georg Wrede
georg.wrede at iki.fi
Sat Mar 7 09:16:32 PST 2009
Christopher Wright wrote:
> Okay, here's an improved version of rdmd with config files.
>
> Added features:
> - Config file
> - Specify a compiler
> - Specify default imports for --eval
> - Specify build flags
> - Option to show source with --eval
> - Changed the definition of "main" with --eval to use 'in char[][]'
> rather than 'string[]' (the args probably don't matter much anyway)
> - Executables are stored in the temp directory, not the current
> directory. This way, they can be reused even if you change directories;
> and they don't clutter up your working directory.
>
> Attached is a sample rdmd.conf as well as the modified source (based on
> r958 from the phobos repository).
Heh, the last line above is just another reason to include version
information in rdmd!
If one is lazy, then a /very/ practical way is simply to have
string sourceFileVersion = "20090307 190230";
where the format is "yyyyMMdd hhmmss". A Cool guy would make his editor
look for this string in any .d file in the pre-save hook, and update it.
Entirely adequate, and a zero-effort amortized time complexity. :-)
######################################
Something like the below code (from Christopher's attachment) would make
it possible to know unambiguously and reliably what the executing
program is.
If there already isn't, there *absolutely should* exist a nice Phobos
function to do just this!!!!!
In D1 too.
> version (Posix)
> {
> // Conforming to 4.4BSD -- this should be widely available
> extern(C) size_t readlink(const char* path, char* buf, size_t buflength);
> string exePath()
> {
> char[1024] exe;
> // linux, darwin, solaris support /proc/self/exe
> // freebsd is a laggard
> auto size = readlink("/proc/self/exe".ptr, &exe[0], exe.length);
> if (size >= 0)
> {
> return assumeUnique(exe[0..size]);
> }
> return null;
> }
> }
> version (Windows)
> {
> // Conforming to 4.4BSD -- this should be widely available
> extern(C) DWORD GetModuleFileName(void* ptr, char* buf, DWORD size);
> string exePath()
> {
> DWORD length;
> char[1024] buf;
> auto length = GetModuleFileName(null, buf.ptr, buf.length);
> if (length)
> return assumeUnique(buf[0..length]);
> return null;
> }
> }
>
More information about the Digitalmars-d-announce
mailing list