Merge pull request #250 from joakim-noah/rdmd

Fix Issue 11997 - rdmd should search it's binary path for the compiler
merged-on-behalf-of: Vladimir Panteleev <github@thecybershadow.net>
This commit is contained in:
The Dlang Bot 2017-07-17 06:39:37 +02:00 committed by GitHub
commit ee59ec9291
3 changed files with 29 additions and 0 deletions

13
changelog/b11997.dd Normal file
View file

@ -0,0 +1,13 @@
rdmd now checks for a D compiler binary in the directory it's in first
If you downloaded a zip/tar file with the compiler before
and ran `rdmd`, it would invoke the D compiler from the system
`PATH` rather than the compiler right next to it, failing if
there wasn't one in the `PATH`. `rdmd` will now try to use
the D compiler next to it first, and only fall back to the
`PATH` if there isn't one adjacent. If you want rdmd to run a
specific compiler, add the `--compiler` flag to force it, as
always.
To restore the old behaviour of only using the compiler from
your `PATH`, add `--compiler=dmd` (or `ldmd2` or `gdmd`).

6
rdmd.d
View file

@ -59,6 +59,12 @@ version(unittest) {} else
int main(string[] args)
{
//writeln("Invoked with: ", args);
// Look for the D compiler rdmd invokes automatically in the same directory as rdmd
// and fall back to using the one in your path otherwise.
string compilerPath = buildPath(dirName(thisExePath()), defaultCompiler);
if (compilerPath.exists && compilerPath.isFile)
compiler = compilerPath;
if (args.length > 1 && args[1].startsWith("--shebang ", "--shebang="))
{
// multiple options wrapped in one

View file

@ -310,6 +310,16 @@ void runTests()
assert(res.status == -SIGSEGV, format("%s", res));
}
/* https://issues.dlang.org/show_bug.cgi?id=11997- rdmd should search its
binary path for the compiler */
string localDMD = buildPath(tempDir(), baseName(compiler));
std.file.write(localDMD, "empty shell");
scope(exit) std.file.remove(localDMD);
res = execute(rdmdApp ~ [modelSwitch, "--force", "--chatty", "--eval=writeln(`Compiler found.`);"]);
assert(res.status == 1, res.output);
assert(res.output.canFind(`spawn ["` ~ localDMD ~ `",`));
/* -of doesn't append .exe on Windows: https://d.puremagic.com/issues/show_bug.cgi?id=12149 */
version (Windows)