On Wednesday, 10 July 2013 at 12:14:39 UTC, eles wrote:
On Wednesday, 10 July 2013 at 12:03:06 UTC, eles wrote:
On Wednesday, 10 July 2013 at 10:24:17 UTC, Joseph Rushton
Wakeling wrote:
On 07/10/2013 02:07 AM, H. S. Teoh wrote:
Comments / flames / pull requests welcome. ;-)
string findGDC(string argv0)
{
// FIXME: this does not work 100% of the time.
auto c = match(baseName(argv0),
`^(.*-)?g?dmd(-.*)?$`).captures;
auto targetPrefix = c[1];
auto gdcDir = absolutePath(dirName(argv0));
return buildNormalizedPath(gdcDir, targetPrefix ~ "gdc"
~ c[2]);
}
Actually, I think this is better (diff wrt the Teoh's version):
diff --git a/gdmd.d b/gdmd.d
index 6607ce2..4c7e3eb 100644
--- a/gdmd.d
+++ b/gdmd.d
@@ -262,7 +262,14 @@ Config init(string[] args)
{
auto cfg = new Config();
cfg.scriptPath = findScriptPath(args[0]);
- cfg.gdc = findGDC(args[0]);
+ auto which = executeShell("which gdc");
+ if (which.status == 0){
+ writeln("Failed to execute which.");
+ }
+ else {
+ writefln("which returned %s", which.output);
+ }
+ cfg.gdc = findGDC(which.output);
cfg.linker = cfg.gdc;
readDmdConf(cfg);